Migration: OTLP settings carry an Exporter¶
go-tool-base now requires gitlab.com/phpboyscout/go/observability v0.6.0. In
that release otelcore.Settings is {Enabled bool; Exporter otelcore.Exporter},
and the collector fields live on otelcore.Collector. The change is decided in
observability spec 0003.
Who is affected¶
Only a tool that builds telemetry.ObservabilitySettings by hand, or reads the
OTLP fields back out of it. A tool that configures telemetry through its
telemetry.* config keys changes nothing: the keys and their meaning are the
same, and pkg/telemetry resolves them into the new shape.
What to change¶
// before
otlp := otelcore.Settings{Enabled: true, Endpoint: "https://collector:4318", Insecure: true}
// after
otlp := otelcore.Settings{
Enabled: true,
Exporter: otelcore.Collector{Endpoint: "https://collector:4318", Insecure: true},
}
A nil Exporter behaves as an empty Collector, so the OTel SDK reads the
OTEL_EXPORTER_OTLP_* environment variables, exactly as an empty Endpoint
did before.
To read the resolved endpoint, assert the exporter's type:
func tracingEndpoint(settings telemetry.ObservabilitySettings) string {
if c, ok := settings.Tracing.OTLP.Exporter.(otelcore.Collector); ok {
return c.Endpoint
}
return ""
}
One config key is now refused¶
telemetry.<signal>.exporter is not a go-tool-base key and nothing ships it.
Before, it was ignored everywhere. Now telemetry.ObserveSettingsFromConfig
returns an error when the key is present at bind time, because the decoder
cannot turn a config value into an Exporter. A config reload that adds the
key later is not applied: the observed settings keep their last good value.
The settings telemetry.SetupFromProps resolves through
telemetry.ObservabilitySettingsFromProps still ignore the key, so only a tool
that observes the settings itself is affected. Remove
the key if you have it.