From 6799afcd34f7ae356351d300200bd4d3938f3fd2 Mon Sep 17 00:00:00 2001 From: emdneto <9735060+emdneto@users.noreply.github.com> Date: Mon, 16 Dec 2024 17:15:30 -0300 Subject: [PATCH] add more tests as per comments Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com> --- .../tests/test_semconv.py | 58 +++++++++++++++---- 1 file changed, 47 insertions(+), 11 deletions(-) diff --git a/opentelemetry-instrumentation/tests/test_semconv.py b/opentelemetry-instrumentation/tests/test_semconv.py index b353ecc23c..6a56efcc37 100644 --- a/opentelemetry-instrumentation/tests/test_semconv.py +++ b/opentelemetry-instrumentation/tests/test_semconv.py @@ -26,7 +26,7 @@ from opentelemetry.trace.status import StatusCode -def semconv_stability_mode(mode): +def stability_mode(mode): def decorator(test_case): @patch.dict(os.environ, {OTEL_SEMCONV_STABILITY_OPT_IN: mode}) def wrapper(*args, **kwargs): @@ -40,7 +40,7 @@ def wrapper(*args, **kwargs): class TestOpenTelemetrySemConvStability(TestCase): - @semconv_stability_mode("") + @stability_mode("") def test_default_mode(self): self.assertEqual( _OpenTelemetrySemanticConventionStability._get_opentelemetry_stability_opt_in_mode( @@ -48,9 +48,15 @@ def test_default_mode(self): ), _StabilityMode.DEFAULT, ) + self.assertEqual( + _OpenTelemetrySemanticConventionStability._get_opentelemetry_stability_opt_in_mode( + _OpenTelemetryStabilitySignalType.DATABASE + ), + _StabilityMode.DEFAULT, + ) - @semconv_stability_mode("http") - def test_http_mode(self): + @stability_mode("http") + def test_http_stable_mode(self): self.assertEqual( _OpenTelemetrySemanticConventionStability._get_opentelemetry_stability_opt_in_mode( _OpenTelemetryStabilitySignalType.HTTP @@ -58,7 +64,7 @@ def test_http_mode(self): _StabilityMode.HTTP, ) - @semconv_stability_mode("http/dup") + @stability_mode("http/dup") def test_http_dup_mode(self): self.assertEqual( _OpenTelemetrySemanticConventionStability._get_opentelemetry_stability_opt_in_mode( @@ -67,8 +73,8 @@ def test_http_dup_mode(self): _StabilityMode.HTTP_DUP, ) - @semconv_stability_mode("database") - def test_database_mode(self): + @stability_mode("database") + def test_database_stable_mode(self): self.assertEqual( _OpenTelemetrySemanticConventionStability._get_opentelemetry_stability_opt_in_mode( _OpenTelemetryStabilitySignalType.DATABASE @@ -76,7 +82,7 @@ def test_database_mode(self): _StabilityMode.DATABASE, ) - @semconv_stability_mode("database/dup") + @stability_mode("database/dup") def test_database_dup_mode(self): self.assertEqual( _OpenTelemetrySemanticConventionStability._get_opentelemetry_stability_opt_in_mode( @@ -85,14 +91,44 @@ def test_database_dup_mode(self): _StabilityMode.DATABASE_DUP, ) - @semconv_stability_mode("database,http") - def test_multiple_stability_modes(self): + @stability_mode("database,http") + def test_multiple_stability_database_http_modes(self): + self.assertEqual( + _OpenTelemetrySemanticConventionStability._get_opentelemetry_stability_opt_in_mode( + _OpenTelemetryStabilitySignalType.DATABASE + ), + _StabilityMode.DATABASE, + ) + self.assertEqual( + _OpenTelemetrySemanticConventionStability._get_opentelemetry_stability_opt_in_mode( + _OpenTelemetryStabilitySignalType.HTTP + ), + _StabilityMode.HTTP, + ) + + @stability_mode("database,http/dup") + def test_multiple_stability_database_http_dup_modes(self): self.assertEqual( _OpenTelemetrySemanticConventionStability._get_opentelemetry_stability_opt_in_mode( _OpenTelemetryStabilitySignalType.DATABASE ), _StabilityMode.DATABASE, ) + self.assertEqual( + _OpenTelemetrySemanticConventionStability._get_opentelemetry_stability_opt_in_mode( + _OpenTelemetryStabilitySignalType.HTTP + ), + _StabilityMode.HTTP_DUP, + ) + + @stability_mode("database/dup,http") + def test_multiple_stability_database_dup_http_stable_modes(self): + self.assertEqual( + _OpenTelemetrySemanticConventionStability._get_opentelemetry_stability_opt_in_mode( + _OpenTelemetryStabilitySignalType.DATABASE + ), + _StabilityMode.DATABASE_DUP, + ) self.assertEqual( _OpenTelemetrySemanticConventionStability._get_opentelemetry_stability_opt_in_mode( _OpenTelemetryStabilitySignalType.HTTP @@ -100,7 +136,7 @@ def test_multiple_stability_modes(self): _StabilityMode.HTTP, ) - @semconv_stability_mode("database,database/dup,http,http/dup") + @stability_mode("database,database/dup,http,http/dup") def test_stability_mode_dup_precedence(self): self.assertEqual( _OpenTelemetrySemanticConventionStability._get_opentelemetry_stability_opt_in_mode(