Configuring OTEL Trace Exporter for Arize in Golang
Moving my question here. I configured OTEL in a golang project along these lines:
# Arize Cloud Configuration
ARIZE_ENDPOINT=https://otlp.arize.com/v1
ARIZE_SPACE_KEY=***
ARIZE_API_KEY=***
// createArizeTraceExporter creates an OTLP trace exporter configured for Arize
func createArizeTraceExporter(ctx context.Context, env environment.Env) (trace.SpanExporter, error) {
headers := map[string]string{
"x-api-key": env.ArizeAPIKey,
"x-space-key": env.ArizeSpaceKey,
}
endpoint := env.ArizeEndpoint
if endpoint == "" {
endpoint = "localhost:4317" // Default for development
}
opts := []otlptracegrpc.Option{
otlptracegrpc.WithEndpoint(endpoint),
otlptracegrpc.WithHeaders(headers),
otlptracegrpc.WithTimeout(5 * time.Second),
}
if strings.Contains(endpoint, "localhost") {
opts = append(opts, otlptracegrpc.WithInsecure())
}
// Create exporter with throttling - only 5% of traces
exporter, err := otlptracegrpc.New(ctx, opts...)
if err != nil {
return nil, err
}
// Wrap with sampling exporter (5% sampling)
return NewSamplingExporter(exporter, 1.0), nil
}
