Skip to content

fix(tracing): use monotonic export deadlines - #4063

Merged
seratch merged 1 commit into
openai:mainfrom
GautamSharma99:fix/tracing-monotonic-export-clock
Jul 31, 2026
Merged

seratch merged 1 commit into
openai:mainfrom
GautamSharma99:fix/tracing-monotonic-export-clock

Conversation

@GautamSharma99

Copy link
Copy Markdown
Contributor

Summary

This pull request makes BatchTraceProcessor scheduled exports use a monotonic clock consistently.

The processor represents schedule_delay as a relative deadline, but previously initialized, compared, and reset _next_export_time with time.time(). Wall time can move because of NTP corrections, host synchronization, timezone configuration, or manual changes:

  • a backward jump could keep queued telemetry buffered much longer than configured; and
  • a forward jump could trigger a premature export and reduce batching efficiency.

Scheduled-export initialization, comparison, and reset now use time.monotonic(), matching the existing monotonic shutdown deadlines. Queue-size triggers, the worker polling cadence, force flush, shutdown draining, retries, trace timestamps, and exporter payloads are unchanged.

No clock abstraction, public configuration, or alternate scheduling path is introduced.

Test plan

Replaced the previous scheduled-export test with a deterministic controlled-clock regression.

The previous test patched wall time and then called shutdown() before counting exported items. Because shutdown always performs a final drain, it could pass even when the scheduled-export branch never executed.

The replacement runs the worker decision loop without real sleeping, distinguishes no-argument scheduled exports from the final shutdown drain, and covers both directions:

  • wall time jumps forward while monotonic time remains before the deadline: no scheduled export occurs;
  • wall time jumps backward while monotonic time passes the deadline: one scheduled export occurs.

Both cases fail against the original wall-clock implementation.

Validation completed successfully:

  • Focused trace-processor suite: 56 passed
  • make format
  • make lint
  • make typecheck
  • make tests

Compatibility

This is an internal scheduling correction against the v0.19.1 behavior boundary. It changes no public signatures, configuration meaning, trace or span data, exporter payloads, persisted state, or backend protocol behavior.

Issue number

Closes #4057

Checks

  • I have added new tests, if relevant
  • I have run .agents/skills/code-change-verification/scripts/run.sh
  • I have confirmed all verification steps pass
  • If using Codex, I have run /review before submitting this PR

@seratch
seratch enabled auto-merge (squash) July 31, 2026 09:32
@seratch seratch added this to the 0.19.x milestone Jul 31, 2026
@seratch
seratch merged commit 2c6be96 into openai:main Jul 31, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Tracing] Scheduled exports use wall clock and are sensitive to clock changes

2 participants