diff --git a/otelx/semconv/deprecated.go b/otelx/semconv/deprecated.go new file mode 100644 index 00000000..6b15ec2c --- /dev/null +++ b/otelx/semconv/deprecated.go @@ -0,0 +1,30 @@ +// Copyright © 2024 Ory Corp +// SPDX-License-Identifier: Apache-2.0 + +package semconv + +import ( + "context" + + otelattr "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/trace" +) + +func NewDeprecatedFeatureUsedEvent(ctx context.Context, deprecatedCodeFeatureID string) (string, trace.EventOption) { + return DeprecatedFeatureUsed.String(), + trace.WithAttributes( + append( + AttributesFromContext(ctx), + AttrDeprecatedFeatureID(deprecatedCodeFeatureID), + )..., + ) +} + +const ( + AttributeKeyDeprecatedCodePathIDAttributeKey AttributeKey = "DeprecatedFeatureID" + DeprecatedFeatureUsed Event = "DeprecatedFeatureUsed" +) + +func AttrDeprecatedFeatureID(id string) otelattr.KeyValue { + return otelattr.String(AttributeKeyDeprecatedCodePathIDAttributeKey.String(), id) +}