File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1435,6 +1435,8 @@ def check_tokens():
14351435 resource = resource ,
14361436 views = self .metrics .views ,
14371437 )
1438+ # For easy testing
1439+ meter_provider ._logfire_metric_readers = metric_readers # type: ignore
14381440 for reader in metric_readers :
14391441 with suppress (Exception ):
14401442 # Prevent metric readers from recording metrics about themselves which just adds noise.
Original file line number Diff line number Diff line change @@ -150,7 +150,12 @@ def process_attribute(
150150 assert value == os .getpid ()
151151 return 1234
152152 if name == 'service.instance.id' :
153- if re .match (r'^[0-9a-f]{32}$' , value ):
153+ # OpenTelemetry <=1.42 set this to `uuid4().hex` (32 hex chars); 1.43+ uses the
154+ # dashed UUID form. Normalise either representation to a fixed value so snapshots
155+ # stay deterministic across OTel versions.
156+ if re .match (r'^[0-9a-f]{32}$' , value ) or re .match (
157+ r'^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$' , value
158+ ):
154159 return '0' * 32
155160 if parse_json_attributes and isinstance (value , str ) and (value .startswith ('{' ) or value .startswith ('[' )):
156161 try :
Original file line number Diff line number Diff line change @@ -46,8 +46,8 @@ classifiers = [
4646 " Framework :: OpenTelemetry :: Instrumentations" ,
4747]
4848dependencies = [
49- " opentelemetry-sdk >= 1.39.0, < 1.43 .0" ,
50- " opentelemetry-exporter-otlp-proto-http >= 1.39.0, < 1.43 .0" ,
49+ " opentelemetry-sdk >= 1.39.0, < 1.44 .0" ,
50+ " opentelemetry-exporter-otlp-proto-http >= 1.39.0, < 1.44 .0" ,
5151 " opentelemetry-instrumentation >= 0.41b0" ,
5252 " rich >= 13.4.2" ,
5353 " protobuf >= 4.23.4" ,
Original file line number Diff line number Diff line change 1111import pytest
1212import requests
1313import requests .exceptions
14+ from dirty_equals import IsStr
1415from inline_snapshot import snapshot
1516from opentelemetry .sdk .trace .export import SpanExportResult
1617from requests .models import PreparedRequest , Response as Response
@@ -45,7 +46,9 @@ def test_max_body_size_bytes() -> None:
4546 exporter .max_body_size = 10
4647 with pytest .raises (BodyTooLargeError ) as e :
4748 exporter .export (TEST_SPANS )
48- assert str (e .value ) == snapshot ('Request body is too large (897045 bytes), must be less than 10 bytes.' )
49+ # The exact serialized size depends on the OpenTelemetry version, so match the message shape
50+ # rather than a hardcoded byte count.
51+ assert str (e .value ) == IsStr (regex = r'Request body is too large \(\d+ bytes\), must be less than 10 bytes\.' )
4952
5053
5154def test_connection_error_retries (monkeypatch : pytest .MonkeyPatch , caplog : pytest .LogCaptureFixture ) -> None :
Original file line number Diff line number Diff line change @@ -2299,8 +2299,15 @@ def get_span_processors() -> Iterable[SpanProcessor]:
22992299 return result [1 :]
23002300
23012301
2302- def get_metric_readers () -> Iterable [SpanProcessor ]:
2303- return get_meter_provider ().provider ._sdk_config .metric_readers # type: ignore
2302+ def get_metric_readers () -> Iterable [object ]:
2303+ provider = get_meter_provider ().provider # type: ignore
2304+ result = provider ._logfire_metric_readers # type: ignore
2305+ try :
2306+ # This only works on older OTel versions and is just a sanity check now.
2307+ assert result == provider ._sdk_config .metric_readers # type: ignore
2308+ except AttributeError :
2309+ pass
2310+ return result # type: ignore
23042311
23052312
23062313def get_log_record_processors () -> Iterable [LogRecordProcessor ]:
You can’t perform that action at this time.
0 commit comments