Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ids_generator references from moving from api to sdk #283

Merged
merged 2 commits into from
Jan 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we be promoting direct imports from these sub-modules, or just ensuring that all required classes can be imported from the top-level-ish opentelemetry.sdk.trace module?

I feel like it's a bit rigid to import things from opentelemetry.sdk.trace.ids_generator (can't refactor the codebase if you have to split classes / etc).

If you make opentelemetry.sdk.trace a kitchen sink with all of these classes, you not only enable that ability to refactor, but you also reduce the friction on the user having to remember what module some class actually is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you but possibly could be addressed in a later date.

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