feat(traces): per-span limits and exception stacktraces - #955
Open
turnipdabeets wants to merge 1 commit into
Open
turnipdabeets wants to merge 1 commit into
turnipdabeets wants to merge 1 commit into
Conversation
Contributor
Prompt To Fix All With AI### Issue 1
posthog/tracing/_limits.py:98
**Nested keys bypass limits**
A nested mapping with a very long key bypasses `max_attribute_value_length` because this stores the original key. The OTLP encoder later emits that key without truncation, so it can make the batch exceed the transport limit and be dropped. Store the truncated `key_str` instead.
```suggestion
bounded[truncate_string(key_str, max_length)] = item
```
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "feat(traces): per-span limits and except..." | Re-trigger Greptile |
Contributor
posthog-python Compliance ReportDate: 2026-09-15 22:09:40 UTC ✅ All Tests Passed!111/111 tests passed Capture_V1 Tests✅ 94/94 tests passed View Details
Feature_Flags Tests✅ 17/17 tests passed View Details
|
This was referenced Sep 14, 2026
turnipdabeets
force-pushed
the
traces/07-span-limits
branch
from
September 14, 2026 22:58
384a4a8 to
8de0208
Compare
turnipdabeets
added this pull request to stack #958
September 14, 2026 23:03
turnipdabeets
force-pushed
the
traces/07-span-limits
branch
from
September 15, 2026 14:09
8de0208 to
8088f97
Compare
turnipdabeets
force-pushed
the
traces/07-span-limits
branch
2 times, most recently
from
September 15, 2026 14:25
f02e6b4 to
3a514f7
Compare
Bounds what one span can hold, per the traces spec. A span keeps at most max_attributes_per_span user attributes and max_events_per_span events (128 each, earliest-set wins), and each event at most 128 attributes; what the caps refuse is reported as droppedAttributesCount / droppedEventsCount, clamped to uint32. The posthogDistinctId and sessionId join keys are exempt. max_attribute_value_length (8192) bounds every string an attribute holds, nested ones included, along with span and event names, status messages and resource attributes, so one large value cannot get a span dropped as too large. Recorded exceptions now carry exception.stacktrace, keeping the tail of the traceback where Python puts the raising frame. Not reachable from the client. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TkZAsCciW4PV8ZdcCHmAbA
turnipdabeets
force-pushed
the
traces/07-span-limits
branch
from
September 15, 2026 22:04
3a514f7 to
21a1004
Compare
turnipdabeets
marked this pull request as ready for review
September 16, 2026 14:34
Contributor
|
Reviews (2): Last reviewed commit: "feat(traces): per-span limits and except..." | Re-trigger Greptile |
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.
💡 Motivation and Context
Bounds what one span can hold, per the traces spec.
max_attributes_per_spanuser attributes andmax_events_per_spanevents (128 each, earliest-set wins); each event at most 128 attributes. Overflow is reported asdroppedAttributesCount/droppedEventsCount, clamped to uint32. TheposthogDistinctIdandsessionIdjoin keys are exempt.max_attribute_value_length(8192) bounds every string an attribute holds, nested ones included, plus span and event names, status messages and resource attributes, so one large value cannot get a span dropped as too large.exception.stacktrace, keeping the tail of the traceback where Python puts the raising frame.Not reachable from the client yet.
Stack (PR 7 of 9, based on
traces/06-export):traces/01-ids-traceparenttraces/02-otlp-encodingtraces/03-span-handlestraces/04-transporttraces/05-pipelinetraces/06-exporttraces/07-span-limits← this PRtraces/08-before-span-sendtraces/09-client-wiring💚 How did you test it?
Unit tests in
posthog/test/tracing/test_limits.py, plus additions totest_span.py,test_otlp.py,test_pipeline.pyandtest_export.py.📝 Checklist
If releasing new changes
sampo addto generate a changeset file🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Implemented with Claude Code (Claude Opus 5) against the traces spec, one commit per slice so each PR reviews on its own. Rebased onto main and opened as a stacked draft in a later Claude Code session (Claude Fable 5.1).
🤖 Generated with Claude Code
https://claude.ai/code/session_012o7CtHLfcypjmXL7g9ZGRC