Metadata lets you attach custom key-value pairs to your AgentMark traces. Use metadata to add context like user IDs, environment names, feature flags, request IDs, and customer tiers — then filter and search by those values in the Dashboard.Documentation Index
Fetch the complete documentation index at: https://docs.agentmark.co/llms.txt
Use this file to discover all available pages before exploring further.
Developers configure metadata in your application. See Tracing setup for setup instructions.
Setting metadata
There are two ways to attach metadata to traces in the AgentMark SDK: via thetelemetry.metadata object when formatting a prompt, and via the span() function’s metadata option when grouping traces.
Via telemetry metadata
Pass metadata when formatting a prompt. These key-value pairs are attached to the resulting span:Via the span function
Pass metadata when creating a trace group. All spans within the trace inherit this metadata:SpanOptions.metadata is typed as Record<string, string> — values must be strings. Convert numbers, booleans, and other types before passing.
Filtering by metadata
In the AgentMark Dashboard, metadata keys are auto-discovered from your trace data. You can filter traces by any metadata key that appears in your data. To filter by metadata:- Navigate to the Traces tab in the Dashboard.
- Open the filter dropdown.
- Look for entries prefixed with Metadata: followed by the key name (for example, “Metadata: userId”).
- Select the key you want to filter by.
- Choose an operator and enter a value.
- equals / notEquals — exact match / no match on the value
- contains / notContains — value includes / excludes the specified substring
- starts with — value begins with the specified string
- ends with — value ends with the specified string
- exists — the key is present, regardless of value
- does not exist — the key is not present on the trace
Metadata in the trace detail
When viewing an individual trace in the Dashboard, metadata appears in the attributes section. All key-value pairs you attached are displayed, making it easy to see the full context of a trace without switching to your application logs.How metadata is stored
AgentMark stores metadata as aMap(LowCardinality(String), String) column in ClickHouse. Keys are indexed for fast filtering and search. All values are stored as strings — if you need to attach non-string values, convert them first:
Best practices
Recommended metadata keys
userId— Per-user debugging and cost attribution. Example:"user-123"sessionId— Group related traces. Also available as a top-levelspan()option. Example:"sess-abc"environment— Distinguish staging from production when using a single app. Example:"production"version— Track which application version generated the trace. Example:"2.1.0"requestId— Correlate AgentMark traces with your application logs. Example:"req-xyz"feature— Identify which feature or flow triggered the trace. Example:"chat-v2"
Tips
- Use consistent key names across your application. If one service sends
userIdand another sendsuser_id, they appear as separate keys in the Dashboard. - Keep values short. Metadata is designed for identifiers and labels, not large payloads.
- Use metadata for anything you want to filter by later. If you find yourself searching your application logs for a value, it is a good candidate for metadata.
- Metadata keys are case-sensitive.
userIdanduseridare treated as different keys. - All values are stored as strings. Convert numbers, booleans, and other types before passing —
SpanOptions.metadataandtelemetry.metadataare both typedRecord<string, string>.
Next steps
Traces and logs
Understand trace details and span attributes
Sessions
Group related traces together
Filtering and search
Filter traces by metadata keys
Tracing setup
Set up tracing in your application
Have Questions?
We’re here to help! Choose the best way to reach us:
- Email us at hello@agentmark.co for support
- Schedule an Enterprise Demo to learn about our business solutions