Documentation
¶
Overview ¶
Package arizeotel is the Go helper for sending OpenTelemetry traces to Arize. It wraps the standard OTel OTLP/HTTP setup with Arize-aware defaults so callers don't have to hand-roll ~30 lines of tracer-provider boilerplate on every service.
Typical usage:
tp, err := arizeotel.Register(ctx, arizeotel.Options{
ProjectName: "my-go-service",
// SpaceID and APIKey default to $ARIZE_SPACE_ID and $ARIZE_API_KEY.
})
if err != nil {
log.Printf("arize tracer: %v", err)
return
}
defer tp.Shutdown(ctx)
After Register returns, otel.Tracer("…") yields tracers wired to Arize. Never call log.Fatalf after a span has started — it skips the deferred Shutdown and the in-flight spans never flush.
This is the Go equivalent of arize-otel-python's register().
Index ¶
Constants ¶
const ( EndpointArize = "otlp.arize.com" EndpointArizeEurope = "otlp.eu-west-1a.arize.com" )
Default Arize OTLP/HTTP endpoint hostnames. The OTLP HTTP exporter takes a bare hostname (no scheme, no path) via WithEndpoint.
const ( EnvSpaceID = "ARIZE_SPACE_ID" EnvAPIKey = "ARIZE_API_KEY" EnvProjectName = "ARIZE_PROJECT_NAME" EnvEndpoint = "ARIZE_COLLECTOR_ENDPOINT" )
Environment variable names recognised by Register.
const Version = "0.1.0"
Version is the package version reported as the service.version resource attribute on every span created by tracers from a Register-returned TracerProvider.
Variables ¶
This section is empty.
Functions ¶
func Register ¶
Register configures an OpenTelemetry TracerProvider that exports spans to Arize via OTLP/HTTP, registers it as the global TracerProvider, and returns it so the caller can defer tp.Shutdown(ctx) to flush buffered spans before exit.
Callers should ALWAYS defer tp.Shutdown — for CLI/script processes, dropping this defer means batched spans never flush and traces never appear in Arize.
Types ¶
type Options ¶
type Options struct {
// SpaceID is the Arize Space ID. Required (via field or $ARIZE_SPACE_ID).
SpaceID string
// APIKey is the Arize API key. Required (via field or $ARIZE_API_KEY).
APIKey string
// ProjectName is the project to associate spans with. Defaults to
// "default" if empty and $ARIZE_PROJECT_NAME is unset.
ProjectName string
// Endpoint is the Arize OTLP/HTTP collector hostname. Defaults to
// EndpointArize (US). Use EndpointArizeEurope for EU spaces. Accepts
// either a bare hostname ("otlp.arize.com") or a full URL
// ("https://otlp.arize.com") — the scheme and path are stripped.
Endpoint string
// ExtraHeaders are merged into the OTLP/HTTP request headers alongside
// the required space_id and api_key headers. Use this to set custom
// routing headers or for on-prem deployments.
ExtraHeaders map[string]string
// ExtraResourceAttributes are merged into the OTel Resource alongside
// the required project-name attribute. Common additions: deployment
// environment, host metadata, build SHA. Values provided here override
// the defaults Register sets for service.name and service.version.
ExtraResourceAttributes []attribute.KeyValue
// Insecure disables TLS on the OTLP/HTTP exporter. Default false. Only
// set true for on-prem or local collectors.
Insecure bool
// SimpleProcessor uses SimpleSpanProcessor instead of BatchSpanProcessor.
// Default false (batched). Useful for tests and CLIs where you want
// every span flushed immediately.
SimpleProcessor bool
// SkipSetGlobal omits calling otel.SetTracerProvider on the returned
// TracerProvider. Default false (the provider becomes the global one).
SkipSetGlobal bool
}
Options configure the Register call. Empty string fields fall back to the matching ARIZE_* environment variable (and then to documented defaults).