-
Notifications
You must be signed in to change notification settings - Fork 749
Add MLflow OTLP telemetry exporter, docs, and example #2112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
rapids-bot
merged 3 commits into
NVIDIA:develop
from
EnesYilmazcode:feat/mlflow-otlp-exporter
Jul 14, 2026
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
docs/source/run-workflows/observe/observe-workflow-with-mlflow.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| <!-- | ||
| SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| --> | ||
|
|
||
| # NVIDIA NeMo Agent Toolkit: Observing a Workflow with MLflow | ||
|
|
||
| This guide shows how to send **OpenTelemetry** traces from NeMo Agent Toolkit to an [MLflow](https://mlflow.org/docs/latest/tracing/) tracking server using the built-in `mlflow` exporter (`nvidia-nat[opentelemetry]`). MLflow 3.6+ ingests OTLP spans at `<tracking-server>/v1/traces` and routes them to an experiment via the `x-mlflow-experiment-id` header. For field reference and custom OTLP endpoints, see [Adding Telemetry Exporters](../../extend/custom-components/telemetry-exporters.md). | ||
|
|
||
| ## Step 1: Start an MLflow tracking server | ||
|
|
||
| Trace ingestion requires a tracking server backed by a database store. Install MLflow (`pip install "mlflow>=3.6"`) and start it: | ||
|
|
||
| ```bash | ||
| mlflow server --backend-store-uri sqlite:///mlflow.db --host 127.0.0.1 --port 5000 | ||
| ``` | ||
|
|
||
| The OTLP ingestion endpoint is then `http://localhost:5000/v1/traces`, and the MLflow UI is at `http://localhost:5000`. | ||
|
|
||
| ## Step 2: Configure the environment | ||
|
|
||
| ```bash | ||
| # Optional: overrides the defaults in config-mlflow.yml | ||
| export MLFLOW_OTLP_ENDPOINT="http://localhost:5000/v1/traces" | ||
| export MLFLOW_EXPERIMENT_ID="0" # the MLflow experiment ID to route traces to (default experiment is "0") | ||
| ``` | ||
|
|
||
| ## Step 3: Install the OpenTelemetry extra | ||
|
|
||
| ```bash | ||
| uv pip install -e ".[opentelemetry]" | ||
| # or, from PyPI: uv pip install "nvidia-nat[opentelemetry]" | ||
| ``` | ||
|
|
||
| ## Step 4: Run the simple calculator observability example | ||
|
|
||
| From the root of the NeMo Agent Toolkit repository: | ||
|
|
||
| ```bash | ||
| uv pip install -e examples/observability/simple_calculator_observability/ | ||
|
|
||
| nat run --config_file examples/observability/simple_calculator_observability/configs/config-mlflow.yml --input "What is 2 * 4?" | ||
| ``` | ||
|
|
||
| You should see a log line such as `Started exporter 'mlflow'`. Open the MLflow UI at `http://localhost:5000`, select the experiment matching `MLFLOW_EXPERIMENT_ID`, and view the workflow trace under the **Traces** tab. | ||
|
|
||
| ## Related configuration | ||
|
|
||
| - Example config: `examples/observability/simple_calculator_observability/configs/config-mlflow.yml` | ||
| - [Telemetry exporters reference](../../extend/custom-components/telemetry-exporters.md) |
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
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
68 changes: 68 additions & 0 deletions
68
examples/observability/simple_calculator_observability/configs/config-mlflow.yml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # | ||
| # MLflow: start a tracking server with a database backend store (required for trace ingestion), e.g. | ||
| # mlflow server --backend-store-uri sqlite:///mlflow.db --host 127.0.0.1 --port 5000 | ||
| # Traces are sent to ${MLFLOW_OTLP_ENDPOINT:-http://localhost:5000/v1/traces} and routed to experiment | ||
| # ${MLFLOW_EXPERIMENT_ID:-0}. See: https://mlflow.org/docs/latest/tracing/ | ||
|
|
||
| general: | ||
| telemetry: | ||
| logging: | ||
| console: | ||
| _type: console | ||
| level: WARN | ||
| file: | ||
| _type: file | ||
| path: ./.tmp/nat_simple_calculator.log | ||
| level: DEBUG | ||
| tracing: | ||
| mlflow: | ||
| _type: mlflow | ||
| endpoint: ${MLFLOW_OTLP_ENDPOINT:-http://localhost:5000/v1/traces} | ||
| experiment_id: "${MLFLOW_EXPERIMENT_ID:-0}" | ||
|
|
||
| front_end: | ||
| _type: fastapi | ||
| endpoints: | ||
| - path: /get_time | ||
| method: POST | ||
| description: Gets the current time | ||
| function_name: current_datetime | ||
| cors: | ||
| allow_origins: ['*'] | ||
|
|
||
| function_groups: | ||
| calculator: | ||
| _type: calculator | ||
|
|
||
| functions: | ||
| current_datetime: | ||
| _type: current_datetime | ||
|
|
||
| llms: | ||
| nim_llm: | ||
| _type: nim | ||
| model_name: nvidia/nemotron-3-nano-30b-a3b | ||
| temperature: 0.0 | ||
| max_tokens: 1024 | ||
|
|
||
|
|
||
| workflow: | ||
| _type: react_agent | ||
| tool_names: [calculator, current_datetime] | ||
| llm_name: nim_llm | ||
| verbose: true | ||
| parse_agent_response_max_retries: 3 |
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
29 changes: 29 additions & 0 deletions
29
packages/nvidia_nat_opentelemetry/tests/observability/test_mlflow_telemetry_exporter.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| """Unit tests for the MLflow OTLP telemetry exporter routing header and config defaults.""" | ||
|
|
||
| import nat.plugins.opentelemetry.register as otel_register | ||
|
|
||
|
|
||
| def test_mlflow_experiment_headers_match_mlflow_ingestion_contract(): | ||
| """The routing header key/value matches MLflow's OTLP ingestion (x-mlflow-experiment-id).""" | ||
| assert otel_register._mlflow_experiment_headers("42") == {"x-mlflow-experiment-id": "42"} | ||
|
|
||
|
|
||
| def test_mlflow_exporter_config_field_defaults(): | ||
| """Defaults target a local MLflow tracking server and the default experiment.""" | ||
| fields = otel_register.MLflowTelemetryExporter.model_fields | ||
| assert fields["endpoint"].default == "http://localhost:5000/v1/traces" | ||
| assert fields["experiment_id"].default == "0" |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.