> ## Documentation Index
> Fetch the complete documentation index at: https://docs.honeyhive.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Overview

> How to enrich your traces and spans with additional context

## Prerequisites

Please complete the [Quickstart](/introduction/quickstart) and make sure you set up custom tracing using the `@trace` Python decorator or `traceFunction` JavaScript method. Here's the guide for [custom spans](/tracing/custom-spans) to set those up.

## Session & Span Level Enrichments

Custom Spans allow you to trace any function in your code and see its inputs, outputs, errors, duration, etc. However, for certain use cases, you might want to add *additional* context into your trace such as feedback or metrics. We call this context injection **enrichments**.

To log additional context to your root `session`, you can use

* [enrich\_session() in Python](/sdk-reference/python-tracer-ref#enrich-session)
* [enrichSession() in JavaScript](/sdk-reference/typescript-tracer-ref#enrichsession)

To log additional context to a specific child `event` span, you can use

* [enrich\_span() in Python](/sdk-reference/python-tracer-ref#enrich-span)
* [enrichSpan() in JavaScript](/sdk-reference/typescript-tracer-ref#enrichspan)

These are useful if you want to add context *within* a traced function during runtime.

## Enrichment Schema

Enrichments are key-value pairs that you can add to your traces to provide additional context. You can add the following enrichment attributes to your traces:

| Attribute Key     | Type   | Description                                                                     | `enrich_session` | `enrich_span` |
| ----------------- | ------ | ------------------------------------------------------------------------------- | ---------------- | ------------- |
| `config`          | Object | Configuration details                                                           | ✓                | ✓             |
| `feedback`        | Object | User feedback or annotations                                                    | ✓                | ✓             |
| `metrics`         | Object | Metrics, scores, or evaluations                                                 | ✓                | ✓             |
| `metadata`        | Object | Catch-all for arbitrary metadata or JSON                                        | ✓                | ✓             |
| `outputs`         | Object | Output data from the function or event                                          | ✓                | ✓             |
| `user_properties` | Object | User-specific attributes                                                        | ✓                | ✗             |
| `event_type`      | String | Type of event (chain, model, tool)                                              | ✗                | ✓             |
| `inputs`          | Object | Input data for the function or event                                            | ✗                | ✓             |
| `error`           | String | Error information if applicable                                                 | ✗                | ✓             |
| `event_id`        | String | Custom event ID to override the auto-generated span ID. Must be a valid UUIDv4. | ✗                | ✓             |

<Note>**Note:** For the Object type enrichments (config, metadata, etc.), enrichments are always *additive* for unique keys. This means that enriching the same field twice with different keys will result in both keys being included in the trace. However, if you enrich the same field with the same key twice, the value will be overwritten.</Note>

## Examples

Here are some ways in which you can enrich your traces:

<CardGroup cols={2}>
  <Card title="Metrics & Evaluations" icon="chart-line" href="/tracing/client-side-evals">
    Add metrics, scores, or evaluations to your traces
  </Card>

  <Card title="User Feedback" icon="comment" href="/tracing/setting-user-feedback">
    Enrich traces with feedback or additional annotations
  </Card>

  <Card title="Configuration Details" icon="gear" href="/tracing/setting-config">
    Include config details, model hyperparameters, or prompt templates
  </Card>

  <Card title="User Properties" icon="user" href="/tracing/setting-user-properties">
    Add user properties or tracking IDs to your traces
  </Card>

  <Card title="Custom Metadata" icon="tags" href="/tracing/setting-metadata">
    Enrich traces with arbitrary metadata or JSON
  </Card>
</CardGroup>
