From 01da4ce919b61cb18edf944c5df27d552ef074b3 Mon Sep 17 00:00:00 2001 From: Abishek Kafle Date: Sun, 5 Oct 2025 18:47:38 +0000 Subject: [PATCH 1/4] Use OTel semconv constants for feature flag telemetry attributes Signed-off-by: Abishek Kafle --- go.mod | 1 + go.sum | 13 ++----------- openfeature/telemetry/telemetry.go | 26 ++++++++++++++------------ 3 files changed, 17 insertions(+), 23 deletions(-) diff --git a/go.mod b/go.mod index 39b8614a..5320a761 100644 --- a/go.mod +++ b/go.mod @@ -17,4 +17,5 @@ require ( github.com/hashicorp/go-memdb v1.3.4 // indirect github.com/hashicorp/golang-lru v1.0.2 // indirect github.com/spf13/pflag v1.0.7 // indirect + github.com/stretchr/testify v1.11.1 // indirect ) diff --git a/go.sum b/go.sum index d395ce03..01a95441 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,6 @@ github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/cucumber/gherkin/go/v26 v26.2.0 h1:EgIjePLWiPeslwIWmNQ3XHcypPsWAHoMCz/YEBKP4GI= github.com/cucumber/gherkin/go/v26 v26.2.0/go.mod h1:t2GAPnB8maCT4lkHL99BDCVNzCh1d7dBhCLt150Nr/0= -github.com/cucumber/godog v0.15.0 h1:51AL8lBXF3f0cyA5CV4TnJFCTHpgiy+1x1Hb3TtZUmo= -github.com/cucumber/godog v0.15.0/go.mod h1:FX3rzIDybWABU4kuIXLZ/qtqEe1Ac5RdXmqvACJOces= github.com/cucumber/godog v0.15.1 h1:rb/6oHDdvVZKS66hrhpjFQFHjthFSrQBCOI1LwshNTI= github.com/cucumber/godog v0.15.1/go.mod h1:qju+SQDewOljHuq9NSM66s0xEhogx0q30flfxL4WUk8= 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 github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0= -github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/pflag v1.0.7 h1:vN6T9TfwStFPFM5XzjsvmzZkLuaLX+HS+0SeFLRgU6M= 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/ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -go.uber.org/mock v0.5.2 h1:LbtPTcP8A5k9WPXj54PPPbjcI4Y6lhyOZXn+VS7wNko= -go.uber.org/mock v0.5.2/go.mod h1:wLlUxC2vVTPTaE3UD51E0BGOAElKrILxhVSDYQLld5o= +github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y= go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU= -golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M= -golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA= -golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng= -golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU= golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk= golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/openfeature/telemetry/telemetry.go b/openfeature/telemetry/telemetry.go index 14f363be..b49c8960 100644 --- a/openfeature/telemetry/telemetry.go +++ b/openfeature/telemetry/telemetry.go @@ -5,6 +5,7 @@ import ( "strings" "github.com/open-feature/go-sdk/openfeature" + semconv "go.opentelemetry.io/otel/semconv/v1.34.0" ) // EvaluationEvent represents an event that is emitted when a flag is evaluated. @@ -22,22 +23,23 @@ type EvaluationEvent struct { Attributes map[string]any } -// The OpenTelemetry compliant event attributes for flag evaluation. + +// Use OTel semconv constants for feature flag attributes. const ( - FlagKey string = "feature_flag.key" - ErrorTypeKey string = "error.type" - ResultValueKey string = "feature_flag.result.value" - ResultVariantKey string = "feature_flag.result.variant" - ErrorMessageKey string = "error.message" - ContextIDKey string = "feature_flag.context.id" - ProviderNameKey string = "feature_flag.provider.name" - ResultReasonKey string = "feature_flag.result.reason" - FlagSetIDKey string = "feature_flag.set.id" - VersionKey string = "feature_flag.version" + FlagKey = semconv.FeatureFlagKeyKey + ErrorTypeKey = semconv.ErrorTypeKey + ResultValueKey = semconv.FeatureFlagResultValueKey + ResultVariantKey = semconv.FeatureFlagResultVariantKey + ErrorMessageKey = semconv.ErrorMessageKey + ContextIDKey = semconv.FeatureFlagContextIDKey + ProviderNameKey = semconv.FeatureFlagProviderNameKey + ResultReasonKey = semconv.FeatureFlagResultReasonKey + FlagSetIDKey = semconv.FeatureFlagSetIDKey + VersionKey = semconv.FeatureFlagVersionKey ) // FlagEvaluationKey is the name of the feature flag evaluation event. -const FlagEvaluationKey string = "feature_flag.evaluation" +const FlagEvaluationKey = semconv.FeatureFlagEvaluationEvent const ( flagMetaContextIDKey string = "contextId" From 41ccd8afa5a24e4f5adb63dbcd0df67618d08219 Mon Sep 17 00:00:00 2001 From: Abishek Kafle Date: Sun, 5 Oct 2025 18:51:59 +0000 Subject: [PATCH 2/4] Replaced locally defined feature flag attribute constants in the telemetry package with references to OpenTelemetry semantic conventions (semconv). Reduces maintenance and ensures alignment with OTel updates. Removes redundant constant definitions. Signed-off-by: Abishek Kafle --- openfeature/telemetry/telemetry.go | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/openfeature/telemetry/telemetry.go b/openfeature/telemetry/telemetry.go index b49c8960..5a6d5810 100644 --- a/openfeature/telemetry/telemetry.go +++ b/openfeature/telemetry/telemetry.go @@ -3,9 +3,8 @@ package telemetry import ( "strings" - "github.com/open-feature/go-sdk/openfeature" - semconv "go.opentelemetry.io/otel/semconv/v1.34.0" + semconv "go.opentelemetry.io/otel/semconv/v1.25.0" ) // EvaluationEvent represents an event that is emitted when a flag is evaluated. @@ -26,16 +25,16 @@ type EvaluationEvent struct { // Use OTel semconv constants for feature flag attributes. const ( - FlagKey = semconv.FeatureFlagKeyKey - ErrorTypeKey = semconv.ErrorTypeKey - ResultValueKey = semconv.FeatureFlagResultValueKey - ResultVariantKey = semconv.FeatureFlagResultVariantKey - ErrorMessageKey = semconv.ErrorMessageKey - ContextIDKey = semconv.FeatureFlagContextIDKey - ProviderNameKey = semconv.FeatureFlagProviderNameKey - ResultReasonKey = semconv.FeatureFlagResultReasonKey - FlagSetIDKey = semconv.FeatureFlagSetIDKey - VersionKey = semconv.FeatureFlagVersionKey + FlagKey = semconv.FeatureFlagKeyKey + ErrorTypeKey = semconv.ErrorTypeKey + ResultValueKey = semconv.FeatureFlagResultValueKey + ResultVariantKey = semconv.FeatureFlagResultVariantKey + ErrorMessageKey = semconv.ErrorMessageKey + ContextIDKey = semconv.FeatureFlagContextIDKey + ProviderNameKey = semconv.FeatureFlagProviderNameKey + ResultReasonKey = semconv.FeatureFlagResultReasonKey + FlagSetIDKey = semconv.FeatureFlagSetIDKey + VersionKey = semconv.FeatureFlagVersionKey ) // FlagEvaluationKey is the name of the feature flag evaluation event. From abde909cd24f3c28d91c39b1b8046120affd5190 Mon Sep 17 00:00:00 2001 From: Abishek Kafle Date: Mon, 6 Oct 2025 11:10:43 +0000 Subject: [PATCH 3/4] updated go.mod and go.sum Signed-off-by: Abishek Kafle --- go.mod | 1 + go.sum | 2 ++ 2 files changed, 3 insertions(+) diff --git a/go.mod b/go.mod index 5320a761..c39a7a51 100644 --- a/go.mod +++ b/go.mod @@ -18,4 +18,5 @@ require ( github.com/hashicorp/golang-lru v1.0.2 // indirect github.com/spf13/pflag v1.0.7 // indirect github.com/stretchr/testify v1.11.1 // indirect + go.opentelemetry.io/otel v1.38.0 // indirect ) diff --git a/go.sum b/go.sum index 01a95441..a874fd54 100644 --- a/go.sum +++ b/go.sum @@ -47,6 +47,8 @@ github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= +go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= +go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM= go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y= go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU= golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk= From 34088dbb8b62216a6f5e6af52d222cb1cf8abee0 Mon Sep 17 00:00:00 2001 From: Abishek Kafle Date: Mon, 6 Oct 2025 11:14:32 +0000 Subject: [PATCH 4/4] updated go.mod and go.sum Signed-off-by: Abishek Kafle --- go.mod | 3 +-- go.sum | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index c39a7a51..09e29e20 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,7 @@ go 1.24.0 require ( github.com/cucumber/godog v0.15.1 github.com/go-logr/logr v1.4.3 + go.opentelemetry.io/otel v1.38.0 go.uber.org/mock v0.6.0 golang.org/x/text v0.29.0 ) @@ -17,6 +18,4 @@ require ( github.com/hashicorp/go-memdb v1.3.4 // indirect github.com/hashicorp/golang-lru v1.0.2 // indirect github.com/spf13/pflag v1.0.7 // indirect - github.com/stretchr/testify v1.11.1 // indirect - go.opentelemetry.io/otel v1.38.0 // indirect ) diff --git a/go.sum b/go.sum index a874fd54..6209575a 100644 --- a/go.sum +++ b/go.sum @@ -15,6 +15,8 @@ github.com/gofrs/uuid v4.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRx github.com/gofrs/uuid v4.3.1+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gofrs/uuid v4.4.0+incompatible h1:3qXRTX8/NbyulANqlc0lchS1gqAVxRgsuW1YrTJupqA= github.com/gofrs/uuid v4.4.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/hashicorp/go-immutable-radix v1.3.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc= github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60=