Support session ID set by OpenTelemetry semantic convention#19211
Support session ID set by OpenTelemetry semantic convention#19211serena-ruan merged 2 commits intomlflow:masterfrom
Conversation
Signed-off-by: Serena Ruan <serena.rxy@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR adds support for translating OpenTelemetry semantic convention session IDs (session.id) to MLflow's session IDs, enabling proper rendering in the MLflow UI. The implementation extracts session IDs from span attributes and stores them in trace metadata, with logic to preserve existing session IDs.
Key Changes
- Session ID extraction from OTel span attributes during span logging
- Session ID storage in trace metadata with preservation of existing values
- Test coverage for session ID handling including creation, preservation, and absence scenarios
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| mlflow/store/tracking/sqlalchemy_store.py | Adds logic to extract session.id from span attributes and store it in trace metadata, only setting a new session ID if one doesn't already exist |
| tests/store/tracking/test_sqlalchemy_store.py | Adds comprehensive test cases for session ID handling including storage from attributes, preservation of existing session IDs, and behavior when no session ID is present |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Documentation preview for e2dc19d is available at: More info
|
BenWilson2
left a comment
There was a problem hiding this comment.
Looks good. I don't think we need to have guards for span processing with broken session configurations within a root span (like Copilot recommended)
| aggregated_token_usage = update_token_usage( | ||
| aggregated_token_usage, span_token_usage | ||
| ) | ||
| # session id used by OTel semantic conventions: https://opentelemetry.io/docs/specs/semconv/registry/attributes/session/#session-id |
There was a problem hiding this comment.
Shall we define this key in mlflow/tracing/constant.py?
There was a problem hiding this comment.
We can, but I think that file is more for constants reused in mlflow tracing concepts, and this is only used here once
🛠 DevTools 🛠
Install mlflow from this PR
For Databricks, use the following command:
Related Issues/PRs
#xxxWhat changes are proposed in this pull request?
Support translation OTel session ID to mlflow's session ID so that it can render on UI correctly:



How is this PR tested?
Does this PR require documentation update?
Release Notes
Is this a user-facing change?
What component(s), interfaces, languages, and integrations does this PR affect?
Components
area/tracking: Tracking Service, tracking client APIs, autologgingarea/models: MLmodel format, model serialization/deserialization, flavorsarea/model-registry: Model Registry service, APIs, and the fluent client calls for Model Registryarea/scoring: MLflow Model server, model deployment tools, Spark UDFsarea/evaluation: MLflow model evaluation features, evaluation metrics, and evaluation workflowsarea/gateway: MLflow AI Gateway client APIs, server, and third-party integrationsarea/prompts: MLflow prompt engineering features, prompt templates, and prompt managementarea/tracing: MLflow Tracing features, tracing APIs, and LLM tracing functionalityarea/projects: MLproject format, project running backendsarea/uiux: Front-end, user experience, plotting, JavaScript, JavaScript dev serverarea/build: Build and test infrastructure for MLflowarea/docs: MLflow documentation pagesHow should the PR be classified in the release notes? Choose one:
rn/none- No description will be included. The PR will be mentioned only by the PR number in the "Small Bugfixes and Documentation Updates" sectionrn/breaking-change- The PR will be mentioned in the "Breaking Changes" sectionrn/feature- A new user-facing feature worth mentioning in the release notesrn/bug-fix- A user-facing bug fix worth mentioning in the release notesrn/documentation- A user-facing documentation change worth mentioning in the release notesShould this PR be included in the next patch release?
Yesshould be selected for bug fixes, documentation updates, and other small changes.Noshould be selected for new features and larger changes. If you're unsure about the release classification of this PR, leave this unchecked to let the maintainers decide.What is a minor/patch release?
Bug fixes, doc updates and new features usually go into minor releases.
Bug fixes and doc updates usually go into patch releases.