diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d1c0db2b9d3..34e11fc67ee 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,7 @@ env: # Otherwise, set variable to the commit of your branch on # opentelemetry-python-contrib which is compatible with these Core repo # changes. - CONTRIB_REPO_SHA: 6e328246c895ff433b14430c9edddfead072287c + CONTRIB_REPO_SHA: c86562fcddcf8fd037492de3880790776abe79ce jobs: build: diff --git a/CHANGELOG.md b/CHANGELOG.md index bcb8d65d4b8..9ddc4e879b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased](https://github.com/open-telemetry/opentelemetry-python/compare/v0.18b0...HEAD) +### Changed +- Rename `IdsGenerator` to `IdGenerator` + ([#1651])(https://github.com/open-telemetry/opentelemetry-python/pull/1651) + ## [0.18b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v0.18b0) - 2021-02-16 ### Added diff --git a/docs/sdk/trace.id_generator.rst b/docs/sdk/trace.id_generator.rst new file mode 100644 index 00000000000..e0b4640e419 --- /dev/null +++ b/docs/sdk/trace.id_generator.rst @@ -0,0 +1,7 @@ +opentelemetry.sdk.trace.id_generator +==================================== + +.. automodule:: opentelemetry.sdk.trace.id_generator + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/sdk/trace.ids_generator.rst b/docs/sdk/trace.ids_generator.rst deleted file mode 100644 index ab5ab149511..00000000000 --- a/docs/sdk/trace.ids_generator.rst +++ /dev/null @@ -1,7 +0,0 @@ -opentelemetry.sdk.trace.ids_generator -===================================== - -.. automodule:: opentelemetry.sdk.trace.ids_generator - :members: - :undoc-members: - :show-inheritance: \ No newline at end of file diff --git a/docs/sdk/trace.rst b/docs/sdk/trace.rst index 22e4fcc13f9..d163ac11e29 100644 --- a/docs/sdk/trace.rst +++ b/docs/sdk/trace.rst @@ -7,7 +7,7 @@ Submodules .. toctree:: trace.export - trace.ids_generator + trace.id_generator trace.sampling util.instrumentation diff --git a/opentelemetry-api/src/opentelemetry/environment_variables/__init__.py b/opentelemetry-api/src/opentelemetry/environment_variables/__init__.py index 3b1ee8a7e38..21d84d0f85e 100644 --- a/opentelemetry-api/src/opentelemetry/environment_variables/__init__.py +++ b/opentelemetry-api/src/opentelemetry/environment_variables/__init__.py @@ -15,7 +15,7 @@ OTEL_PROPAGATORS = "OTEL_PROPAGATORS" OTEL_PYTHON_CONTEXT = "OTEL_PYTHON_CONTEXT" OTEL_PYTHON_DISABLED_INSTRUMENTATIONS = "OTEL_PYTHON_DISABLED_INSTRUMENTATIONS" -OTEL_PYTHON_IDS_GENERATOR = "OTEL_PYTHON_IDS_GENERATOR" +OTEL_PYTHON_ID_GENERATOR = "OTEL_PYTHON_ID_GENERATOR" OTEL_PYTHON_SERVICE_NAME = "OTEL_PYTHON_SERVICE_NAME" OTEL_TRACES_EXPORTER = "OTEL_TRACES_EXPORTER" OTEL_PYTHON_TRACER_PROVIDER = "OTEL_PYTHON_TRACER_PROVIDER" diff --git a/opentelemetry-distro/src/opentelemetry/distro/__init__.py b/opentelemetry-distro/src/opentelemetry/distro/__init__.py index 46b469b0fb8..51464d51a52 100644 --- a/opentelemetry-distro/src/opentelemetry/distro/__init__.py +++ b/opentelemetry-distro/src/opentelemetry/distro/__init__.py @@ -21,7 +21,7 @@ from opentelemetry import trace from opentelemetry.environment_variables import ( - OTEL_PYTHON_IDS_GENERATOR, + OTEL_PYTHON_ID_GENERATOR, OTEL_PYTHON_SERVICE_NAME, OTEL_TRACES_EXPORTER, ) @@ -33,7 +33,7 @@ BatchExportSpanProcessor, SpanExporter, ) -from opentelemetry.sdk.trace.ids_generator import IdsGenerator +from opentelemetry.sdk.trace.id_generator import IdGenerator logger = getLogger(__file__) @@ -41,12 +41,12 @@ EXPORTER_OTLP = "otlp" EXPORTER_OTLP_SPAN = "otlp_span" -RANDOM_IDS_GENERATOR = "random" -_DEFAULT_IDS_GENERATOR = RANDOM_IDS_GENERATOR +RANDOM_ID_GENERATOR = "random" +_DEFAULT_ID_GENERATOR = RANDOM_ID_GENERATOR -def _get_ids_generator() -> str: - return environ.get(OTEL_PYTHON_IDS_GENERATOR, _DEFAULT_IDS_GENERATOR) +def _get_id_generator() -> str: + return environ.get(OTEL_PYTHON_ID_GENERATOR, _DEFAULT_ID_GENERATOR) def _get_service_name() -> str: @@ -77,12 +77,12 @@ def _get_exporter_names() -> Sequence[str]: def _init_tracing( - exporters: Sequence[SpanExporter], ids_generator: IdsGenerator + exporters: Sequence[SpanExporter], id_generator: IdGenerator ): service_name = _get_service_name() provider = TracerProvider( resource=Resource.create({"service.name": service_name}), - ids_generator=ids_generator(), + id_generator=id_generator(), ) trace.set_tracer_provider(provider) @@ -141,26 +141,26 @@ def _import_exporters( return trace_exporters -def _import_ids_generator(ids_generator_name: str) -> IdsGenerator: +def _import_id_generator(id_generator_name: str) -> IdGenerator: # pylint: disable=unbalanced-tuple-unpacking [ - (ids_generator_name, ids_generator_impl) + (id_generator_name, id_generator_impl) ] = _import_tracer_provider_config_components( - [ids_generator_name.strip()], "opentelemetry_ids_generator" + [id_generator_name.strip()], "opentelemetry_id_generator" ) - if issubclass(ids_generator_impl, IdsGenerator): - return ids_generator_impl + if issubclass(id_generator_impl, IdGenerator): + return id_generator_impl - raise RuntimeError("{0} is not an IdsGenerator".format(ids_generator_name)) + raise RuntimeError("{0} is not an IdGenerator".format(id_generator_name)) def _initialize_components(): exporter_names = _get_exporter_names() trace_exporters = _import_exporters(exporter_names) - ids_generator_name = _get_ids_generator() - ids_generator = _import_ids_generator(ids_generator_name) - _init_tracing(trace_exporters, ids_generator) + id_generator_name = _get_id_generator() + id_generator = _import_id_generator(id_generator_name) + _init_tracing(trace_exporters, id_generator) class Configurator(BaseConfigurator): diff --git a/opentelemetry-distro/tests/test_configurator.py b/opentelemetry-distro/tests/test_configurator.py index e1a8cfc8ae0..b6b80b2e602 100644 --- a/opentelemetry-distro/tests/test_configurator.py +++ b/opentelemetry-distro/tests/test_configurator.py @@ -18,24 +18,21 @@ from unittest.mock import patch from opentelemetry.distro import ( - _get_ids_generator, - _import_ids_generator, + _get_id_generator, + _import_id_generator, _init_tracing, ) from opentelemetry.environment_variables import ( - OTEL_PYTHON_IDS_GENERATOR, + OTEL_PYTHON_ID_GENERATOR, OTEL_PYTHON_SERVICE_NAME, ) from opentelemetry.sdk.resources import Resource -from opentelemetry.sdk.trace.ids_generator import ( - IdsGenerator, - RandomIdsGenerator, -) +from opentelemetry.sdk.trace.id_generator import IdGenerator, RandomIdGenerator class Provider: - def __init__(self, resource=None, ids_generator=None): - self.ids_generator = ids_generator + def __init__(self, resource=None, id_generator=None): + self.id_generator = id_generator self.processor = None self.resource = resource @@ -60,7 +57,7 @@ class OTLPExporter: pass -class CustomIdsGenerator(IdsGenerator): +class CustomIdGenerator(IdGenerator): def generate_span_id(self): pass @@ -103,12 +100,12 @@ def tearDown(self): # pylint: disable=protected-access def test_trace_init_default(self): environ[OTEL_PYTHON_SERVICE_NAME] = "my-test-service" - _init_tracing({"zipkin": Exporter}, RandomIdsGenerator) + _init_tracing({"zipkin": Exporter}, RandomIdGenerator) self.assertEqual(self.set_provider_mock.call_count, 1) provider = self.set_provider_mock.call_args[0][0] self.assertIsInstance(provider, Provider) - self.assertIsInstance(provider.ids_generator, RandomIdsGenerator) + self.assertIsInstance(provider.id_generator, RandomIdGenerator) self.assertIsInstance(provider.processor, Processor) self.assertIsInstance(provider.processor.exporter, Exporter) self.assertEqual( @@ -117,12 +114,12 @@ def test_trace_init_default(self): def test_trace_init_otlp(self): environ[OTEL_PYTHON_SERVICE_NAME] = "my-otlp-test-service" - _init_tracing({"otlp": OTLPExporter}, RandomIdsGenerator) + _init_tracing({"otlp": OTLPExporter}, RandomIdGenerator) self.assertEqual(self.set_provider_mock.call_count, 1) provider = self.set_provider_mock.call_args[0][0] self.assertIsInstance(provider, Provider) - self.assertIsInstance(provider.ids_generator, RandomIdsGenerator) + self.assertIsInstance(provider.id_generator, RandomIdGenerator) self.assertIsInstance(provider.processor, Processor) self.assertIsInstance(provider.processor.exporter, OTLPExporter) self.assertIsInstance(provider.resource, Resource) @@ -132,17 +129,17 @@ def test_trace_init_otlp(self): ) del environ[OTEL_PYTHON_SERVICE_NAME] - @patch.dict(environ, {OTEL_PYTHON_IDS_GENERATOR: "custom_ids_generator"}) - @patch("opentelemetry.distro.IdsGenerator", new=IdsGenerator) + @patch.dict(environ, {OTEL_PYTHON_ID_GENERATOR: "custom_id_generator"}) + @patch("opentelemetry.distro.IdGenerator", new=IdGenerator) @patch("opentelemetry.distro.iter_entry_points") - def test_trace_init_custom_ids_generator(self, mock_iter_entry_points): + def test_trace_init_custom_id_generator(self, mock_iter_entry_points): mock_iter_entry_points.configure_mock( return_value=[ - IterEntryPoint("custom_ids_generator", CustomIdsGenerator) + IterEntryPoint("custom_id_generator", CustomIdGenerator) ] ) - ids_generator_name = _get_ids_generator() - ids_generator = _import_ids_generator(ids_generator_name) - _init_tracing({}, ids_generator) + id_generator_name = _get_id_generator() + id_generator = _import_id_generator(id_generator_name) + _init_tracing({}, id_generator) provider = self.set_provider_mock.call_args[0][0] - self.assertIsInstance(provider.ids_generator, CustomIdsGenerator) + self.assertIsInstance(provider.id_generator, CustomIdGenerator) diff --git a/opentelemetry-instrumentation/README.rst b/opentelemetry-instrumentation/README.rst index 346ae555b0d..14ba530e830 100644 --- a/opentelemetry-instrumentation/README.rst +++ b/opentelemetry-instrumentation/README.rst @@ -72,7 +72,7 @@ Well known trace exporter names: When present the value is passed on to the relevant exporter initializer as ``service_name`` argument. -* ``--ids-generator`` or ``OTEL_PYTHON_IDS_GENERATOR`` +* ``--id-generator`` or ``OTEL_PYTHON_ID_GENERATOR`` Used to specify which IDs Generator to use for the global Tracer Provider. By default, it will use the random IDs generator. diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/__init__.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/__init__.py index dfd83a4983b..b48cc936821 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/__init__.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/__init__.py @@ -21,7 +21,7 @@ from shutil import which from opentelemetry.environment_variables import ( - OTEL_PYTHON_IDS_GENERATOR, + OTEL_PYTHON_ID_GENERATOR, OTEL_PYTHON_SERVICE_NAME, OTEL_TRACES_EXPORTER, ) @@ -51,14 +51,14 @@ def parse_args(): ) parser.add_argument( - "--ids-generator", + "--id-generator", required=False, help=""" The IDs Generator to be used with the Tracer Provider. Examples: - --ids-generator=random + --id-generator=random """, ) @@ -85,8 +85,8 @@ def load_config_from_cli_args(args): environ[OTEL_TRACES_EXPORTER] = args.trace_exporter if args.service_name: environ[OTEL_PYTHON_SERVICE_NAME] = args.service_name - if args.ids_generator: - environ[OTEL_PYTHON_IDS_GENERATOR] = args.ids_generator + if args.id_generator: + environ[OTEL_PYTHON_ID_GENERATOR] = args.id_generator def run() -> None: diff --git a/opentelemetry-sdk/setup.cfg b/opentelemetry-sdk/setup.cfg index 231b7159802..5573fa7127b 100644 --- a/opentelemetry-sdk/setup.cfg +++ b/opentelemetry-sdk/setup.cfg @@ -52,8 +52,8 @@ opentelemetry_tracer_provider = sdk_tracer_provider = opentelemetry.sdk.trace:TracerProvider opentelemetry_exporter = console_span = opentelemetry.sdk.trace.export:ConsoleSpanExporter -opentelemetry_ids_generator = - random = opentelemetry.sdk.trace.ids_generator:RandomIdsGenerator +opentelemetry_id_generator = + random = opentelemetry.sdk.trace.id_generator:RandomIdGenerator [options.extras_require] test = diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py index e3f489706ff..ddfc2e2c934 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py @@ -47,10 +47,7 @@ ) from opentelemetry.sdk.resources import Resource from opentelemetry.sdk.trace import sampling -from opentelemetry.sdk.trace.ids_generator import ( - IdsGenerator, - RandomIdsGenerator, -) +from opentelemetry.sdk.trace.id_generator import IdGenerator, RandomIdGenerator from opentelemetry.sdk.util import BoundedDict, BoundedList from opentelemetry.sdk.util.instrumentation import InstrumentationInfo from opentelemetry.trace import SpanContext @@ -840,13 +837,13 @@ def __init__( span_processor: Union[ SynchronousMultiSpanProcessor, ConcurrentMultiSpanProcessor ], - ids_generator: IdsGenerator, + id_generator: IdGenerator, instrumentation_info: InstrumentationInfo, ) -> None: self.sampler = sampler self.resource = resource self.span_processor = span_processor - self.ids_generator = ids_generator + self.id_generator = id_generator self.instrumentation_info = instrumentation_info @contextmanager @@ -901,7 +898,7 @@ def start_span( # pylint: disable=too-many-locals # is_valid determines root span if parent_span_context is None or not parent_span_context.is_valid: parent_span_context = None - trace_id = self.ids_generator.generate_trace_id() + trace_id = self.id_generator.generate_trace_id() trace_flags = None trace_state = None else: @@ -925,7 +922,7 @@ def start_span( # pylint: disable=too-many-locals ) span_context = trace_api.SpanContext( trace_id, - self.ids_generator.generate_span_id(), + self.id_generator.generate_span_id(), is_remote=False, trace_flags=trace_flags, trace_state=sampling_result.trace_state, @@ -1003,15 +1000,15 @@ def __init__( active_span_processor: Union[ SynchronousMultiSpanProcessor, ConcurrentMultiSpanProcessor ] = None, - ids_generator: IdsGenerator = None, + id_generator: IdGenerator = None, ): self._active_span_processor = ( active_span_processor or SynchronousMultiSpanProcessor() ) - if ids_generator is None: - self.ids_generator = RandomIdsGenerator() + if id_generator is None: + self.id_generator = RandomIdGenerator() else: - self.ids_generator = ids_generator + self.id_generator = id_generator self.resource = resource self.sampler = sampler self._atexit_handler = None @@ -1030,7 +1027,7 @@ def get_tracer( self.sampler, self.resource, self._active_span_processor, - self.ids_generator, + self.id_generator, InstrumentationInfo( instrumenting_module_name, instrumenting_library_version ), diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/trace/ids_generator.py b/opentelemetry-sdk/src/opentelemetry/sdk/trace/id_generator.py similarity index 91% rename from opentelemetry-sdk/src/opentelemetry/sdk/trace/ids_generator.py rename to opentelemetry-sdk/src/opentelemetry/sdk/trace/id_generator.py index 4e2a81b7318..62b12a94921 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/trace/ids_generator.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/trace/id_generator.py @@ -16,7 +16,7 @@ import random -class IdsGenerator(abc.ABC): +class IdGenerator(abc.ABC): @abc.abstractmethod def generate_span_id(self) -> int: """Get a new span ID. @@ -40,8 +40,8 @@ def generate_trace_id(self) -> int: """ -class RandomIdsGenerator(IdsGenerator): - """The default IDs generator for TracerProvider which randomly generates all +class RandomIdGenerator(IdGenerator): + """The default ID generator for TracerProvider which randomly generates all bits when generating IDs. """ diff --git a/opentelemetry-sdk/tests/trace/test_trace.py b/opentelemetry-sdk/tests/trace/test_trace.py index 043c6dc0e3c..f83d949a85b 100644 --- a/opentelemetry-sdk/tests/trace/test_trace.py +++ b/opentelemetry-sdk/tests/trace/test_trace.py @@ -34,7 +34,7 @@ OTEL_TRACES_SAMPLER_ARG, ) from opentelemetry.sdk.trace import Resource, sampling -from opentelemetry.sdk.trace.ids_generator import RandomIdsGenerator +from opentelemetry.sdk.trace.id_generator import RandomIdGenerator from opentelemetry.sdk.util import ns_to_iso_str from opentelemetry.sdk.util.instrumentation import InstrumentationInfo from opentelemetry.trace.status import StatusCode @@ -791,15 +791,15 @@ def test_invalid_event_attributes(self): self.assertEqual(root.events[3].attributes, {"attr2": (1, 2)}) def test_links(self): - ids_generator = RandomIdsGenerator() + id_generator = RandomIdGenerator() other_context1 = trace_api.SpanContext( - trace_id=ids_generator.generate_trace_id(), - span_id=ids_generator.generate_span_id(), + trace_id=id_generator.generate_trace_id(), + span_id=id_generator.generate_span_id(), is_remote=False, ) other_context2 = trace_api.SpanContext( - trace_id=ids_generator.generate_trace_id(), - span_id=ids_generator.generate_span_id(), + trace_id=id_generator.generate_trace_id(), + span_id=id_generator.generate_span_id(), is_remote=False, ) @@ -1297,12 +1297,12 @@ class TestSpanLimits(unittest.TestCase): def test_span_environment_limits(self): reload(trace) tracer = new_tracer() - ids_generator = RandomIdsGenerator() + id_generator = RandomIdGenerator() some_links = [ trace_api.Link( trace_api.SpanContext( - trace_id=ids_generator.generate_trace_id(), - span_id=ids_generator.generate_span_id(), + trace_id=id_generator.generate_trace_id(), + span_id=id_generator.generate_span_id(), is_remote=False, ) ) diff --git a/propagator/opentelemetry-propagator-b3/src/opentelemetry/propagators/b3/__init__.py b/propagator/opentelemetry-propagator-b3/src/opentelemetry/propagators/b3/__init__.py index 7f59ff417b7..e872cef9e6c 100644 --- a/propagator/opentelemetry-propagator-b3/src/opentelemetry/propagators/b3/__init__.py +++ b/propagator/opentelemetry-propagator-b3/src/opentelemetry/propagators/b3/__init__.py @@ -94,9 +94,9 @@ def extract( self._trace_id_regex.fullmatch(trace_id) is None or self._span_id_regex.fullmatch(span_id) is None ): - ids_generator = trace.get_tracer_provider().ids_generator - trace_id = ids_generator.generate_trace_id() - span_id = ids_generator.generate_span_id() + id_generator = trace.get_tracer_provider().id_generator + trace_id = id_generator.generate_trace_id() + span_id = id_generator.generate_span_id() sampled = "0" else: diff --git a/propagator/opentelemetry-propagator-b3/tests/test_b3_format.py b/propagator/opentelemetry-propagator-b3/tests/test_b3_format.py index aea06b47fb9..cbf19b02a2c 100644 --- a/propagator/opentelemetry-propagator-b3/tests/test_b3_format.py +++ b/propagator/opentelemetry-propagator-b3/tests/test_b3_format.py @@ -17,7 +17,7 @@ import opentelemetry.propagators.b3 as b3_format # pylint: disable=no-name-in-module,import-error import opentelemetry.sdk.trace as trace -import opentelemetry.sdk.trace.ids_generator as ids_generator +import opentelemetry.sdk.trace.id_generator as id_generator import opentelemetry.trace as trace_api from opentelemetry.context import get_current from opentelemetry.trace.propagation.textmap import DictGetter @@ -38,7 +38,7 @@ def get_child_parent_new_carrier(old_carrier): "child", trace_api.SpanContext( parent_span_context.trace_id, - ids_generator.RandomIdsGenerator().generate_span_id(), + id_generator.RandomIdGenerator().generate_span_id(), is_remote=False, trace_flags=parent_span_context.trace_flags, trace_state=parent_span_context.trace_state, @@ -56,15 +56,15 @@ def get_child_parent_new_carrier(old_carrier): class TestB3Format(unittest.TestCase): @classmethod def setUpClass(cls): - id_generator = ids_generator.RandomIdsGenerator() + generator = id_generator.RandomIdGenerator() cls.serialized_trace_id = b3_format.format_trace_id( - id_generator.generate_trace_id() + generator.generate_trace_id() ) cls.serialized_span_id = b3_format.format_span_id( - id_generator.generate_span_id() + generator.generate_span_id() ) cls.serialized_parent_id = b3_format.format_span_id( - id_generator.generate_span_id() + generator.generate_span_id() ) def setUp(self) -> None: @@ -256,10 +256,10 @@ def test_missing_trace_id(self): self.assertEqual(span_context.trace_id, trace_api.INVALID_TRACE_ID) @patch( - "opentelemetry.sdk.trace.ids_generator.RandomIdsGenerator.generate_trace_id" + "opentelemetry.sdk.trace.id_generator.RandomIdGenerator.generate_trace_id" ) @patch( - "opentelemetry.sdk.trace.ids_generator.RandomIdsGenerator.generate_span_id" + "opentelemetry.sdk.trace.id_generator.RandomIdGenerator.generate_span_id" ) def test_invalid_trace_id( self, mock_generate_span_id, mock_generate_trace_id @@ -282,10 +282,10 @@ def test_invalid_trace_id( self.assertEqual(span_context.span_id, 2) @patch( - "opentelemetry.sdk.trace.ids_generator.RandomIdsGenerator.generate_trace_id" + "opentelemetry.sdk.trace.id_generator.RandomIdGenerator.generate_trace_id" ) @patch( - "opentelemetry.sdk.trace.ids_generator.RandomIdsGenerator.generate_span_id" + "opentelemetry.sdk.trace.id_generator.RandomIdGenerator.generate_span_id" ) def test_invalid_span_id( self, mock_generate_span_id, mock_generate_trace_id diff --git a/propagator/opentelemetry-propagator-jaeger/tests/test_jaeger_propagator.py b/propagator/opentelemetry-propagator-jaeger/tests/test_jaeger_propagator.py index 46c554d4f5e..8512678aeee 100644 --- a/propagator/opentelemetry-propagator-jaeger/tests/test_jaeger_propagator.py +++ b/propagator/opentelemetry-propagator-jaeger/tests/test_jaeger_propagator.py @@ -16,7 +16,7 @@ from unittest.mock import Mock import opentelemetry.sdk.trace as trace -import opentelemetry.sdk.trace.ids_generator as ids_generator +import opentelemetry.sdk.trace.id_generator as id_generator import opentelemetry.trace as trace_api from opentelemetry import baggage from opentelemetry.propagators import ( # pylint: disable=no-name-in-module @@ -43,7 +43,7 @@ def get_context_new_carrier(old_carrier, carrier_baggage=None): "child", trace_api.SpanContext( parent_span_context.trace_id, - ids_generator.RandomIdsGenerator().generate_span_id(), + id_generator.RandomIdGenerator().generate_span_id(), is_remote=False, trace_flags=parent_span_context.trace_flags, trace_state=parent_span_context.trace_state, @@ -68,10 +68,10 @@ def _format_uber_trace_id(trace_id, span_id, parent_span_id, flags): class TestJaegerPropagator(unittest.TestCase): @classmethod def setUpClass(cls): - id_generator = ids_generator.RandomIdsGenerator() - cls.trace_id = id_generator.generate_trace_id() - cls.span_id = id_generator.generate_span_id() - cls.parent_span_id = id_generator.generate_span_id() + generator = id_generator.RandomIdGenerator() + cls.trace_id = generator.generate_trace_id() + cls.span_id = generator.generate_span_id() + cls.parent_span_id = generator.generate_span_id() cls.serialized_uber_trace_id = _format_uber_trace_id( cls.trace_id, cls.span_id, cls.parent_span_id, 11 )