fix(opentelemetry): update tests for otel sdk 1.40.0 compatibility#4662
Conversation
cc022b7 to
3786661
Compare
xrmx
left a comment
There was a problem hiding this comment.
I think you also need to remove the upper bound in pyproject.toml to see if it's working with 1.40.0.
|
hey @xrmx, yep already done that but not doing the unpin in this pr - leaving it to the more established contributors relevant diffs / pip show
make test-all output
so yeah technically this is already able to receive otel 1.40.0 I guess, but still better to also fix upstream the unsafe access |
|
Thanks for this @giorgiovilardo! I agree with @xrmx though, we should remove the version constraint in this same PR |
5082765 to
72ba042
Compare
|
@provinzkraut done ;) |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4662 +/- ##
=======================================
Coverage 67.33% 67.33%
=======================================
Files 292 292
Lines 14938 14938
Branches 1675 1675
=======================================
Hits 10058 10058
Misses 4743 4743
Partials 137 137 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
72ba042 to
c71f29f
Compare
c71f29f to
6f585a1
Compare


Description
Referring to opentelemetry-python#5009, the issue is a bit nuanced: there is one change to make upstream - long story very short, there is an unsafe attribute access that is triggered by passing no boundaries to
ExplicitBucketHistogramAggregationi.e.aggregation_last_value = {Counter: ExplicitBucketHistogramAggregation()}and then pass this aspreferred_aggregationto theInMemoryMetricReader, intests/unit/test_contrib/test_opentelemetry.py:33-35.This will be fixed upstream but also made more robust on Litestar side with the proposed change:
aggregation_last_value = {Counter: ExplicitBucketHistogramAggregation(boundaries=[])}By fixing this, we would expose a subsequent problem on
test_open_telemetry_middleware_with_http_route, more specifically when navigatingscope_metricsvia index withscope_metrics = resource_metrics.scope_metrics[0]; this is due to 1.40.0TracerProviders having a newTracerMetricsclass that instruments them. This changes the ordering on thescope_metrics, making indexed access fail.The other proposed change will just get the correct scope skipping the otel tagged one.
This will allow, once upstream is done, to unpin (or in general update)
opentelemetry-sdk📚 Documentation preview 📚: https://litestar-org.github.io/litestar-docs-preview/4662