Tags and Metadata
Learn how to set metadata on your traces
Introduction
Metadata is a key-value pair that you can add to your traces to provide additional context.
It is provided as a catch-all for arbitrary information or JSON you might want to add to your traces.
The following steps will show you how to set metadata on the entire session.
Prerequisites
You have already set tracing for your code as described in our quickstart guide.
Setting
You can set on both the trace level or the span level. If the applies to the entire trace, then set it on the trace level. If the applies to a specific span, then set it on the span level. For more details, refer to the enrich traces documentation.
In Python, you can use the enrich_session
function to set on the trace level.
To pass to HoneyHive, pass it to the param in the enrich_session
function. This function is used to enrich the session with additional information. Remember that enrich_session
will update, not overwrite, the existing object on the trace.
Read more about the enrich_session
function in the Python SDK reference.
Here’s an example of how to set on the trace level in Python:
Concepts
What is Metadata?
Metadata is anything that doesn’t describe the quality of inputs / outputs or the system’s behavior. This metadata can be used to filter and group traces in HoneyHive.
Examples include
- Online Experiment IDs
- Offline Experiment IDs
- Token Usage
- Cost
- System-level information
Reserved Fields
The following metadata fields are reserved and treated specially by HoneyHive:
- Token Usage
total_tokens
: Total tokens used in the session/eventcompletion_tokens
: Completion tokens used in the session/eventprompt_tokens
: Prompt tokens used in the session/event
- Cost
cost
: Cost of the session/event
- Event Counts
num_events
: Number of events in the sessionnum_model_events
: Number of model events in the sessionhas_feedback
: Whether the session has feedback on any of the events
- Evaluation Run ID
run_id
: Evaluation run ID used to group sessions for an evaluation run
Learn more
SDK Reference
Read more about the enrich_session
function in the Python SDK reference.