Documentation/SDK (Go)/Tracing
1 min read

Tracing

Use OpenTelemetry spans and stable naming conventions so traces are consistent across languages.

Minimal smoke example (real)

This mirrors sdk/boson-go/examples/trace-smoke/main.go:

package main

import (
  "context"
  "time"
  boson "github.com/getboson/boson-go"
)

func main() {
  cfg := boson.ConfigFromEnv() // accepts BOSON_* or LANGFUSE_* equivalents
  client, _ := boson.NewClient(cfg)

  now := time.Now().UTC()
  traceID := "boson-go-smoke-" + now.Format("20060102-150405")

  client.TraceCreate(boson.TraceCreateBody{
    ID:        traceID,
    Timestamp: now,
    Name:      "boson-go-smoke",
    Metadata:  map[string]any{"example": "trace-smoke"},
  })

  client.SpanCreate(boson.SpanCreateBody{
    ID:        "span-" + traceID,
    TraceID:   traceID,
    StartTime: now,
    EndTime:   now.Add(1200 * time.Millisecond),
    Name:      "boson-go-operation",
    Input:     map[string]any{"ok": true},
    Output:    map[string]any{"at": now.Format(time.RFC3339Nano)},
  })

  _ = client.Flush(context.Background())
}
  • retrieval.query
  • llm.completion
  • tool.execute

Next steps