Skip to content

Commit

Permalink
Added Span limits support to the tracing SDK
Browse files Browse the repository at this point in the history
- Added SpanLimits class
- TracerProvider now optionally accepts an instance of SpanLimits which
is passed all the way down to Spans.
- Spans use the limits to created bounded lists or dicts for different
fields.
  • Loading branch information
owais committed May 15, 2021
1 parent 2f21502 commit 9c8ac95
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 3 additions & 0 deletions opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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()
Expand Down
5 changes: 2 additions & 3 deletions opentelemetry-sdk/tests/trace/test_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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 = [
Expand Down

0 comments on commit 9c8ac95

Please sign in to comment.