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 withTracer.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
| Key | Mapper target | Set by SDK helper | Description |
|---|---|---|---|
judgment.input | Yes | observe (automatic), set_input / setInput | The input a step receives. |
judgment.output | Yes | observe (automatic), set_output / setOutput | The output a step produces. |
judgment.llm.tool_calls | Yes | None | Structured tool/function calls made during a step. |
judgment.span_kind | Yes | observe(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_name | Yes | None | The name shown for this step in the trace. Falls back to the raw OpenTelemetry span name when unset. |
judgment.agent_version | Yes | None | The version of the agent or prompt implementation used for this step. Powers the agent-version breakdown in monitoring. |
judgment.tool.status | Yes | None | A 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_code | Yes | None | A short error code for a failed tool step, such as quota_exceeded. Readable as tool_error_code in telemetry.spans. |
Identifiers
| Key | Mapper target | Set by SDK helper | Description |
|---|---|---|---|
judgment.tool_call_id | Yes | None | The 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_id | Yes | None | The model response this span belongs to. Defaults to gen_ai.response.id. Multiple spans can share this ID. |
judgment.conversation_id | Yes | None | Groups 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_id | Yes | set_session_id / setSessionId | Ties 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_id | Yes | set_customer_id / setCustomerId | Which of your customers (tenant/account) a trace belongs to. Map here to filter and break down activity by customer. |
judgment.customer_user_id | Yes | set_customer_user_id / setCustomerUserId | Which individual end user a trace belongs to. Map here to trace activity down to a single user. |
judgment.project_id | No | None | The Judgment project a trace belongs to. Judgment sets this from your API key/SDK configuration; it is not a mapper target. |
judgment.test.run_id | No | test_case / testCase | The 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_id | No | test_case / testCase | The 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.
| Key | Mapper target | Set by SDK helper | Description |
|---|---|---|---|
judgment.mcp.server_name | Yes | MCP integration | Non-empty MCP server name. Required with judgment.mcp.tool_name to identify a tool execution. |
judgment.mcp.tool_name | Yes | MCP integration | Non-empty executed tool name. Required with judgment.mcp.server_name. |
judgment.mcp.client_name | Yes | MCP integration | Client application name, such as Cursor. |
judgment.mcp.intent | Yes | MCP integration | The agent's stated reason for calling the tool. |
judgment.mcp.outcome | Yes | MCP integration | success, error, or cancelled. Without an explicit value, OpenTelemetry error status gives error; other statuses give success. |
judgment.mcp.argument_keys | Yes | MCP integration | Business 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_type | Yes | MCP integration, mark_mcp_call_error / markMcpCallError | Tool error classification. Overrides error details from OpenTelemetry for MCP recording. |
judgment.mcp.error_message | Yes | MCP integration, mark_mcp_call_error / markMcpCallError | Redacted failure text. The integration writes it when error-message capture is on. Overrides error details from OpenTelemetry for MCP recording. |
judgment.mcp.metadata | Yes | None | Additional context as a JSON-encoded object. |
See MCP tool executions for required attributes, automatic mappings, and a mapper example.
Agent
| Key | Mapper target | Set by SDK helper | Description |
|---|---|---|---|
judgment.agent_id | No | None | Identifies 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_id | No | None | The agent ID of the caller, for spans produced by a sub-agent. Used to reconstruct multi-agent call hierarchies. |
judgment.agent_class_name | No | None | The class/type name of the agent implementation, set automatically by SDK agent instrumentation. |
judgment.agent_instance_name | No | None | The specific instance/display name of the agent, set automatically by SDK agent instrumentation. |
judgment.is_agent_entry_point | No | None | Marks the span where an agent run begins, as opposed to an internal step of that run. |
Usage & Cost
| Key | Mapper target | Set by SDK helper | Description |
|---|---|---|---|
judgment.llm.provider | Yes | recordLLMMetadata (provider) | The model provider, e.g. OpenAI or Anthropic. Map here so Judgment can price token usage accurately. |
judgment.llm.model | Yes | recordLLMMetadata (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_tokens | Yes | recordLLMMetadata (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_tokens | Yes | recordLLMMetadata (cache_creation_input_tokens) | Input tokens written into the prompt cache. Map here to track prompt-cache write cost. |
judgment.usage.reasoning_tokens | Yes | None | Tokens a reasoning model spends "thinking". Map here to account for reasoning cost. |
judgment.usage.cache_read_input_tokens | Yes | recordLLMMetadata (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_tokens | Yes | recordLLMMetadata (output_tokens), wrap() | Tokens the model generated in its response. Map here to report output token cost. |
judgment.usage.non_cached_input_image_tokens | Yes | None | Image input tokens charged at the normal rate. Map here if your model bills image inputs separately. |
judgment.usage.output_image_tokens | Yes | None | Image tokens the model generated. Map here if your model bills image outputs separately. |
judgment.usage.total_cost_usd | Yes | recordLLMMetadata (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
| Key | Mapper target | Set by SDK helper | Description |
|---|---|---|---|
judgment.conversation.observation | No | None | One 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.warnings | No | None | Set 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
| Key | Mapper target | Set by SDK helper | Description |
|---|---|---|---|
judgment.state_before | No | None | A snapshot of the agent's state before this step ran, for evaluators/judges that score state transitions. |
judgment.state_after | No | None | A 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 attribute | Set by | Meaning |
|---|---|---|
service.name | Tracer.init, default: the project name | Service that emitted the span. Override with resource_attributes (Python) or resourceAttributes (TypeScript). |
deployment.environment.name | Tracer.init(environment=...) | Environment of the trace. deployment.environment is read as a fallback. Empty shows as No environment. |
telemetry.sdk.name, telemetry.sdk.version | Tracer.init | SDK identity. |
judgment.project_id | judgeval Workers tracer | Project 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 attribute | Judgment key |
|---|---|
gen_ai.response.model, then gen_ai.request.model | judgment.llm.model |
gen_ai.system | judgment.llm.provider |
gen_ai.usage.input_tokens, gen_ai.usage.output_tokens | judgment.usage.non_cached_input_tokens, judgment.usage.output_tokens |
gen_ai.usage.cache_read_input_tokens, gen_ai.usage.cache_creation_input_tokens | judgment.usage.cache_read_input_tokens, judgment.usage.cache_creation_input_tokens |
gen_ai.input.messages, gen_ai.prompt, gen_ai.tool.call.arguments | judgment.input |
gen_ai.output.messages, gen_ai.completion, gen_ai.tool.call.result | judgment.output |
gen_ai.conversation.id | judgment.conversation_id, and judgment.session_id when unset |
gen_ai.tool.call.id | judgment.tool_call_id |
gen_ai.response.id | judgment.response_id |
gen_ai.tool.name present | judgment.span_kind = tool |
gen_ai.operation.name = chat or text_completion | judgment.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 attribute | Value | Example |
|---|---|---|
judgment.mcp.server_name | Non-empty string identifying the MCP server. | my-tools |
judgment.mcp.tool_name | Non-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 attribute | Target attribute |
|---|---|
gen_ai.tool.name | judgment.mcp.tool_name |
fastmcp.server.name, otherwise the resource's service.name | judgment.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 attribute | Value and behavior |
|---|---|
judgment.session_id | Conversation 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.model | The calling model's name, if known. |
judgment.customer_user_id | Your end user's identifier. |
judgment.input, judgment.output | Captured 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.namefrom the MCPinitializerequest per session, then record it on everytools/callspan asjudgment.mcp.client_nameor 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 asjudgment.mcp.intentor 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 todeployment.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:
-
Select New Mapper and enter a name, such as
MCP tool calls. -
Under Mapping Rules, add these source and target pairs:
Source Key Target Key app.mcp.serverjudgment.mcp.server_nameapp.mcp.tooljudgment.mcp.tool_nameapp.conversation_idjudgment.session_idapp.mcp.reasonjudgment.mcp.intent -
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.
-
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.
| Order | Layer | What runs |
|---|---|---|
| 1 | Platform normalization | The built-in mappers above. |
| 2 | Organization mappers | Org-wide configured mappers. |
| 3 | Project mappers | Mappers configured for the project. |
| 4 | Platform enrichment | MCP automatic mapping, span kind inference, and LLM cost calculation. |
| 5 | Conversation | Records 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
| Setting | Default | Behavior |
|---|---|---|
| Enabled | On | Disabled mappers are skipped. |
| Override | Off | Off: writes the target only if it has no value yet. On: always writes the target. |
| Remove Source | On | Deletes 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.