File tree Expand file tree Collapse file tree 3 files changed +61
-4
lines changed
src/opentelemetry/sdk/trace Expand file tree Collapse file tree 3 files changed +61
-4
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
8
8
## [ Unreleased] ( https://github.com/open-telemetry/opentelemetry-python/compare/v1.8.0-0.27b0...HEAD )
9
9
10
+ - Fix SpanLimits global span limit defaulting when set to 0
11
+ ([ #2398 ] ( https://github.com/open-telemetry/opentelemetry-python/pull/2398 ) )
10
12
- Decode URL-encoded headers in environment variables
11
13
([ #2312 ] ( https://github.com/open-telemetry/opentelemetry-python/pull/2312 ) )
12
14
- [ exporter/opentelemetry-exporter-otlp-proto-grpc] Add OTLPMetricExporter
Original file line number Diff line number Diff line change @@ -594,23 +594,31 @@ def __init__(
594
594
max_attributes , OTEL_ATTRIBUTE_COUNT_LIMIT
595
595
)
596
596
self .max_attributes = (
597
- global_max_attributes or _DEFAULT_OTEL_ATTRIBUTE_COUNT_LIMIT
597
+ global_max_attributes
598
+ if global_max_attributes is not None
599
+ else _DEFAULT_OTEL_ATTRIBUTE_COUNT_LIMIT
598
600
)
599
601
600
602
self .max_span_attributes = self ._from_env_if_absent (
601
603
max_span_attributes ,
602
604
OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT ,
603
- global_max_attributes or _DEFAULT_OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT ,
605
+ global_max_attributes
606
+ if global_max_attributes is not None
607
+ else _DEFAULT_OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT ,
604
608
)
605
609
self .max_event_attributes = self ._from_env_if_absent (
606
610
max_event_attributes ,
607
611
OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT ,
608
- global_max_attributes or _DEFAULT_OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT ,
612
+ global_max_attributes
613
+ if global_max_attributes is not None
614
+ else _DEFAULT_OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT ,
609
615
)
610
616
self .max_link_attributes = self ._from_env_if_absent (
611
617
max_link_attributes ,
612
618
OTEL_LINK_ATTRIBUTE_COUNT_LIMIT ,
613
- global_max_attributes or _DEFAULT_OTEL_LINK_ATTRIBUTE_COUNT_LIMIT ,
619
+ global_max_attributes
620
+ if global_max_attributes is not None
621
+ else _DEFAULT_OTEL_LINK_ATTRIBUTE_COUNT_LIMIT ,
614
622
)
615
623
616
624
# attribute length
Original file line number Diff line number Diff line change @@ -1594,6 +1594,53 @@ def test_span_no_limits_code(self):
1594
1594
)
1595
1595
)
1596
1596
1597
+ def test_span_zero_global_limit (self ):
1598
+ self ._test_span_limits (
1599
+ new_tracer (
1600
+ span_limits = trace .SpanLimits (
1601
+ max_attributes = 0 ,
1602
+ max_events = 0 ,
1603
+ max_links = 0 ,
1604
+ )
1605
+ ),
1606
+ 0 ,
1607
+ 0 ,
1608
+ 0 ,
1609
+ 0 ,
1610
+ 0 ,
1611
+ )
1612
+
1613
+ def test_span_zero_global_nonzero_model (self ):
1614
+ self ._test_span_limits (
1615
+ new_tracer (
1616
+ span_limits = trace .SpanLimits (
1617
+ max_attributes = 0 ,
1618
+ max_events = 0 ,
1619
+ max_links = 0 ,
1620
+ max_span_attributes = 15 ,
1621
+ max_span_attribute_length = 25 ,
1622
+ )
1623
+ ),
1624
+ 15 ,
1625
+ 0 ,
1626
+ 0 ,
1627
+ 0 ,
1628
+ 25 ,
1629
+ )
1630
+
1631
+ def test_span_zero_global_unset_model (self ):
1632
+ self ._test_span_no_limits (
1633
+ new_tracer (
1634
+ span_limits = trace .SpanLimits (
1635
+ max_attributes = 0 ,
1636
+ max_span_attributes = trace .SpanLimits .UNSET ,
1637
+ max_links = trace .SpanLimits .UNSET ,
1638
+ max_events = trace .SpanLimits .UNSET ,
1639
+ max_attribute_length = trace .SpanLimits .UNSET ,
1640
+ )
1641
+ )
1642
+ )
1643
+
1597
1644
def test_dropped_attributes (self ):
1598
1645
span = get_span_with_dropped_attributes_events_links ()
1599
1646
self .assertEqual (1 , span .dropped_links )
You can’t perform that action at this time.
0 commit comments