While the HoneyHive tracer automatically instruments all of the most common LLM application components, you might sometimes want to trace parts of your code beyond the automated coverage.

To do this, you can use HoneyHive’s manual tracing tools, which we’ll walk through in this guide.

Prerequisites

Please complete the Quickstart and make sure you have initialized your tracer using HoneyHiveTracer.init().

Overview

HoneyHive gives you full customizability over your traces.

You can trace any function in your code and see its inputs, outputs, errors, duration, etc. by decorating it with the @trace decorator:

Python
from honeyhive import trace

@trace()
def my_function(param1, param2):
    # Code here
    return result

Enriching Custom Spans

You can enrich your custom spans with additional properties to provide more context to your traces.

Please refer to the Enrich Traces documentation for more details.

Decorator-based Enrichments

You can also enrich the Configuration, Metadata, and Event Type fields on the decorator in addition to using the enrich_span function.

You can find the complete documentation for this in the Python SDK reference.

Here is an example of how to enrich the Configuration, Metadata, and Event Type fields on the decorator:

Python
from honeyhive import trace

@trace(
    config={
        "event_type": "my_event_type",
        "metadata": {"key": "value"},
    },
    metadata={
        "key": "value",
    },
    event_type="chain",
)
def my_function(param1, param2):
    # Code here
    return result

Best practices

  • Use descriptive function names, as they will be used as span names in your traces
  • Be mindful of sensitive data when tracing functions - avoid capturing passwords or other secrets

By strategically adding the @trace() decorator to key functions in your application, you can gain valuable insights into your custom code’s performance and behavior, complementing HoneyHive’s automatic instrumentation of LLM components.

Visualizing Your Traces

All traces can be visualized in the HoneyHive web app under Data Store in the session’s specified project. The session tree view shows you the execution flow of your trace, as well all the automatically captured and manually enriched attributes.

Next Steps

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