Skip to Content
Judgment Labs
Tracing

Attribute keys and mappers

The judgment.* span attribute keys Judgment reads, and how attribute mappers fill them at ingest.

Judgment reads the judgment.* span attributes below as structured fields. Any other key is stored as a custom attribute and stays searchable.

Columns:

  • Mapper target: whether an attribute mapper can write the key. Keys marked No are set by the SDKs or the ingest pipeline.
  • Set by SDK helper: the judgeval helper that writes the key, as python_name / typescriptName, checked against judgeval 1.3.3 (Python) and 1.3.4 (npm). None means no SDK helper writes it; set it with Tracer.set_attribute / Tracer.setAttribute, a raw OpenTelemetry SDK, or a mapper. wrap() here means the OpenAI wrapper.

The Agent keys and judgment.state_before / judgment.state_after are declared in both SDKs, but no helper in the current SDK releases writes them, even where a description says the SDK sets them automatically.

Span attribute keys

Core

KeyMapper targetSet by SDK helperDescription
judgment.inputYesobserve (automatic), set_input / setInputThe input a step receives.
judgment.outputYesobserve (automatic), set_output / setOutputThe output a step produces.
judgment.llm.tool_callsYesNoneStructured tool/function calls made during a step.
judgment.span_kindYesobserve(span_type=...) / observe(fn, { spanType }), set_span_kind / setSpanKind, wrap()The type of step (llm, tool, function, agent, ...). Judgment infers this automatically when usage or provider/model attributes are present, so you rarely need to set it yourself.
judgment.span_nameYesNoneThe name shown for this step in the trace. Falls back to the raw OpenTelemetry span name when unset.
judgment.agent_versionYesNoneThe version of the agent or prompt implementation used for this step. Powers the agent-version breakdown in monitoring.
judgment.tool.statusYesNoneA short outcome code for a tool step, such as ok, rejected or failed. Readable as tool_status in telemetry.spans, so charts and SQL can group tool calls by outcome without reading the output.
judgment.tool.error_codeYesNoneA short error code for a failed tool step, such as quota_exceeded. Readable as tool_error_code in telemetry.spans.

Identifiers

KeyMapper targetSet by SDK helperDescription
judgment.tool_call_idYesNoneThe conversation tool call this span belongs to. Multiple execution spans can share this ID. Defaults to gen_ai.tool.call.id, with Pydantic AI normalization described below.
judgment.response_idYesNoneThe model response this span belongs to. Defaults to gen_ai.response.id. Multiple spans can share this ID.
judgment.conversation_idYesNoneGroups the model calls that share it into a conversation. Defaults to gen_ai.conversation.id, which you set with set_propagating_attribute / setPropagatingAttribute. Map your conversation or thread ID here. See Conversation ID.
judgment.session_idYesset_session_id / setSessionIdTies multiple traces to one session, read from each trace's root span. Reuse it when traces continue the same conversation; use separate IDs for independent conversations. It does not group model calls into conversations; use judgment.conversation_id for that. See Session guidance.
judgment.customer_idYesset_customer_id / setCustomerIdWhich of your customers (tenant/account) a trace belongs to. Map here to filter and break down activity by customer.
judgment.customer_user_idYesset_customer_user_id / setCustomerUserIdWhich individual end user a trace belongs to. Map here to trace activity down to a single user.
judgment.project_idNoNoneThe Judgment project a trace belongs to. Judgment sets this from your API key/SDK configuration; it is not a mapper target.
judgment.test.run_idNotest_case / testCaseThe test run a trace belongs to. Read from the trace's root span, together with judgment.test.case_id, to attach the trace to its test case.
judgment.test.case_idNotest_case / testCaseThe test case within judgment.test.run_id that a trace answers. Read from the trace's root span; the first matching trace is used for the case.

MCP

MCP integration means instrument_mcp_server / instrumentMcpServer (automatic), checked against judgeval 1.9.3 (Python) and 1.8.4 (npm). Values depend on the call's available context and your capture settings.

KeyMapper targetSet by SDK helperDescription
judgment.mcp.server_nameYesMCP integrationNon-empty MCP server name. Required with judgment.mcp.tool_name to identify a tool execution.
judgment.mcp.tool_nameYesMCP integrationNon-empty executed tool name. Required with judgment.mcp.server_name.
judgment.mcp.client_nameYesMCP integrationClient application name, such as Cursor.
judgment.mcp.intentYesMCP integrationThe agent's stated reason for calling the tool.
judgment.mcp.outcomeYesMCP integrationsuccess, error, or cancelled. Without an explicit value, OpenTelemetry error status gives error; other statuses give success.
judgment.mcp.argument_keysYesMCP integrationBusiness argument names as a string array or JSON-encoded string array. Defaults to the top-level keys of judgment.input when it is an object.
judgment.mcp.error_typeYesMCP integration, mark_mcp_call_error / markMcpCallErrorTool error classification. Overrides error details from OpenTelemetry for MCP recording.
judgment.mcp.error_messageYesMCP integration, mark_mcp_call_error / markMcpCallErrorRedacted failure text. The integration writes it when error-message capture is on. Overrides error details from OpenTelemetry for MCP recording.
judgment.mcp.metadataYesNoneAdditional context as a JSON-encoded object.

See MCP tool executions for required attributes, automatic mappings, and a mapper example.

Agent

KeyMapper targetSet by SDK helperDescription
judgment.agent_idNoNoneIdentifies the agent instance that produced this span. Judgment SDK agent instrumentation sets this automatically; it powers agent grouping and is not a mapper target.
judgment.parent_agent_idNoNoneThe agent ID of the caller, for spans produced by a sub-agent. Used to reconstruct multi-agent call hierarchies.
judgment.agent_class_nameNoNoneThe class/type name of the agent implementation, set automatically by SDK agent instrumentation.
judgment.agent_instance_nameNoNoneThe specific instance/display name of the agent, set automatically by SDK agent instrumentation.
judgment.is_agent_entry_pointNoNoneMarks the span where an agent run begins, as opposed to an internal step of that run.

Usage & Cost

KeyMapper targetSet by SDK helperDescription
judgment.llm.providerYesrecordLLMMetadata (provider)The model provider, e.g. OpenAI or Anthropic. Map here so Judgment can price token usage accurately.
judgment.llm.modelYesrecordLLMMetadata (model), wrap()The exact model used, e.g. gpt-4o. Map here (together with provider) so cost is calculated correctly.
judgment.usage.non_cached_input_tokensYesrecordLLMMetadata (non_cached_input_tokens), wrap()Input tokens charged at the normal (uncached) rate. Map here to report input token cost.
judgment.usage.cache_creation_input_tokensYesrecordLLMMetadata (cache_creation_input_tokens)Input tokens written into the prompt cache. Map here to track prompt-cache write cost.
judgment.usage.reasoning_tokensYesNoneTokens a reasoning model spends "thinking". Map here to account for reasoning cost.
judgment.usage.cache_read_input_tokensYesrecordLLMMetadata (cache_read_input_tokens), wrap()Input tokens read from the prompt cache at the cheaper cached rate. Map here to track cache savings.
judgment.usage.output_tokensYesrecordLLMMetadata (output_tokens), wrap()Tokens the model generated in its response. Map here to report output token cost.
judgment.usage.non_cached_input_image_tokensYesNoneImage input tokens charged at the normal rate. Map here if your model bills image inputs separately.
judgment.usage.output_image_tokensYesNoneImage tokens the model generated. Map here if your model bills image outputs separately.
judgment.usage.total_cost_usdYesrecordLLMMetadata (total_cost_usd)A total cost you have already computed for this step, in USD. Map here to report cost directly instead of from tokens.

Observations

KeyMapper targetSet by SDK helperDescription
judgment.conversation.observationNoNoneOne model call as an observation, in JSON: what the model was given and produced, its usage, and its attribution. Judgment stores it as part of its conversation.
judgment.conversation.warningsNoNoneSet by ingest when a span's observation does not fit the observation format, listing what is wrong. Such a call is not stored.

State snapshots

KeyMapper targetSet by SDK helperDescription
judgment.state_beforeNoNoneA snapshot of the agent's state before this step ran, for evaluators/judges that score state transitions.
judgment.state_afterNoNoneA snapshot of the agent's state after this step ran, paired with judgment.state_before.

Reserved keys

Other judgment.* keys are reserved for the Judgment SDKs and the ingest pipeline. Don't set them yourself or target them with a mapper.

Resource attributes

Judgment reads these from the OpenTelemetry resource, not from span attributes.

Resource attributeSet byMeaning
service.nameTracer.init, default: the project nameService that emitted the span. Override with resource_attributes (Python) or resourceAttributes (TypeScript).
deployment.environment.nameTracer.init(environment=...)Environment of the trace. deployment.environment is read as a fallback. Empty shows as No environment.
telemetry.sdk.name, telemetry.sdk.versionTracer.initSDK identity.
judgment.project_idjudgeval Workers tracerProject ID stamped on the resource. Ingest routes by the X-Project-Id header, not this attribute.

Built-in normalization

At ingest, built-in mappers copy common third-party attributes onto judgment.* keys. They cover OTel GenAI semantic conventions, OpenInference, LangSmith, Vercel AI SDK 6 and 7, Logfire, Braintrust cost, and generic LLM provider attributes.

Incoming attributeJudgment key
gen_ai.response.model, then gen_ai.request.modeljudgment.llm.model
gen_ai.systemjudgment.llm.provider
gen_ai.usage.input_tokens, gen_ai.usage.output_tokensjudgment.usage.non_cached_input_tokens, judgment.usage.output_tokens
gen_ai.usage.cache_read_input_tokens, gen_ai.usage.cache_creation_input_tokensjudgment.usage.cache_read_input_tokens, judgment.usage.cache_creation_input_tokens
gen_ai.input.messages, gen_ai.prompt, gen_ai.tool.call.argumentsjudgment.input
gen_ai.output.messages, gen_ai.completion, gen_ai.tool.call.resultjudgment.output
gen_ai.conversation.idjudgment.conversation_id, and judgment.session_id when unset
gen_ai.tool.call.idjudgment.tool_call_id
gen_ai.response.idjudgment.response_id
gen_ai.tool.name presentjudgment.span_kind = tool
gen_ai.operation.name = chat or text_completionjudgment.span_kind = llm

Add a configured mapper only for keys this list does not cover.

For tool-execution spans emitted by the pydantic-ai instrumentation scope (gen_ai.operation.name = execute_tool), Judgment removes a final __digits suffix from the tool-call association: call_abc__2 becomes judgment.tool_call_id = call_abc. This associates Code Mode helper executions with their outer conversation tool call. Other instrumentation keeps its IDs unchanged. Original provider attributes and explicitly supplied Judgment IDs are preserved; configured mappers with Override enabled can replace the association.

These associations are populated on ingestion. Previously stored spans are not normalized retroactively.

Generated conversation observations prefer the span's normalized judgment.response_id, including configured mappings. When it is absent, conversation conversion can extract the observation's response_id from a recorded OpenAI Responses, Chat Completions, or Anthropic response body. Body IDs and explicitly supplied observation IDs are not copied back to span attributes.

MCP tool executions

If you already send tool-execution traces to Judgment, you can use them for MCP observability without adding Judgment's MCP instrumentation. Supply the required attributes directly or map your existing attribute names, then add any optional context you capture.

Required attributes

Send one completed server-side span per tool execution, with a positive duration and both attributes below. Root and nested executions are eligible; offline test traces don't appear in MCP observability.

Target attributeValueExample
judgment.mcp.server_nameNon-empty string identifying the MCP server.my-tools
judgment.mcp.tool_nameNon-empty string identifying the executed tool.get_menu

Map the server's execution span, not the client's request span or a model span describing a planned tool call. Mapping both the client and server spans records two calls for the same execution.

Automatic mappings

Judgment fills absent identity attributes on spans with mcp.method.name = tools/call and OpenTelemetry span kind SERVER. Here, SERVER refers to the OpenTelemetry span kind, not the judgment.span_kind attribute. These spans use the following mappings:

Incoming attributeTarget attribute
gen_ai.tool.namejudgment.mcp.tool_name
fastmcp.server.name, otherwise the resource's service.namejudgment.mcp.server_name

Source names must be non-empty strings, and existing target attributes stay unchanged, including empty values. If your instrumentation uses other attribute names or span kinds, use a custom mapper to supply the required attributes instead.

Optional attributes

Map the fields you already capture to add context to each call; missing optional fields don't prevent it from appearing. The MCP attribute catalog lists client identity, intent, outcome, argument names, metadata, and error fields. Use these shared attributes for the remaining context:

Target attributeValue and behavior
judgment.session_idConversation ID, reused across related tool executions. To group by mcp.session.id, map it explicitly; it isn't used as a fallback. Without judgment.session_id, calls remain ungrouped.
judgment.llm.modelThe calling model's name, if known.
judgment.customer_user_idYour end user's identifier.
judgment.input, judgment.outputCaptured arguments and result. JSON-encode structured values.

Mappers copy recorded values; they don't ask the agent for intent, model, or conversation IDs. Capture those values in your instrumentation before mapping them. Without Judgment's MCP instrumentation, capture client name and intent explicitly:

  • Client name: retain clientInfo.name from the MCP initialize request per session, then record it on every tools/call span as judgment.mcp.client_name or a custom attribute mapped to it. Initialization attributes aren't automatically copied to later spans.
  • Intent: MCP doesn't provide a standard intent field. Declare a tool argument such as intent, or capture the reason from application context, then record its value as judgment.mcp.intent or a custom attribute mapped to it. Judgment's MCP instrumentation can inject the argument and remove it before the tool handler runs; a custom implementation must handle its own argument.

Other call details come from the span and its resource:

  • Outcome: map an explicit outcome when a tool returns an error result without setting OpenTelemetry error status. Error text alone doesn't set the outcome.
  • Timing and trace links: use the original span.
  • Environment: uses the resource's deployment.environment.name, falling back to deployment.environment.

Map your existing attributes

Suppose each server-side tool-execution span already has these attributes:

{
  "app.mcp.server": "my-tools",
  "app.mcp.tool": "get_menu",
  "app.conversation_id": "conversation-123",
  "app.mcp.reason": "Find the restaurant's menu"
}

Rules copy exact span attribute keys, not paths inside a JSON payload. Put MCP-specific source keys only on server-side tool-execution spans. In Settings, select your project and open Mappers:

  1. Select New Mapper and enter a name, such as MCP tool calls.

  2. Under Mapping Rules, add these source and target pairs:

    Source KeyTarget Key
    app.mcp.serverjudgment.mcp.server_name
    app.mcp.tooljudgment.mcp.tool_name
    app.conversation_idjudgment.session_id
    app.mcp.reasonjudgment.mcp.intent
  3. Leave Enabled on. Leave Override off unless you want to replace an existing target value; MCP automatic mapping won't overwrite values set by your mapper. Turn off Remove Source if you want to keep the original attributes too.

  4. Select Create Mapper, then send another tool call. Open MCP under Monitoring and check the server and tool names.

Mapping changes apply to newly ingested spans, not traces already stored. See mapper settings for defaults or Trace your MCP server for SDK setup.

Mapper order

Ingest runs mappers in five layers. Each layer sees the output of the layers before it.

OrderLayerWhat runs
1Platform normalizationThe built-in mappers above.
2Organization mappersOrg-wide configured mappers.
3Project mappersMappers configured for the project.
4Platform enrichmentMCP automatic mapping, span kind inference, and LLM cost calculation.
5ConversationRecords model calls in the form the Conversation view reads.

Customer mappers run before span kind inference and cost calculation. A mapper that writes judgment.llm.provider, judgment.llm.model, and token counts therefore feeds cost calculation and llm span kind inference.

Span kind inference marks a span llm when it carries usage, provider, or model attributes for a billable GenAI operation. Rollup operations such as invoke_agent are excluded.

Mapper settings

SettingDefaultBehavior
EnabledOnDisabled mappers are skipped.
OverrideOffOff: writes the target only if it has no value yet. On: always writes the target.
Remove SourceOnDeletes the source key, only when the mapping was applied.
  • Targets must be keys with Mapper target = Yes.
  • Mappers apply at ingest. Spans stored before a mapper existed do not change.
  • Creating, editing, or deleting a mapper applies to spans ingested from then on.
  • Org-wide mappers can only be edited by a Judgment administrator. Creating, editing, or deleting project mappers needs the developer role, in the app and through MCP.

Manage mappers

In the app: open Settings, choose the project, then open Mappers.

MCP tools: list_mappers, get_mapper, create_mapper, update_mapper, delete_mapper. See MCP tools for inputs and roles.

On this page