From 12d0f97b7999d24e00bbf128405d17466d853a1f Mon Sep 17 00:00:00 2001 From: Leighton Chen Date: Fri, 26 Feb 2021 10:39:12 -0800 Subject: [PATCH 1/8] id --- CHANGELOG.md | 4 ++ docs/sdk/trace.ids_generator.rst | 4 +- docs/sdk/trace.rst | 2 +- .../src/opentelemetry/distro/__init__.py | 26 ++++++------ .../tests/test_configurator.py | 40 +++++++++---------- .../auto_instrumentation/__init__.py | 4 +- opentelemetry-sdk/setup.cfg | 4 +- .../src/opentelemetry/sdk/trace/__init__.py | 24 +++++------ .../opentelemetry/sdk/trace/ids_generator.py | 4 +- opentelemetry-sdk/tests/trace/test_trace.py | 18 ++++----- .../opentelemetry/propagators/b3/__init__.py | 6 +-- .../tests/test_b3_format.py | 14 +++---- .../tests/test_jaeger_propagator.py | 6 +-- 13 files changed, 80 insertions(+), 76 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bcb8d65d4b8..5f131112bc8 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` + ([#1584])(https://github.com/open-telemetry/opentelemetry-python/pull/1584) + ## [0.18b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v0.18b0) - 2021-02-16 ### Added diff --git a/docs/sdk/trace.ids_generator.rst b/docs/sdk/trace.ids_generator.rst index ab5ab149511..d231c2ddccc 100644 --- a/docs/sdk/trace.ids_generator.rst +++ b/docs/sdk/trace.ids_generator.rst @@ -1,7 +1,7 @@ -opentelemetry.sdk.trace.ids_generator +opentelemetry.sdk.trace.id_generator ===================================== -.. automodule:: opentelemetry.sdk.trace.ids_generator +.. automodule:: opentelemetry.sdk.trace.id_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-distro/src/opentelemetry/distro/__init__.py b/opentelemetry-distro/src/opentelemetry/distro/__init__.py index 46b469b0fb8..4748047c1a4 100644 --- a/opentelemetry-distro/src/opentelemetry/distro/__init__.py +++ b/opentelemetry-distro/src/opentelemetry/distro/__init__.py @@ -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__) @@ -45,7 +45,7 @@ _DEFAULT_IDS_GENERATOR = RANDOM_IDS_GENERATOR -def _get_ids_generator() -> str: +def _get_id_generator() -> str: return environ.get(OTEL_PYTHON_IDS_GENERATOR, _DEFAULT_IDS_GENERATOR) @@ -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..4e0af3a43c8 100644 --- a/opentelemetry-distro/tests/test_configurator.py +++ b/opentelemetry-distro/tests/test_configurator.py @@ -18,8 +18,8 @@ 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 ( @@ -27,15 +27,15 @@ 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 +60,7 @@ class OTLPExporter: pass -class CustomIdsGenerator(IdsGenerator): +class CustomIdGenerator(IdGenerator): def generate_span_id(self): pass @@ -103,12 +103,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 +117,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 +132,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_IDS_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/src/opentelemetry/instrumentation/auto_instrumentation/__init__.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/__init__.py index dfd83a4983b..8841547edf7 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/__init__.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/__init__.py @@ -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_IDS_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..8ce8001047d 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py @@ -47,9 +47,9 @@ ) 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 @@ -840,13 +840,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 +901,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 +925,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 +1003,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 +1030,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/ids_generator.py index 4e2a81b7318..7436eb2c43e 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/trace/ids_generator.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/trace/ids_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,7 +40,7 @@ def generate_trace_id(self) -> int: """ -class RandomIdsGenerator(IdsGenerator): +class RandomIdGenerator(IdGenerator): """The default IDs 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..e540884a6b7 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,7 +56,7 @@ def get_child_parent_new_carrier(old_carrier): class TestB3Format(unittest.TestCase): @classmethod def setUpClass(cls): - id_generator = ids_generator.RandomIdsGenerator() + id_generator = id_generator.RandomIdGenerator() cls.serialized_trace_id = b3_format.format_trace_id( id_generator.generate_trace_id() ) @@ -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..553b85f7f12 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,7 +68,7 @@ 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() + id_generator = id_generator.RandomIdGenerator() 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() From 7cf913e3115b25c184c941b577ca1b25742fa309 Mon Sep 17 00:00:00 2001 From: Leighton Chen Date: Fri, 26 Feb 2021 10:45:25 -0800 Subject: [PATCH 2/8] id --- CHANGELOG.md | 2 +- .../sdk/trace/{ids_generator.py => id_generator.py} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename opentelemetry-sdk/src/opentelemetry/sdk/trace/{ids_generator.py => id_generator.py} (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f131112bc8..9ddc4e879b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Rename `IdsGenerator` to `IdGenerator` - ([#1584])(https://github.com/open-telemetry/opentelemetry-python/pull/1584) + ([#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 diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/trace/ids_generator.py b/opentelemetry-sdk/src/opentelemetry/sdk/trace/id_generator.py similarity index 100% rename from opentelemetry-sdk/src/opentelemetry/sdk/trace/ids_generator.py rename to opentelemetry-sdk/src/opentelemetry/sdk/trace/id_generator.py From 0ffc0606b10ee82f81ce0f07ebd421a0e8a151f8 Mon Sep 17 00:00:00 2001 From: Leighton Chen Date: Fri, 26 Feb 2021 11:03:28 -0800 Subject: [PATCH 3/8] id --- .../src/opentelemetry/environment_variables/__init__.py | 2 +- opentelemetry-distro/src/opentelemetry/distro/__init__.py | 8 ++++---- opentelemetry-distro/tests/test_configurator.py | 4 ++-- opentelemetry-instrumentation/README.rst | 2 +- .../instrumentation/auto_instrumentation/__init__.py | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) 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 4748047c1a4..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, ) @@ -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_id_generator() -> str: - return environ.get(OTEL_PYTHON_IDS_GENERATOR, _DEFAULT_IDS_GENERATOR) + return environ.get(OTEL_PYTHON_ID_GENERATOR, _DEFAULT_ID_GENERATOR) def _get_service_name() -> str: diff --git a/opentelemetry-distro/tests/test_configurator.py b/opentelemetry-distro/tests/test_configurator.py index 4e0af3a43c8..acfe4814cc4 100644 --- a/opentelemetry-distro/tests/test_configurator.py +++ b/opentelemetry-distro/tests/test_configurator.py @@ -23,7 +23,7 @@ _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 @@ -132,7 +132,7 @@ def test_trace_init_otlp(self): ) del environ[OTEL_PYTHON_SERVICE_NAME] - @patch.dict(environ, {OTEL_PYTHON_IDS_GENERATOR: "custom_id_generator"}) + @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_id_generator(self, mock_iter_entry_points): diff --git a/opentelemetry-instrumentation/README.rst b/opentelemetry-instrumentation/README.rst index 346ae555b0d..9ff9854eb9f 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`` +* ``--ids-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 8841547edf7..3ac92eb1b46 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, ) @@ -86,7 +86,7 @@ def load_config_from_cli_args(args): if args.service_name: environ[OTEL_PYTHON_SERVICE_NAME] = args.service_name if args.id_generator: - environ[OTEL_PYTHON_IDS_GENERATOR] = args.id_generator + environ[OTEL_PYTHON_ID_GENERATOR] = args.id_generator def run() -> None: From a5798897bc209854d7548877a0aea8bed81387da Mon Sep 17 00:00:00 2001 From: Leighton Chen Date: Fri, 26 Feb 2021 11:06:55 -0800 Subject: [PATCH 4/8] id --- opentelemetry-instrumentation/README.rst | 2 +- .../instrumentation/auto_instrumentation/__init__.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/opentelemetry-instrumentation/README.rst b/opentelemetry-instrumentation/README.rst index 9ff9854eb9f..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_ID_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 3ac92eb1b46..b48cc936821 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/__init__.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/__init__.py @@ -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 """, ) From 52e679cb3371cd0db2c45fc4b8098679bce30a07 Mon Sep 17 00:00:00 2001 From: Leighton Chen Date: Fri, 26 Feb 2021 11:10:58 -0800 Subject: [PATCH 5/8] id --- .../opentelemetry-propagator-b3/tests/test_b3_format.py | 8 ++++---- .../tests/test_jaeger_propagator.py | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/propagator/opentelemetry-propagator-b3/tests/test_b3_format.py b/propagator/opentelemetry-propagator-b3/tests/test_b3_format.py index e540884a6b7..cbf19b02a2c 100644 --- a/propagator/opentelemetry-propagator-b3/tests/test_b3_format.py +++ b/propagator/opentelemetry-propagator-b3/tests/test_b3_format.py @@ -56,15 +56,15 @@ def get_child_parent_new_carrier(old_carrier): class TestB3Format(unittest.TestCase): @classmethod def setUpClass(cls): - id_generator = id_generator.RandomIdGenerator() + 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: diff --git a/propagator/opentelemetry-propagator-jaeger/tests/test_jaeger_propagator.py b/propagator/opentelemetry-propagator-jaeger/tests/test_jaeger_propagator.py index 553b85f7f12..8512678aeee 100644 --- a/propagator/opentelemetry-propagator-jaeger/tests/test_jaeger_propagator.py +++ b/propagator/opentelemetry-propagator-jaeger/tests/test_jaeger_propagator.py @@ -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 = id_generator.RandomIdGenerator() - 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 ) From f180343358dda56f5a6bc5184ee673598226483c Mon Sep 17 00:00:00 2001 From: Leighton Chen Date: Fri, 26 Feb 2021 11:11:40 -0800 Subject: [PATCH 6/8] comment --- docs/sdk/{trace.ids_generator.rst => trace.id_generator.rst} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/sdk/{trace.ids_generator.rst => trace.id_generator.rst} (100%) diff --git a/docs/sdk/trace.ids_generator.rst b/docs/sdk/trace.id_generator.rst similarity index 100% rename from docs/sdk/trace.ids_generator.rst rename to docs/sdk/trace.id_generator.rst From 62180508ead13c5c507eab704a03c2be692dc047 Mon Sep 17 00:00:00 2001 From: Leighton Chen Date: Fri, 26 Feb 2021 11:15:15 -0800 Subject: [PATCH 7/8] lint --- docs/sdk/trace.id_generator.rst | 4 ++-- opentelemetry-distro/tests/test_configurator.py | 5 +---- opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py | 5 +---- .../src/opentelemetry/sdk/trace/id_generator.py | 2 +- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/docs/sdk/trace.id_generator.rst b/docs/sdk/trace.id_generator.rst index d231c2ddccc..e0b4640e419 100644 --- a/docs/sdk/trace.id_generator.rst +++ b/docs/sdk/trace.id_generator.rst @@ -1,7 +1,7 @@ opentelemetry.sdk.trace.id_generator -===================================== +==================================== .. automodule:: opentelemetry.sdk.trace.id_generator :members: :undoc-members: - :show-inheritance: \ No newline at end of file + :show-inheritance: diff --git a/opentelemetry-distro/tests/test_configurator.py b/opentelemetry-distro/tests/test_configurator.py index acfe4814cc4..b6b80b2e602 100644 --- a/opentelemetry-distro/tests/test_configurator.py +++ b/opentelemetry-distro/tests/test_configurator.py @@ -27,10 +27,7 @@ OTEL_PYTHON_SERVICE_NAME, ) from opentelemetry.sdk.resources import Resource -from opentelemetry.sdk.trace.id_generator import ( - IdGenerator, - RandomIdGenerator, -) +from opentelemetry.sdk.trace.id_generator import IdGenerator, RandomIdGenerator class Provider: diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py index 8ce8001047d..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.id_generator import ( - IdGenerator, - RandomIdGenerator, -) +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 diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/trace/id_generator.py b/opentelemetry-sdk/src/opentelemetry/sdk/trace/id_generator.py index 7436eb2c43e..62b12a94921 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/trace/id_generator.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/trace/id_generator.py @@ -41,7 +41,7 @@ def generate_trace_id(self) -> int: class RandomIdGenerator(IdGenerator): - """The default IDs generator for TracerProvider which randomly generates all + """The default ID generator for TracerProvider which randomly generates all bits when generating IDs. """ From dbb1f72775a424086b7a1eefbb11cfcbf31d9534 Mon Sep 17 00:00:00 2001 From: Leighton Chen Date: Fri, 26 Feb 2021 12:11:26 -0800 Subject: [PATCH 8/8] sha --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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: