Skip to content

src/telemetry

Copy each Mastra chat turn’s request/response onto its OTel root span so Databricks-managed MLflow can display them.

Why this exists: MLflow’s UC <target>_trace_unified view picks the one span whose parent_span_id is empty and reads request/response from mlflow.spanInputs / mlflow.spanOutputs (or the gen_ai.* equivalents) on THAT span only. Mastra records the turn on its invoke_agent child under mastra.agent_run.input / .output, keys the view never reads, so chat traces arrive with both columns null even when the spans themselves look healthy.

AppKit’s HTTP instrumentation records the server span in OTel RPC metadata, which remains available even when Express makes a middleware-layer child active. When instrumentation is unavailable, this module creates one request-lifetime server span and runs Mastra under it.

Re-exports APPKIT_AGENT_TRACE_ROOT_ATTR


Re-exports MLFLOW_AGENT_TAG


Re-exports MLFLOW_AGENT_TAG_ATTR


Re-exports MLFLOW_GENIE_TAG


Re-exports MLFLOW_GENIE_TAG_ATTR


Re-exports MLFLOW_LOCAL_TAG


Re-exports MLFLOW_LOCAL_TAG_ATTR


Re-exports MLFLOW_OBO_AUTH_TAG


Re-exports MLFLOW_OBO_AUTH_TAG_ATTR


Re-exports MLFLOW_SP_AUTH_TAG


Re-exports MLFLOW_SP_AUTH_TAG_ATTR


Re-exports MLFLOW_TRACE_TAG_PREFIX