Repository navigation
Conversation
opentelemetry-sdk 1.20 and 1.21 read `.dropped` from a span's attributes, events and links during OTLP export. The copy made to add the context's distinct ID, session ID and tags held plain dicts and tuples, so export failed with AttributeError. Use the SDK's bounded collections and carry over the counts the SDK dropped under its span limits.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a span ends inside a PostHog context (
identify_context,set_context_session,tag),with_request_contextrebuilds it as aReadableSpanto add the context values. The copy was given a plain dict for attributes and the original tuples for events and links.On opentelemetry-sdk 1.20 and 1.21, which
pyproject.tomlstill allows (opentelemetry-sdk>=1.20.0), the OTLP encoder reads.droppedfrom those collections, so export fails and the batch is lost:On newer SDKs export works, but the copy reports
dropped_attributes,dropped_eventsanddropped_linksas 0 even when the SDK dropped some under its span limits.The copy now uses
BoundedAttributesandBoundedList, without limits so nothing is truncated again, and carries the original span's dropped counts over. Spans with nothing to add are still returned untouched.💚 How did you test it?
test_processor.py: the exported copy reports dropped counts, and keeps the counts the SDK dropped underSpanLimits. Both fail without the change.pytest posthog/test/ai/otelon opentelemetry-sdk 1.20.0 and 1.45.2.pytest --timeout=30: 7332 passed, 64 skipped.ruff format --check,ruff check, andmypy --no-site-packages --config-file mypy.ini . | mypy-baseline filter: clean.📝 Checklist
If releasing new changes
sampo addto generate a changeset file🤖 Agent context
Autonomy: Human-driven (agent-assisted)
.droppedread, so all three are wrapped, and the dropped counts are copied so the newer-SDK case doesn't report 0.