Skip to main content
When your AI application spans multiple services (an API gateway calling an agent service, an orchestrator invoking a Lambda function), you need traces from all services to appear in a single session. Distributed tracing links events across process boundaries so you can debug end-to-end.

Choose Your Approach

HoneyHive supports two approaches. Pick the one that fits your needs.
Pass the session ID between services so all events land in the same session. Events are grouped together but appear as siblings, not as parent-child.Best for: Simple architectures, serverless (Lambda), cases where you only need events in the same session.
1

Get the session ID from Service A

from honeyhive import HoneyHiveTracer
import os

tracer = HoneyHiveTracer.init(
    api_key=os.getenv("HH_API_KEY"),
    project=os.getenv("HH_PROJECT"),
)

session_id = tracer.session_id
2

Pass the session ID to Service B

Include it in your HTTP request headers or body:
import requests

response = requests.post(
    "https://service-b.example.com/api/endpoint",
    json={"query": "hello", "session_id": session_id},
)
3

Initialize the tracer with the session ID in Service B

from honeyhive import HoneyHiveTracer
import os

# Extract session_id from request (Flask example)
session_id = request.json.get("session_id")

tracer = HoneyHiveTracer.init(
    api_key=os.getenv("HH_API_KEY"),
    project=os.getenv("HH_PROJECT"),
    session_id=session_id,  # Links to Service A's trace
)

Serverless Environments (AWS Lambda)

For Lambda functions, set disable_batch=True to flush spans before the function terminates. Use the session ID approach to link Lambda invocations to the calling service.
from honeyhive import HoneyHiveTracer
import os

def handler(event, context):
    session_id = event.get("session_id")

    tracer = HoneyHiveTracer.init(
        api_key=os.getenv("HH_API_KEY"),
        project=os.getenv("HH_PROJECT"),
        session_id=session_id,
        disable_batch=True,  # Required for Lambda
    )

    result = process_event(event)
    return {"statusCode": 200, "body": result}
Use the x86_64 runtime architecture and install the matching binary:
pip install \
    --platform manylinux2014_x86_64 \
    --target ./site-packages \
    --implementation cp \
    --python-version 3.11 \
    --only-binary=:all: \
    --upgrade "honeyhive>=1.0.0rc0"

Learn More