From fb34c86b8636c403846b82a1e7bb1df071caf525 Mon Sep 17 00:00:00 2001 From: jeremydvoss Date: Tue, 17 Oct 2023 13:56:27 -0700 Subject: [PATCH 1/2] Using enum --- .../src/opentelemetry/instrumentation/utils.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/utils.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/utils.py index 0b0397a8df..1cce80bde7 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/utils.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/utils.py @@ -15,6 +15,7 @@ import os import threading import urllib.parse +from enum import Enum from re import escape, sub from typing import Dict, Sequence @@ -163,7 +164,7 @@ class _OpenTelemetryStabilitySignalType: HTTP = "http" -class _OpenTelemetryStabilityMode: +class _OpenTelemetryStabilityMode(Enum): # http - emit the new, stable HTTP and networking conventions ONLY HTTP = "http" # http/dup - emit both the old and the stable HTTP and networking conventions @@ -191,9 +192,9 @@ def _initialize(cls): if opt_in_list: # Process http opt-in # http/dup takes priority over http - if _OpenTelemetryStabilityMode.HTTP_DUP in opt_in_list: + if _OpenTelemetryStabilityMode.HTTP_DUP.value in opt_in_list: http_opt_in = _OpenTelemetryStabilityMode.HTTP_DUP - elif _OpenTelemetryStabilityMode.HTTP in opt_in_list: + elif _OpenTelemetryStabilityMode.HTTP.value in opt_in_list: http_opt_in = _OpenTelemetryStabilityMode.HTTP _OpenTelemetrySemanticConventionStability._OTEL_SEMCONV_STABILITY_SIGNAL_MAPPING[ _OpenTelemetryStabilitySignalType.HTTP From edfa99e0aa0a8fd4d8b26c2e9afc9ff32dafb153 Mon Sep 17 00:00:00 2001 From: jeremydvoss Date: Tue, 17 Oct 2023 17:46:31 -0700 Subject: [PATCH 2/2] lint --- .../src/opentelemetry/instrumentation/utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/utils.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/utils.py index 1cce80bde7..e4f9b37c37 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/utils.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/utils.py @@ -192,7 +192,10 @@ def _initialize(cls): if opt_in_list: # Process http opt-in # http/dup takes priority over http - if _OpenTelemetryStabilityMode.HTTP_DUP.value in opt_in_list: + if ( + _OpenTelemetryStabilityMode.HTTP_DUP.value + in opt_in_list + ): http_opt_in = _OpenTelemetryStabilityMode.HTTP_DUP elif _OpenTelemetryStabilityMode.HTTP.value in opt_in_list: http_opt_in = _OpenTelemetryStabilityMode.HTTP