diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py index b53cb1d1f19..bba77915a24 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py @@ -919,11 +919,13 @@ def __init__( ], id_generator: IdGenerator, instrumentation_info: InstrumentationInfo, + span_limits: SpanLimits, ) -> None: self.sampler = sampler self.resource = resource self.span_processor = span_processor self.id_generator = id_generator + self._span_limits = span_limits self.instrumentation_info = instrumentation_info self._limits = None @@ -1051,6 +1053,7 @@ def __init__( SynchronousMultiSpanProcessor, ConcurrentMultiSpanProcessor ] = None, id_generator: IdGenerator = None, + span_limits=None, ): self._active_span_processor = ( active_span_processor or SynchronousMultiSpanProcessor() diff --git a/opentelemetry-sdk/tests/trace/test_trace.py b/opentelemetry-sdk/tests/trace/test_trace.py index 5a1376a5f41..fcc3b3c0108 100644 --- a/opentelemetry-sdk/tests/trace/test_trace.py +++ b/opentelemetry-sdk/tests/trace/test_trace.py @@ -42,8 +42,8 @@ from opentelemetry.util._time import _time_ns -def new_tracer() -> trace_api.Tracer: - return trace.TracerProvider().get_tracer(__name__) +def new_tracer(span_limits=None) -> trace_api.Tracer: + return trace.TracerProvider(span_limits=span_limits).get_tracer(__name__) class TestTracer(unittest.TestCase): @@ -1318,7 +1318,6 @@ def test_span_limits_env(self): def test_span_no_limits_env(self): # pylint: disable=protected-access num_links = int(trace._DEFAULT_SPAN_LINKS_LIMIT) + randint(1, 100) - tracer = new_tracer() id_generator = RandomIdGenerator() some_links = [