Skip to main content
Problem: You have a multi-service AI application and need to trace requests as they flow across service boundaries to understand performance, errors, and dependencies. Solution: Use HoneyHive’s distributed tracing with context propagation to create unified traces across multiple services.

How Context Propagation Works

When a request crosses a service boundary, the calling service injects its trace context into outgoing HTTP headers. The receiving service extracts that context and attaches all of its spans to the same trace. The result is a single unified session in HoneyHive, even though the work happened in different processes. HoneyHive provides two helpers that handle the plumbing:

What You’ll Build

A distributed AI agent architecture with a client orchestrator calling both a remote and a local agent:

Prerequisites

Installation

Step 1: Set Environment Variables

Step 2: Create the Agent Server (Remote Service)

The agent server runs a Google ADK research agent. The key line is with_distributed_trace_context(), which extracts the incoming trace context from HTTP headers and attaches it to all spans created inside the block. Create agent_server.py:
The critical pattern on the server side:
with_distributed_trace_context() handles extracting the trace ID, session ID, and project from the incoming headers, attaching context so all spans link to the caller’s trace, and cleaning up when the block exits (even on exceptions).

Step 3: Create the Client Application

The client orchestrates both remote and local agent calls. For the remote call, it uses inject_context_into_carrier() to propagate trace context via HTTP headers. Create client_app.py:
The critical pattern on the client side:
inject_context_into_carrier() adds the W3C traceparent header plus HoneyHive baggage (session ID, project, source) to your outgoing HTTP headers.

Step 4: Run and Test

1

Start the Agent Server

You should see:
2

Run the Client Application (in a separate terminal)

You should see research and analysis results for each query.
3

View in HoneyHive

Go to https://app.us.honeyhive.ai, open the distributed-tracing-tutorial project, and click Traces. You’ll see a unified trace hierarchy:
Spans from agent-server appear as children of client-app spans, even though they ran in different processes.

Troubleshooting

Next Steps

Distributed Tracing Reference

Session ID approach and serverless patterns (Lambda)

Tracing Introduction

How sessions, events, and context propagation work