Skip to content

Make autolog resilient, add UC pre-flight and per-node span descriptions - #33

Open
adamgurary wants to merge 1 commit into
mlflow:mainfrom
adamgurary:tracing-skill-resilience-uc-descriptions
Open

Make autolog resilient, add UC pre-flight and per-node span descriptions#33
adamgurary wants to merge 1 commit into
mlflow:mainfrom
adamgurary:tracing-skill-resilience-uc-descriptions

Conversation

@adamgurary

Copy link
Copy Markdown
Contributor

Summary

Three additive improvements to instrumenting-with-mlflow-tracing/references/python.md, each fixing a concrete failure mode observed when a developer instruments a LangGraph agent for the first time.

1. Resilient autolog setup (Method 1)

The existing autolog block calls each flavor sequentially with no error handling. If one flavor's version-compatibility check raises (for example, mlflow.langchain.autolog() raises ModuleNotFoundError: No module named 'langchain' when only langchain-core is installed), every subsequent autolog call in the same block is skipped. The fix wraps each call in its own try/except so a single missing package does not disable the rest.

The section also adds a note clarifying that LangGraph is traced via mlflow.langchain.autolog() (there is no mlflow.langgraph.autolog()), and that it requires only langchain-core, not the full langchain package.

2. Databricks UC trace-storage pre-flight note

On Databricks, the default experiment backend caps at 100,000 traces per experiment. Nothing in the Quick Start section flags this limit. The fix adds a short callout pointing readers to references/databricks.md for the set_experiment(trace_location=UnityCatalog(...)) one-liner before they hit the cap in production.

3. Per-node span description pattern (new subsection under "Combining AutoLogging with Custom Tracing")

When mlflow.langchain.autolog() traces a LangGraph graph, each node span is named after the node function. The trace shows inputs and outputs but nothing that explains what the node does. A reader has to open the source file to understand the trace. The fix adds a pattern for writing the node's docstring to span.set_attribute("description", fn.__doc__), which surfaces in the span's Attributes tab without any changes to MLflow core.

Testing

Verified locally that:

  • The resilient autolog loop runs without syntax errors in a Python 3.11 environment.
  • mlflow.get_current_active_span() is a valid public API in mlflow>=3.8.0.
  • span.set_attribute(key, value) is a valid public API on LiveSpan.

No existing skill tests are affected (this file contains only documentation and code examples).

- Replace the flat autolog block with a per-flavor try/except loop so a
  missing dependency does not disable other autolog calls.
- Add a note that LangGraph uses mlflow.langchain.autolog() (no separate
  mlflow.langgraph.autolog()) and needs only langchain-core, not langchain.
- Add a pre-flight note that the default experiment backend caps at 100k
  traces on Databricks and point to references/databricks.md for the
  UC trace-location one-liner.
- Add a pattern for setting span.set_attribute("description", <docstring>)
  on LangGraph node spans so traces are readable without opening the code.

Co-authored-by: Isaac
Signed-off-by: Adam Gurary <guraryadam@gmail.com>
@adamgurary
adamgurary force-pushed the tracing-skill-resilience-uc-descriptions branch from d191509 to f97aaa2 Compare July 31, 2026 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant