open-feature / open-feature/go-sdk

[FEATURE] Refactor telemetry package

Open
#407 7 comments 1 reaction 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
249
Forks
61
Avg merge
2d 10h
Merged PRs (30d)
20

Description

### Requirements

I would like to improve the [telemetry](https://github.com/open-feature/go-sdk/blob/main/openfeature/telemetry/telemetry.go) package:

- Omit the value from the returned attributes. The value is of type `any` and this results in the loss of type safety (use of `map[string]any`). Instead, by omitting the value, the attributes map can be of type `map[string]string`, which is much easier to work with. The value is otherwise very easy to obtain via `details.Value` anyways.
- The "Name" of the evaluation event should not be returned. Instead, since that is already a const in the package, users can just use that const wherever it is needed. Ideally, this event name const `feature_flag.evaluation` should eventually make its way into the OTel semconv (as a const). Currently it is [in the spec](https://opentelemetry.io/docs/specs/semconv/feature-flags/feature-flags-logs/) but not in the [semconv package](https://pkg.go.dev/go.opentelemetry.io/otel@v1.37.0/semconv/v1.34.0).
- Refactor the `CreateEvaluationEvent` function to make it work for ALL stages of a hook, rather than just `after` and `finally`. To do that, we could modify the `details openfeature.InterfaceEvaluationDetails` parameter to be a pointer so that a nil check can be performed before adding additional attributes derived from the details. This allows the package to be a bit more useful. This is not a huge deal though, given that there are only two attributes in the hookContext.

I think the goal should be for this package to be used in both the existing logging hook and the OTel hook in go-sdk-contrib.

Related issue: #393

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.