Developers configure metadata in your application. See Development documentation 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 trace() 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 trace function
Pass metadata when creating a trace group. All spans within the trace inherit this metadata: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 — exact match on the value
- contains — value includes 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-leveltrace()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 (under 250 characters). 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.
Limits
AgentMark enforces the following limits on metadata:- Key names: Up to 64 characters, alphanumeric characters and underscores only
- Values: String values up to 500 characters
- Filters: Up to 10 metadata filters can be applied simultaneously in the dashboard
Next steps
Traces and logs
Understand trace details and span attributes
Sessions
Group related traces together
Filtering and search
Filter traces by metadata keys
Development 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