tRPC-Agent-Go provides comprehensive observability features built on the OpenTelemetry standard, offering powerful observability capabilities for Agent applications. With observability enabled, developers can achieve end-to-end monitoring of Agent runtime status, including tracing, performance metrics collection, and logging.
π― Key Features
Tracing: Fully records call chains during Agent execution.
Metrics: Collects key runtime performance data for Agents.
Logging: Unified log collection and management.
Multi-platform Support: Supports mainstream monitoring platforms such as Jaeger, Prometheus, Galileo, and ZhiYan Monitoring Bao.
Flexible Configuration: Supports multiple configuration methods and custom extensions.
Integration with Different Monitoring Platforms
Langfuse Integration
Langfuse is an observability platform designed for LLM applications and supports collecting tracing data via the OpenTelemetry protocol. tRPC-Agent-Go can export Trace data to Langfuse via OpenTelemetry.
1. Deploy Langfuse
Refer to the Langfuse self-hosting guide for local or cloud deployment. For a quick start, see the Docker Compose deployment guide.
You can view tracing data in the Langfuse console.
Integration Code Description
Langfuse supports receiving Trace data via the /api/public/otel (OTLP) endpoint, supporting HTTP/protobuf only, not gRPC.
The above code integrates with Langfuse by setting OTEL_EXPORTER_OTLP_HEADERS and OTEL_EXPORTER_OTLP_TRACES_ENDPOINT.
# EU data regionOTEL_EXPORTER_OTLP_ENDPOINT="https://cloud.langfuse.com/api/public/otel"# US data region# OTEL_EXPORTER_OTLP_ENDPOINT="https://us.cloud.langfuse.com/api/public/otel"# Local deployment (>= v3.22.0)# OTEL_EXPORTER_OTLP_ENDPOINT="http://localhost:3000/api/public/otel"# Set Basic Auth authenticationOTEL_EXPORTER_OTLP_HEADERS="Authorization=Basic ${AUTH_STRING}"
AUTH_STRING is the base64 encoding of public_key:secret_key, which can be generated using the following command:
packagemainimport("context""fmt""time"ametric"trpc.group/trpc-go/trpc-agent-go/telemetry/metric"atrace"trpc.group/trpc-go/trpc-agent-go/telemetry/trace""go.opentelemetry.io/otel/attribute""go.opentelemetry.io/otel/metric""go.opentelemetry.io/otel/trace")funcprocessAgentRequest(ctxcontext.Context)error{// Create tracing span.ctx,span:=atrace.Tracer.Start(ctx,"process-agent-request",trace.WithAttributes(attribute.String("agent.type","chat"),attribute.String("user.id","user123"),),)deferspan.End()// Create metrics counter.requestCounter,err:=ametric.Meter.Int64Counter("agent.requests.total",metric.WithDescription("Total number of agent requests"),)iferr!=nil{returnerr}// Record request.requestCounter.Add(ctx,1,metric.WithAttributes(attribute.String("agent.type","chat"),attribute.String("status","success"),))// Simulate processing.time.Sleep(100*time.Millisecond)returnnil}
Agent Execution Tracing
The framework automatically instruments key components of Agents:
import("go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp""go.opentelemetry.io/otel/sdk/trace")funcsetupCustomExporter()error{exporter,err:=otlptracehttp.New(context.Background(),otlptracehttp.WithEndpoint("https://your-custom-endpoint.com"),otlptracehttp.WithHeaders(map[string]string{"Authorization":"Bearer your-token",}),)iferr!=nil{returnerr}tp:=trace.NewTracerProvider(trace.WithBatcher(exporter),)// Set as the global TracerProvider.otel.SetTracerProvider(tp)returnnil}
References
OpenTelemetry documentation.
tRPC-Agent-Go telemetry examples.
By using observability features properly, you can establish a complete monitoring system for Agent applications, discover and resolve issues in time, and continuously optimize system performance.