diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py index a2690b3f5fc..c202f5cbea1 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py @@ -872,10 +872,6 @@ def __init__( self.instrumentation_info = instrumentation_info self._limits = None - def _with_limits(self, limits: _Limits) -> "Tracer": - self._limits = limits - return self - @contextmanager def start_as_current_span( self, @@ -1023,7 +1019,7 @@ def get_tracer( if not instrumenting_module_name: # Reject empty strings too. instrumenting_module_name = "" logger.error("get_tracer called with missing module name.") - return Tracer( + tracer = Tracer( self.sampler, self.resource, self._active_span_processor, @@ -1031,7 +1027,9 @@ def get_tracer( InstrumentationInfo( instrumenting_module_name, instrumenting_library_version ), - )._with_limits(self._limits) + ) + tracer._limits = self._limits + return tracer def add_span_processor(self, span_processor: SpanProcessor) -> None: """Registers a new :class:`SpanProcessor` for this `TracerProvider`. diff --git a/opentelemetry-sdk/tests/trace/test_trace.py b/opentelemetry-sdk/tests/trace/test_trace.py index 760f1fa5275..c9c523c3fab 100644 --- a/opentelemetry-sdk/tests/trace/test_trace.py +++ b/opentelemetry-sdk/tests/trace/test_trace.py @@ -549,6 +549,7 @@ def test_surplus_span_links(self): self.assertEqual(len(root.links), max_links) def test_surplus_span_attributes(self): + # pylint: disable=protected-access max_attrs = trace._Limits().max_attributes attributes = {str(idx): idx for idx in range(0, 16 + max_attrs)} tracer = new_tracer()