Skip to content

Commit c7ff8be

Browse files
hramezaniclaudealexmojaki
authored
Raise opentelemetry-sdk ceiling to <1.44.0 (allow 1.43) (#2042)
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> Co-authored-by: Alex Hall <alex.mojaki@gmail.com>
1 parent 019c54b commit c7ff8be

6 files changed

Lines changed: 127 additions & 110 deletions

File tree

logfire/_internal/config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff 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.

logfire/_internal/exporters/test.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff 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:

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ classifiers = [
4646
"Framework :: OpenTelemetry :: Instrumentations",
4747
]
4848
dependencies = [
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",

tests/exporters/test_otlp_session.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import pytest
1212
import requests
1313
import requests.exceptions
14+
from dirty_equals import IsStr
1415
from inline_snapshot import snapshot
1516
from opentelemetry.sdk.trace.export import SpanExportResult
1617
from 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

5154
def test_connection_error_retries(monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture) -> None:

tests/test_configure.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff 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

23062313
def get_log_record_processors() -> Iterable[LogRecordProcessor]:

0 commit comments

Comments
 (0)