Setup
Install the Braintrust Go SDK alongside the Eino packages, then configure your API keys.1
Install packages
2
Set environment variables
.env
Auto-instrumentation
To trace Eino without wiring Braintrust into your application code, build your app with Orchestrion, a compile-time tool that appends Braintrust’s handler to yourcallbacks.AppendGlobalHandlers call. Once the handler is registered, all ChatModel, tool, and embedding calls are traced.1
Install Orchestrion
2
Create orchestrion.tool.go in your project root
orchestrion.tool.go
3
Write your app
Register Eino’s global handlers with
callbacks.AppendGlobalHandlers(). Orchestrion appends traceeino.DefaultHandler() to that call at build time, so you don’t import or construct the Braintrust handler yourself.4
Build with Orchestrion and run
Enable Orchestrion via GOFLAGS
Enable Orchestrion via GOFLAGS
Instead of running
orchestrion go build, you can set a GOFLAGS environment variable to enable Orchestrion for normal go build commands:Manual instrumentation
To trace Eino manually, register Braintrust’s handler yourself by passingtraceeino.NewHandler() to callbacks.AppendGlobalHandlers. All subsequent ChatModel calls are traced.Streaming
For streaming, callWait() on the handler after closing the reader so asynchronously finalized span attributes are flushed before exit. Get the handler from traceeino.NewHandler() in the manual path, or from traceeino.DefaultHandler() when auto-instrumenting.#skip-compile
Tracing embeddings
Eino’s callback handler capturesEmbedStrings calls with no setup beyond registering the handler. Embedding calls appear as LLM spans in Braintrust, with input texts, embedding count, and model metadata captured.What Braintrust traces
Braintrust captures:- Chat model spans (
eino.<model>, for exampleeino.OpenAI), with input messages, model parameters (model, max_tokens, temperature, top_p, stop) in metadata, output message with finish reason and tool calls, and token usage metrics (prompt, completion, total, cached prompt, and reasoning tokens). - Streaming chat model output reconstructed from streamed chunks, with a
time_to_first_tokenmetric. - Tool spans (
eino.<tool>), with the tool’s JSON arguments as input and its response as output. - Embedding spans (
eino.<embedder>), with input texts, an embeddings count and vector length summary as output, model and encoding format in metadata, and prompt and total token metrics.
Resources
- CloudWeGo Eino documentation
- Go SDK example
- Trace LLM calls for general Go auto-instrumentation setup