Skip to content

Commit

Permalink
Fix ids_generator references from moving from api to sdk (#283)
Browse files Browse the repository at this point in the history
  • Loading branch information
lzchen authored Jan 11, 2021
1 parent 57b8106 commit d12f67f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- 'release/*'
pull_request:
env:
CORE_REPO_SHA: master
CORE_REPO_SHA: 2b188b9a43dfaa74c1a0a4514b91d1cb07d3075d

jobs:
build:
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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()
)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down

0 comments on commit d12f67f

Please sign in to comment.