fix(telemetry): raise span queue size and make telemetry shutdown idempotent#24121
Merged
Conversation
alexghr
approved these changes
Jun 16, 2026
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.
What
Addresses three operational issues seen on staging.
1. Spans dropped: queue full (
maxQueueSize=2048)BatchSpanProcessor dropping spans: queue full (maxQueueSize=2048). … 97007 total.OTEL_BSP_MAX_QUEUE_SIZE(otelBspMaxQueueSize) from 2048 → 16384 intelemetry-client/src/config.ts, and matched the fallback default inMonitoredBatchSpanProcessor.maxExportBatchSizedefault of 2048 (clamped tomaxQueueSize) so the larger queue actually drains.OTEL_BSP_MAX_QUEUE_SIZE).2. Metrics shutdown order / double shutdown
Root cause: the telemetry client is shared between the aztec-node and an embedded prover-node. Both stop paths call
telemetry.stop()(aztec-node/.../server.tsviatryStop, andprover-node.ts), so the meter/logger/trace providers are flushed-and-shut-down twice. The OTEL providers throw on the secondshutdown()and onforceFlush()after shutdown.Fix: made
OpenTelemetryClient.stop()idempotent by memoizing the shutdown promise, and madeflush()a no-op once shutdown has started. Repeatedstop()calls now resolve to the same single shutdown.3. prover-node → prover-broker ← prover-agent resilience
How many retries before giving up? They never give up — retries are indefinite.
All three broker connections are built with
createProvingJobBrokerClient(...)using theproverBrokerBackoffgenerator (prover-client/src/proving_broker/rpc.ts):start_node.ts(makeTracedFetch(proverBrokerBackoff, …))start_prover_agent.ts(makeTracedFetch(proverBrokerBackoff, …))proverBrokerBackoffis an infinite generator (backoff1, 1, 1, 2, 4, 4, 4, …seconds, capped at 4s), andretry()only gives up when the backoff generator is exhausted — which never happens here. TheECONNREFUSEDline is the per-attempt error logged byretry()while the broker pod is unavailable, not a terminal failure; once the broker pod comes back the next attempt succeeds. So these connections are already resilient to pods cycling — no code change was needed here, and this PR does not alter that behavior. (start_node.tsalready comments "Retry indefinitely until the epoch proving times out and the chain reorgs".)Tests
monitored_batch_span_processor.test.ts: warns when the queue fills; does not drop below the old 2048 default now that the default queue is larger.otel.test.ts(new):stop()shuts the providers down exactly once across multiple/concurrent calls;flush()is a no-op afterstop().Local
yarn build/test was not run — this workspace copy is not bootstrapped (the noir submodule isn't checked out and the full barretenberg→noir build chain is required). CI validates build + tests.Created by claudebox · group:
slackbot