PRODUCTION SCENARIO
A Generative AI Engineer has LangChain autologging enabled, so retriever and LLM spans appear in MLflow traces. A custom Python function that deduplicates and reorders chunks between those calls is invisible in the trace, and it is the suspected cause of bad answers.
How should the engineer make that step visible in the same trace?
Answering here is anonymous. Nothing is saved unless you sign in.
Show answer and explanation
Answer: Decorate the custom function with @mlflow.trace and keep autologging
Automatic tracing captures supported library calls and composes with the @mlflow.trace decorator, so custom logic between LLM calls joins the same unified trace. Autologging does not overwrite manual spans, so disabling it removes the retriever and LLM spans rather than adding the missing one. A span deliberately opened as its own root produces a second trace beside the first, which is the fragmentation to avoid. An artifact records the output without placing it in the call sequence.