Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
17 changes: 6 additions & 11 deletions go.sum
Original file line number Diff line number Diff line change
@@ -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=
Expand All @@ -17,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=
Expand All @@ -37,7 +37,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=
Expand All @@ -48,16 +47,12 @@ 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.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.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=
Expand Down
27 changes: 14 additions & 13 deletions openfeature/telemetry/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import (
"strings"

"github.com/open-feature/go-sdk/openfeature"
semconv "go.opentelemetry.io/otel/semconv/v1.25.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this package isn't included in go.mod

)

// EvaluationEvent represents an event that is emitted when a flag is evaluated.
Expand All @@ -22,22 +22,23 @@
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

Check failure on line 30 in openfeature/telemetry/telemetry.go

View workflow job for this annotation

GitHub Actions / test

undefined: semconv.FeatureFlagResultValueKey

Check failure on line 30 in openfeature/telemetry/telemetry.go

View workflow job for this annotation

GitHub Actions / lint

undefined: semconv.FeatureFlagResultValueKey
ResultVariantKey = semconv.FeatureFlagResultVariantKey

Check failure on line 31 in openfeature/telemetry/telemetry.go

View workflow job for this annotation

GitHub Actions / test

undefined: semconv.FeatureFlagResultVariantKey

Check failure on line 31 in openfeature/telemetry/telemetry.go

View workflow job for this annotation

GitHub Actions / lint

undefined: semconv.FeatureFlagResultVariantKey
ErrorMessageKey = semconv.ErrorMessageKey

Check failure on line 32 in openfeature/telemetry/telemetry.go

View workflow job for this annotation

GitHub Actions / test

undefined: semconv.ErrorMessageKey

Check failure on line 32 in openfeature/telemetry/telemetry.go

View workflow job for this annotation

GitHub Actions / lint

undefined: semconv.ErrorMessageKey
ContextIDKey = semconv.FeatureFlagContextIDKey

Check failure on line 33 in openfeature/telemetry/telemetry.go

View workflow job for this annotation

GitHub Actions / test

undefined: semconv.FeatureFlagContextIDKey

Check failure on line 33 in openfeature/telemetry/telemetry.go

View workflow job for this annotation

GitHub Actions / lint

undefined: semconv.FeatureFlagContextIDKey
ProviderNameKey = semconv.FeatureFlagProviderNameKey
ResultReasonKey = semconv.FeatureFlagResultReasonKey

Check failure on line 35 in openfeature/telemetry/telemetry.go

View workflow job for this annotation

GitHub Actions / test

undefined: semconv.FeatureFlagResultReasonKey

Check failure on line 35 in openfeature/telemetry/telemetry.go

View workflow job for this annotation

GitHub Actions / lint

undefined: semconv.FeatureFlagResultReasonKey
FlagSetIDKey = semconv.FeatureFlagSetIDKey

Check failure on line 36 in openfeature/telemetry/telemetry.go

View workflow job for this annotation

GitHub Actions / test

undefined: semconv.FeatureFlagSetIDKey

Check failure on line 36 in openfeature/telemetry/telemetry.go

View workflow job for this annotation

GitHub Actions / lint

undefined: semconv.FeatureFlagSetIDKey
VersionKey = semconv.FeatureFlagVersionKey

Check failure on line 37 in openfeature/telemetry/telemetry.go

View workflow job for this annotation

GitHub Actions / test

undefined: semconv.FeatureFlagVersionKey

Check failure on line 37 in openfeature/telemetry/telemetry.go

View workflow job for this annotation

GitHub Actions / lint

undefined: semconv.FeatureFlagVersionKey
)

// FlagEvaluationKey is the name of the feature flag evaluation event.
const FlagEvaluationKey string = "feature_flag.evaluation"
const FlagEvaluationKey = semconv.FeatureFlagEvaluationEvent

Check failure on line 41 in openfeature/telemetry/telemetry.go

View workflow job for this annotation

GitHub Actions / test

undefined: semconv.FeatureFlagEvaluationEvent

Check failure on line 41 in openfeature/telemetry/telemetry.go

View workflow job for this annotation

GitHub Actions / lint

undefined: semconv.FeatureFlagEvaluationEvent

const (
flagMetaContextIDKey string = "contextId"
Expand All @@ -49,8 +50,8 @@
// It is intended to be used in the `Finally` stage of a [openfeature.Hook].
func CreateEvaluationEvent(hookContext openfeature.HookContext, details openfeature.InterfaceEvaluationDetails) EvaluationEvent {
attributes := map[string]any{
FlagKey: hookContext.FlagKey(),

Check failure on line 53 in openfeature/telemetry/telemetry.go

View workflow job for this annotation

GitHub Actions / test

cannot use FlagKey (constant "feature_flag.key" of string type "go.opentelemetry.io/otel/attribute".Key) as string value in map literal

Check failure on line 53 in openfeature/telemetry/telemetry.go

View workflow job for this annotation

GitHub Actions / lint

cannot use FlagKey (constant "feature_flag.key" of string type "go.opentelemetry.io/otel/attribute".Key) as string value in map literal
ProviderNameKey: hookContext.ProviderMetadata().Name,

Check failure on line 54 in openfeature/telemetry/telemetry.go

View workflow job for this annotation

GitHub Actions / test

cannot use ProviderNameKey (constant "feature_flag.provider_name" of string type "go.opentelemetry.io/otel/attribute".Key) as string value in map literal

Check failure on line 54 in openfeature/telemetry/telemetry.go

View workflow job for this annotation

GitHub Actions / lint

cannot use ProviderNameKey (constant "feature_flag.provider_name" of string type "go.opentelemetry.io/otel/attribute".Key) as string value in map literal
}

attributes[ResultReasonKey] = strings.ToLower(string(openfeature.UnknownReason))
Expand Down