PR -> feat: bind MLflow active run in worker threads for OpenTrace integration#11
Open
mjehanzaib999 wants to merge 1 commit intoAgentOpt:mainfrom
Open
Conversation
E1: Add bind_active_run() context manager to mlflow_client.py —
re-attaches MLflow active-run state in worker threads so OpenTrace
unified telemetry spans land under the correct parent run.
E2: Wrap _run_job() call in runner.py with bind_active_run(mlflow_ctx)
for max_workers > 1 scenarios.
E3: Update notebook 03 docs to reflect OpenTrace unified telemetry
integration path.
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.
Summary
This PR adds MLflow active-run context propagation support for Trace-Bench worker threads, enabling seamless integration with the OpenTrace unified telemetry pipeline introduced in microsoft/Trace PR #64 (Milestone 2).
Problem
When Trace-Bench runs evaluation jobs with
max_workers > 1, each worker thread loses access to MLflow's thread-local active run state. This causes telemetry spans emitted by OpenTrace's unifiedTelemetrySessionto either:Solution
E1 —
bind_active_run()context manager (trace_bench/integrations/mlflow_client.py)E2 — Runner integration (
trace_bench/runner.py)_run_job()invocations withbind_active_run(mlflow_ctx)when workers > 1E3 — Notebook documentation (
notebooks/03_ui_launch_monitor.ipynb)How it works
Relationship to other PRs
This PR depends on the unified
TelemetrySessionAPI from Trace #64 but can be merged independently —bind_active_run()is a no-op when the telemetry session is not active.Test plan
bind_active_run()correctly propagates run context in threaded executionmax_workers > 1and MLflow enabledmax_workers = 1(no regression)