diff --git a/hooks/open-telemetry/pom.xml b/hooks/open-telemetry/pom.xml index 17d92f22e..df000b9c0 100644 --- a/hooks/open-telemetry/pom.xml +++ b/hooks/open-telemetry/pom.xml @@ -45,6 +45,13 @@ provided + + io.opentelemetry + opentelemetry-semconv + 1.28.0-alpha + provided + + io.opentelemetry opentelemetry-api diff --git a/hooks/open-telemetry/src/main/java/dev/openfeature/contrib/hooks/otel/OTelCommons.java b/hooks/open-telemetry/src/main/java/dev/openfeature/contrib/hooks/otel/OTelCommons.java index a61a56ecf..8a6721389 100644 --- a/hooks/open-telemetry/src/main/java/dev/openfeature/contrib/hooks/otel/OTelCommons.java +++ b/hooks/open-telemetry/src/main/java/dev/openfeature/contrib/hooks/otel/OTelCommons.java @@ -1,14 +1,16 @@ package dev.openfeature.contrib.hooks.otel; import io.opentelemetry.api.common.AttributeKey; +import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; class OTelCommons { // Define semantic conventions // Refer - https://opentelemetry.io/docs/specs/otel/logs/semantic_conventions/feature-flags/ static final String EVENT_NAME = "feature_flag"; - static final AttributeKey flagKeyAttributeKey = AttributeKey.stringKey(EVENT_NAME + ".flag_key"); - static final AttributeKey providerNameAttributeKey = AttributeKey.stringKey(EVENT_NAME + ".provider_name"); - static final AttributeKey variantAttributeKey = AttributeKey.stringKey(EVENT_NAME + ".variant"); + + static final AttributeKey flagKeyAttributeKey = SemanticAttributes.FEATURE_FLAG_KEY; + static final AttributeKey providerNameAttributeKey = SemanticAttributes.FEATURE_FLAG_PROVIDER_NAME; + static final AttributeKey variantAttributeKey = SemanticAttributes.FEATURE_FLAG_VARIANT; // Define non convention attribute keys static final String REASON_KEY = "reason"; diff --git a/hooks/open-telemetry/src/test/java/dev/openfeature/contrib/hooks/otel/TracesHookTest.java b/hooks/open-telemetry/src/test/java/dev/openfeature/contrib/hooks/otel/TracesHookTest.java index 526c25ff0..c03ed2c79 100644 --- a/hooks/open-telemetry/src/test/java/dev/openfeature/contrib/hooks/otel/TracesHookTest.java +++ b/hooks/open-telemetry/src/test/java/dev/openfeature/contrib/hooks/otel/TracesHookTest.java @@ -36,7 +36,7 @@ public static void close() { mockedSpan.close(); } - private final AttributeKey flagKeyAttributeKey = AttributeKey.stringKey("feature_flag.flag_key"); + private final AttributeKey flagKeyAttributeKey = AttributeKey.stringKey("feature_flag.key"); private final AttributeKey providerNameAttributeKey = AttributeKey.stringKey("feature_flag.provider_name"); private final AttributeKey variantAttributeKey = AttributeKey.stringKey("feature_flag.variant");