Skip to content

Commit

Permalink
fix: otel hook attribute naming correction (#359)
Browse files Browse the repository at this point in the history
Signed-off-by: Kavindu Dodanduwa <kavindudodanduwa@gmail.com>
  • Loading branch information
Kavindu-Dodan authored Jul 19, 2023
1 parent 4e1f46f commit 5e6ab32
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
7 changes: 7 additions & 0 deletions hooks/open-telemetry/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@
<scope>provided</scope>
</dependency>

<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-semconv</artifactId>
<version>1.28.0-alpha</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -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<String> flagKeyAttributeKey = AttributeKey.stringKey(EVENT_NAME + ".flag_key");
static final AttributeKey<String> providerNameAttributeKey = AttributeKey.stringKey(EVENT_NAME + ".provider_name");
static final AttributeKey<String> variantAttributeKey = AttributeKey.stringKey(EVENT_NAME + ".variant");

static final AttributeKey<String> flagKeyAttributeKey = SemanticAttributes.FEATURE_FLAG_KEY;
static final AttributeKey<String> providerNameAttributeKey = SemanticAttributes.FEATURE_FLAG_PROVIDER_NAME;
static final AttributeKey<String> variantAttributeKey = SemanticAttributes.FEATURE_FLAG_VARIANT;

// Define non convention attribute keys
static final String REASON_KEY = "reason";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static void close() {
mockedSpan.close();
}

private final AttributeKey<String> flagKeyAttributeKey = AttributeKey.stringKey("feature_flag.flag_key");
private final AttributeKey<String> flagKeyAttributeKey = AttributeKey.stringKey("feature_flag.key");
private final AttributeKey<String> providerNameAttributeKey = AttributeKey.stringKey("feature_flag.provider_name");
private final AttributeKey<String> variantAttributeKey = AttributeKey.stringKey("feature_flag.variant");

Expand Down

0 comments on commit 5e6ab32

Please sign in to comment.