Tracer provider defaults to OTEL default provider for evals#127
Merged
David Elner (delner) merged 3 commits intomainfrom Mar 22, 2026
Merged
Tracer provider defaults to OTEL default provider for evals#127David Elner (delner) merged 3 commits intomainfrom
David Elner (delner) merged 3 commits intomainfrom
Conversation
| # @param errors [Queue] Thread-safe error collection queue | ||
| def run_eval_case(case_context, errors) | ||
| # Each eval case starts its own trace — detach from any ambient span context | ||
| eval_span = tracer.start_root_span("eval") |
Contributor
There was a problem hiding this comment.
i feel like this would be more readable if case_context was shorter
Collaborator
Author
There was a problem hiding this comment.
Sure. Practically speaking we could abbreviate the variable name to case because its semantically the same.
Collaborator
Author
There was a problem hiding this comment.
Ahh whoops, forgot case is reserved. So it'd have to be kase (Ruby convention)
Matt Perpick (clutchski)
approved these changes
Mar 22, 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.
Trace scorers query spans via BTQL after the task runs. For spans to be queryable, they must first be flushed from the OpenTelemetry tracer provider.
Previously,
force_flushwas called oneval_context.tracer_provider, which wasnilwhen users didn't explicitly passtracer_provider:toEval.run(the common case). The safe navigation operator (&.) silently skipped the flush. In practice, the OTLP exporter's background thread usually shipped spans in time, but this was a race condition — not a guarantee.Additionally, the runner maintained its own fallback (
eval_context.tracer_provider || OpenTelemetry.tracer_provider) to create spans, but this resolved provider was never persisted, so downstream code couldn't rely on it.Changes
Context::Factory#buildnow defaultstracer_providertoOpenTelemetry.tracer_providerwhen none is provided, so the context always carries a resolved provider.force_flushcall uses arespond_to?guard instead of&., since the global provider may be aProxyTracerProviderthat doesn't implementforce_flush(e.g. ifBraintrust.initwas never called).initializesince the context now guarantees a provider.Impact
Users running trace scorers without passing
tracer_provider:toEval.runshould no longer need that workaround. The flush will execute against the correct provider automatically.