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.

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:

  1. Token Usage
    • total_tokens: Total tokens used in the session/event
    • completion_tokens: Completion tokens used in the session/event
    • prompt_tokens: Prompt tokens used in the session/event
  2. Cost
    • cost: Cost of the session/event
  3. Event Counts
    • num_events: Number of events in the session
    • num_model_events: Number of model events in the session
    • has_feedback: Whether the session has feedback on any of the events
  4. 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.