| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Tracing writes each span twice — once on start (no end_time) and once on end — so the start row is only ever overwritten by the end write moments later. Persisting it doubles span-ingest write volume and, on the SGP backend, costs a non-HOT UPDATE (tsvector/GIN recompute + index churn) plus a dead tuple per span. Skip the span-start upsert by default so each span is persisted once, on end (a single INSERT). Set AGENTEX_TRACING_SKIP_SPAN_START=0/false/no/off to restore the start write when in-flight or never-ending spans must be visible. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The end-only skip is governed by AGENTEX_TRACING_SKIP_SPAN_START (default ON) but was silent — an operator could only infer it from the absence of start-export metrics. Emit a one-time INFO at processor init stating whether span-start upsert is enabled or skipped, so the deployment's tracing mode is visible in logs. Off the hot path (once per construction). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…v-tunable The async span queue batched at 50 spans / 100ms linger. For high-volume span ingest that means many small upsert_batch PUTs — each a separate HTTP round trip and a separate INSERT statement on the backend. Raise the defaults to 200 spans / 250ms so batches fill before flushing, amortizing the per-request and per-statement overhead (still well under the backend's 1000-row cap). Also make batch_size resolvable from AGENTEX_SPAN_QUEUE_BATCH_SIZE, matching the existing env-override pattern for linger_ms / max_size / max_retries / concurrency (batch_size was the only queue knob not tunable without an SDK release). Resolution order: explicit arg > AGENTEX_SPAN_QUEUE_BATCH_SIZE env > default. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Reverts the span_queue.py batch_size/linger_ms changes (and their tests) so this PR stays scoped to end-only ingest (sgp_tracing_processor.py). The batching throughput tuning ships separately in #397. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…gh-volume ingest Coalesce more spans into each upsert_batch HTTP call to amortize the per-request round trip and the per-statement parse/plan + index-maintenance overhead that dominates at high span volume. batch_size is now env-tunable via AGENTEX_SPAN_QUEUE_BATCH_SIZE (default 200), and linger rises to 250ms so batches fill rather than shipping near-size-1. Split out of #394 (end-only ingest) so each change ships and is reviewed independently. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
| Back | FazBrowse Home | New Git URL |
Summary
Move the "end-only span ingest" optimization (originally done on the EGP backend in scaleapi#145863) into the SDK producer, so the wasted span-start write is never sent on the wire in the first place.
Tracing writes each span twice — once on start (no end_time) and once on end. The start row is only ever overwritten by the end write moments later, so persisting it:
This change makes SGPSyncTracingProcessor / SGPAsyncTracingProcessor skip the span-start upsert, so each span is persisted once, on end (a single INSERT server-side). Doing it in the SDK also eliminates the wasted start HTTP call entirely — not just the DB write.
Behavior
Parsing mirrors the SDK's existing AGENTEX_TRACING_METRICS convention (raw not in ("0","false","no","off")).
Trade-offs
Both are reversible per-deployment via the env var.
Tests
Note
Branched off v0.11.8 per request; rebased onto main (0.12.0) for a clean PR — the processor file and its tests are byte-identical between the tag and main, so the code change is exactly the same.
🤖 Generated with Claude Code
Greptile Summary
This PR moves the "end-only span ingest" optimisation from the EGP backend into the SDK producer itself, eliminating the wasted span-start HTTP call entirely. SGPSyncTracingProcessor.on_span_start and SGPAsyncTracingProcessor.on_spans_start become no-ops by default, controlled by a new AGENTEX_TRACING_SKIP_SPAN_START env var that mirrors the existing AGENTEX_TRACING_METRICS convention.
Confidence Score: 5/5
Safe to merge. The change makes span-start writes a no-op by default with a clearly documented opt-out; on_span_end is untouched and carries the full span payload, so no trace data is lost for normally-completing spans.
The logic is straightforward: a single env-var gate in each start handler, all end-path code unchanged. The new TestSkipSpanStartEnv class directly exercises every falsy/truthy value, and the four updated existing tests correctly re-enable the start path via monkeypatch.setenv. No span data is dropped for spans that complete normally.
No files require special attention.
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Span Start Event] --> B{_skip_span_start_enabled?\nenv: AGENTEX_TRACING_SKIP_SPAN_START} B -- "True (default)" --> C[No-op: return immediately\nNo HTTP call sent] B -- "False (opt-in)" --> D[Build SGPSpan\n_build_sgp_span] D --> E[flush / upsert_batch\nSGP Backend HTTP write] F[Span End Event] --> G[Build SGPSpan + end_time\n_build_sgp_span] G --> H[flush / upsert_batch\nSGP Backend HTTP write\nSingle INSERT on backend]Reviews (4): Last reviewed commit: "refactor(tracing): split span batch/ling..." | Re-trigger Greptile