Documentation
¶
Overview ¶
Package telemetry provides OpenTelemetry trace export (OTLP) with resources in unique.
Bootstrap ¶
Blank-import the use subpackage at the app composition root (not telemetry itself):
import _ "github.com/omcrgnt/telemetry/use"
telemetry/use registers DefaultTrace via unique.MustAddReplaceable. Hardcoded dev defaults: host localhost, port 4318, insecure TLS, service name app.
User override ¶
Build and register a user Provider with unique.Add (replaces the system default):
built, err := cfg.Telemetry.Build() unique.Global().Add(built)
Config uses [common.v1.Label], [common.v1.Host], and [common.v1.Port] for OTLP endpoint and service name.
Wiring ¶
Provider implements Inject (sets global TracerProvider) and Close (shutdown). Call Inject before runner.Run so HTTP otelhttp instrumentation sees the provider.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultTrace ¶
func DefaultTrace() any
DefaultTrace returns the system trace Provider for telemetry/use registration.
Types ¶
type Config ¶
type Config struct {
ServiceName *commonv1.Label `ecfg:"SERVICE_NAME"`
Host *commonv1.Host `ecfg:"HOST"`
Port *commonv1.Port `ecfg:"PORT"`
Insecure Insecure `ecfg:"INSECURE"`
}
Config configures OTLP trace export (host, port, service name). ecfg fills and protovalidates proto fields before Build is called.
type Insecure ¶ added in v0.22.1
type Insecure bool
Insecure controls whether the OTLP HTTP exporter skips TLS — a plain bool doesn't implement Validator, which ecfg requires of every non-proto leaf field (see ecfgtool's validateLeaf); a named bool with Usage/Validate is the same fix every other non-proto scalar config field in this project already uses (e.g. IdleMin int in user-session's session.Spec).
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider configures the process TracerProvider. Catalog field: *Provider (Configurable) — declare it explicitly (e.g. `Telemetry *telemetry.Provider `ecfg:"TELEMETRY"“ in _appResources) to override the system default that telemetry/use registers via unique.MustAddReplaceable; the normal fill/LoadEnv/materialize/merge pipeline then replaces that Replaceable entry with one built from real env vars (see res/unique's Add/Merge: TagRegular replaces TagReplaceable). Without a catalog field, only the hardcoded default (see DefaultTrace) exists — see doc.go's manual-override path for the pre-existing alternative when a Configurable catalog field isn't a fit.
func (*Provider) BuildConfig ¶ added in v0.22.0
func (*Provider) BuildConfig() (app.Materializer, error)
BuildConfig returns the config spec for materialize.