GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||
GeezerVison is showing github.com — feat(tracing): skip Agentex span-start write by default (end-only ingest) by NiteshDhanpal · Pull Request #438 · scaleapi/scale-agentex-python Conversation
|
| Filename | Overview |
|---|---|
| src/agentex/lib/core/tracing/processors/agentex_tracing_processor.py | Adds _skip_span_start_enabled(), _create_kwargs(), and the init-time flag capture; both processors correctly branch on self._skip_span_start to skip start writes and substitute a single end-of-span INSERT. Logic is sound and consistent across sync/async. |
| tests/lib/core/tracing/processors/test_agentex_tracing_processor.py | Adds TestAgentexSyncSkipSpanStart and TestAgentexAsyncSkipSpanStart with 3 cases each (default, skip-disabled, mid-span toggle regression). New _make_span() helper builds a realistic Span fixture. Async tests rely on project-wide asyncio_mode=auto in keeping with existing test patterns. |
%%{init: {'theme': 'neutral'}}%%
flowchart TD
INIT["__init__(config)\nself._skip_span_start = _skip_span_start_enabled()"]
INIT --> START["on_span_start(span)"]
INIT --> END["on_span_end(span)"]
START --> C1{self._skip_span_start?}
C1 -- "True (default)" --> NOOP["return (no-op)"]
C1 -- "False" --> CREATE_START["spans.create(**_create_kwargs(span))"]
END --> C2{self._skip_span_start?}
C2 -- "True (default)" --> CREATE_END["spans.create(**_create_kwargs(span))\n(single INSERT — complete span)"]
C2 -- "False" --> UPDATE_END["spans.update(span.id, **span.model_dump(...))"]
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
INIT["__init__(config)\nself._skip_span_start = _skip_span_start_enabled()"]
INIT --> START["on_span_start(span)"]
INIT --> END["on_span_end(span)"]
START --> C1{self._skip_span_start?}
C1 -- "True (default)" --> NOOP["return (no-op)"]
C1 -- "False" --> CREATE_START["spans.create(**_create_kwargs(span))"]
END --> C2{self._skip_span_start?}
C2 -- "True (default)" --> CREATE_END["spans.create(**_create_kwargs(span))\n(single INSERT — complete span)"]
C2 -- "False" --> UPDATE_END["spans.update(span.id, **span.model_dump(...))"]
Reviews (3): Last reviewed commit: "fix(tracing): capture skip-span-start de..." | Re-trigger Greptile
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
…est) The Agentex tracing processor wrote every span twice — a `spans.create` on start and a `spans.update` on end — doubling per-span HTTP/DB writes against the Agentex control plane. Under load this is what timed out span-start activities and pressured the Agentex Postgres connection pool. Default to end-only ingest: skip the start write and persist each span once, as a single `spans.create` on end (a bare `spans.update` would 404 since the row was never created). Gated by a dedicated, default-ON env var `AGENTEX_TRACING_SKIP_AGENTEX_SPAN_START`, independent of the SGP/EGP processor's `AGENTEX_TRACING_SKIP_SPAN_START` so the EGP span path is unchanged. Set to 0/false/no/off to restore start writes. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Per Greptile review: re-reading the flag in both on_span_start and on_span_end risks splitting a span's lifecycle if the env toggles between them — start-skip + end-update lands on a non-existent row (404). Unlike the SGP processor (idempotent upsert_batch on both halves), the Agentex backend's create-on-start / update-on-end asymmetry makes this a real failure. Capture _skip_span_start once in __init__ for both sync and async processors and reference it in both handlers, so the decision is always consistent. Adds a regression test (toggle env mid-span -> still end-only INSERT). Co-Authored-By: Claude Opus 4.8 <[email protected]>
e22b496 to
8474cc0
Compare
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.