observability/_examples/otel-bridge/hono-multi/README.md
Distributed tracing example demonstrating Mastra's OtelBridge with multiple Hono services and Arize Phoenix.
This example demonstrates proper trace context propagation across three services:
service-one (port 3000)
↓ HTTP request
service-two (port 3001)
↓ HTTP request
service-mastra (port 4000) → Mastra agent with OtelBridge
All services use OpenTelemetry instrumentation, and traces are visualized in Arize Phoenix.
The OtelBridge enables Mastra to:
Without OtelBridge, Mastra would create disconnected traces with new trace IDs.
pnpm docker:up
Phoenix will be available at:
Create a .env file in the example root directory:
echo "OPENAI_API_KEY=your-key-here" > .env
From the example root:
pnpm install
The shared instrumentation package and the mastra service must be built before testing:
pnpm build
You need three terminal windows:
Terminal 1 - service-one:
cd observability/_examples/otel-bridge/hono-multi/service-one
pnpm start
Terminal 2 - service-two:
cd observability/_examples/otel-bridge/hono-multi/service-two
pnpm start
Terminal 3 - service-mastra:
cd observability/_examples/otel-bridge/hono-multi/service-mastra
pnpm start
Make a request to service-one:
curl http://localhost:3000/service-one
Expected response:
{
"message": "service-one → service-two → service-mastra (agent: Hello there friend!)"
}
All services use a shared instrumentation package that:
instrumentation/src/index.ts - Shared OTEL configurationservice-mastra/src/index.ts - Mastra + OtelBridge setupservice-mastra/src/agent.ts - Simple Mastra agentdocker-compose.yml - Arize Phoenix configurationThis indicates a problem with trace context propagation:
OPENAI_API_KEY is set in .env (example root directory)The integration tests verify distributed tracing across all three services.
pnpm docker:up.env in example root with your API keyOPENAI_API_KEY=your-key before running testspnpm build# If using .env file (recommended)
pnpm test
# Or with inline environment variable
OPENAI_API_KEY=your-key pnpm test
The tests will:
Stop Phoenix:
pnpm docker:down
Stop all services: Ctrl+C in each terminal
This example is based on treasur-inc/mastra-hono-tracing-example but updated to: