From d12f67fc31f0376440b21083f328834693ac7ee2 Mon Sep 17 00:00:00 2001 From: Leighton Chen Date: Mon, 11 Jan 2021 12:40:38 -0800 Subject: [PATCH] Fix ids_generator references from moving from api to sdk (#283) --- .github/workflows/test.yml | 2 +- CHANGELOG.md | 2 ++ .../tests/test_datadog_format.py | 7 ++++--- .../sdk/extension/aws/trace/aws_xray_ids_generator.py | 9 ++++++--- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c4dd9b5af4..02406343a7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,7 +6,7 @@ on: - 'release/*' pull_request: env: - CORE_REPO_SHA: master + CORE_REPO_SHA: 2b188b9a43dfaa74c1a0a4514b91d1cb07d3075d jobs: build: diff --git a/CHANGELOG.md b/CHANGELOG.md index 418490c84a..0312ed9764 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -55,6 +55,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ([#261](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/261)) - `opentelemetry-instrumentation-aiopg` Fix AttributeError `__aexit__` when `aiopg.connect` and `aio[g].create_pool` used with async context manager ([#235](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/235)) +- `opentelemetry-exporter-datadog` `opentelemetry-sdk-extension-aws` Fix reference to ids_generator in sdk + ([#235](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/235)) ## [0.16b1](https://github.com/open-telemetry/opentelemetry-python-contrib/releases/tag/v0.16b1) - 2020-11-26 diff --git a/exporter/opentelemetry-exporter-datadog/tests/test_datadog_format.py b/exporter/opentelemetry-exporter-datadog/tests/test_datadog_format.py index 7f1491744f..4f5b4c07e2 100644 --- a/exporter/opentelemetry-exporter-datadog/tests/test_datadog_format.py +++ b/exporter/opentelemetry-exporter-datadog/tests/test_datadog_format.py @@ -18,6 +18,7 @@ from opentelemetry import trace as trace_api from opentelemetry.exporter.datadog import constants, propagator from opentelemetry.sdk import trace +from opentelemetry.sdk.trace.ids_generator import RandomIdsGenerator from opentelemetry.trace import get_current_span, set_span_in_context from opentelemetry.trace.propagation.textmap import DictGetter @@ -29,7 +30,7 @@ class TestDatadogFormat(unittest.TestCase): @classmethod def setUpClass(cls): - ids_generator = trace_api.RandomIdsGenerator() + ids_generator = RandomIdsGenerator() cls.serialized_trace_id = propagator.format_trace_id( ids_generator.generate_trace_id() ) @@ -107,7 +108,7 @@ def test_context_propagation(self): "child", trace_api.SpanContext( parent_span_context.trace_id, - trace_api.RandomIdsGenerator().generate_span_id(), + RandomIdsGenerator().generate_span_id(), is_remote=False, trace_flags=parent_span_context.trace_flags, trace_state=parent_span_context.trace_state, @@ -154,7 +155,7 @@ def test_sampling_priority_auto_reject(self): "child", trace_api.SpanContext( parent_span_context.trace_id, - trace_api.RandomIdsGenerator().generate_span_id(), + RandomIdsGenerator().generate_span_id(), is_remote=False, trace_flags=parent_span_context.trace_flags, trace_state=parent_span_context.trace_state, diff --git a/sdk-extension/opentelemetry-sdk-extension-aws/src/opentelemetry/sdk/extension/aws/trace/aws_xray_ids_generator.py b/sdk-extension/opentelemetry-sdk-extension-aws/src/opentelemetry/sdk/extension/aws/trace/aws_xray_ids_generator.py index aa7d51bc7d..6928e0b18d 100644 --- a/sdk-extension/opentelemetry-sdk-extension-aws/src/opentelemetry/sdk/extension/aws/trace/aws_xray_ids_generator.py +++ b/sdk-extension/opentelemetry-sdk-extension-aws/src/opentelemetry/sdk/extension/aws/trace/aws_xray_ids_generator.py @@ -15,10 +15,13 @@ import random import time -from opentelemetry import trace +from opentelemetry.sdk.trace.ids_generator import ( + IdsGenerator, + RandomIdsGenerator, +) -class AwsXRayIdsGenerator(trace.IdsGenerator): +class AwsXRayIdsGenerator(IdsGenerator): """Generates tracing IDs compatible with the AWS X-Ray tracing service. In the X-Ray system, the first 32 bits of the `TraceId` are the Unix epoch time in seconds. Since spans (AWS calls them segments) with an embedded timestamp @@ -28,7 +31,7 @@ class AwsXRayIdsGenerator(trace.IdsGenerator): See: https://docs.aws.amazon.com/xray/latest/devguide/xray-api-sendingdata.html#xray-api-traceids """ - random_ids_generator = trace.RandomIdsGenerator() + random_ids_generator = RandomIdsGenerator() def generate_span_id(self) -> int: return self.random_ids_generator.generate_span_id()