Skip to content

Commit accf2cd

Browse files
committed
Use OTel semconv constants for feature flag telemetry attributes
Signed-off-by: Abishek Kafle <[email protected]>
1 parent 40fe27e commit accf2cd

File tree

3 files changed

+17
-23
lines changed

3 files changed

+17
-23
lines changed

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ require (
1717
github.com/hashicorp/go-memdb v1.3.4 // indirect
1818
github.com/hashicorp/golang-lru v1.0.2 // indirect
1919
github.com/spf13/pflag v1.0.7 // indirect
20+
github.com/stretchr/testify v1.11.1 // indirect
2021
)

go.sum

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
22
github.com/cucumber/gherkin/go/v26 v26.2.0 h1:EgIjePLWiPeslwIWmNQ3XHcypPsWAHoMCz/YEBKP4GI=
33
github.com/cucumber/gherkin/go/v26 v26.2.0/go.mod h1:t2GAPnB8maCT4lkHL99BDCVNzCh1d7dBhCLt150Nr/0=
4-
github.com/cucumber/godog v0.15.0 h1:51AL8lBXF3f0cyA5CV4TnJFCTHpgiy+1x1Hb3TtZUmo=
5-
github.com/cucumber/godog v0.15.0/go.mod h1:FX3rzIDybWABU4kuIXLZ/qtqEe1Ac5RdXmqvACJOces=
64
github.com/cucumber/godog v0.15.1 h1:rb/6oHDdvVZKS66hrhpjFQFHjthFSrQBCOI1LwshNTI=
75
github.com/cucumber/godog v0.15.1/go.mod h1:qju+SQDewOljHuq9NSM66s0xEhogx0q30flfxL4WUk8=
86
github.com/cucumber/messages/go/v21 v21.0.1 h1:wzA0LxwjlWQYZd32VTlAVDTkW6inOFmSM+RuOwHZiMI=
@@ -37,7 +35,6 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
3735
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
3836
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
3937
github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
40-
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
4138
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
4239
github.com/spf13/pflag v1.0.7 h1:vN6T9TfwStFPFM5XzjsvmzZkLuaLX+HS+0SeFLRgU6M=
4340
github.com/spf13/pflag v1.0.7/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
@@ -48,16 +45,10 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
4845
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
4946
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
5047
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
51-
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
52-
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
53-
go.uber.org/mock v0.5.2 h1:LbtPTcP8A5k9WPXj54PPPbjcI4Y6lhyOZXn+VS7wNko=
54-
go.uber.org/mock v0.5.2/go.mod h1:wLlUxC2vVTPTaE3UD51E0BGOAElKrILxhVSDYQLld5o=
48+
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
49+
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
5550
go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y=
5651
go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU=
57-
golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M=
58-
golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA=
59-
golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng=
60-
golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU=
6152
golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk=
6253
golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4=
6354
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

openfeature/telemetry/telemetry.go

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"strings"
66

77
"github.com/open-feature/go-sdk/openfeature"
8+
semconv "go.opentelemetry.io/otel/semconv/v1.34.0"
89
)
910

1011
// EvaluationEvent represents an event that is emitted when a flag is evaluated.
@@ -22,22 +23,23 @@ type EvaluationEvent struct {
2223
Attributes map[string]any
2324
}
2425

25-
// The OpenTelemetry compliant event attributes for flag evaluation.
26+
27+
// Use OTel semconv constants for feature flag attributes.
2628
const (
27-
FlagKey string = "feature_flag.key"
28-
ErrorTypeKey string = "error.type"
29-
ResultValueKey string = "feature_flag.result.value"
30-
ResultVariantKey string = "feature_flag.result.variant"
31-
ErrorMessageKey string = "error.message"
32-
ContextIDKey string = "feature_flag.context.id"
33-
ProviderNameKey string = "feature_flag.provider.name"
34-
ResultReasonKey string = "feature_flag.result.reason"
35-
FlagSetIDKey string = "feature_flag.set.id"
36-
VersionKey string = "feature_flag.version"
29+
FlagKey = semconv.FeatureFlagKeyKey
30+
ErrorTypeKey = semconv.ErrorTypeKey
31+
ResultValueKey = semconv.FeatureFlagResultValueKey
32+
ResultVariantKey = semconv.FeatureFlagResultVariantKey
33+
ErrorMessageKey = semconv.ErrorMessageKey
34+
ContextIDKey = semconv.FeatureFlagContextIDKey
35+
ProviderNameKey = semconv.FeatureFlagProviderNameKey
36+
ResultReasonKey = semconv.FeatureFlagResultReasonKey
37+
FlagSetIDKey = semconv.FeatureFlagSetIDKey
38+
VersionKey = semconv.FeatureFlagVersionKey
3739
)
3840

3941
// FlagEvaluationKey is the name of the feature flag evaluation event.
40-
const FlagEvaluationKey string = "feature_flag.evaluation"
42+
const FlagEvaluationKey = semconv.FeatureFlagEvaluationEvent
4143

4244
const (
4345
flagMetaContextIDKey string = "contextId"

0 commit comments

Comments
 (0)