Introduces code.nochebuena.dev/einherjar/telemetry — the observability bootstrap starter for the Einherjar framework. Absorbs the telemetry package from micro-lib, migrating from OpenCensus to OpenTelemetry SDK v1.42. Bootstrap functions (not lifecycle.Component — telemetry must be initialized before the launcher starts, and its shutdown must run after all components stop): - New(ctx, cfg) (func(context.Context) error, error) — production mode; exports traces, metrics, and logs via OTLP over gRPC to the configured endpoint; returns a shutdown function to be deferred in main() - NewConsole(ctx, logger, cfg) (func(context.Context) error, error) — development mode; writes structured telemetry to the provided logging.Logger; no network dependency; suitable for local development and CI Config (EINHERJAR_OTEL_* env vars): ServiceName(required), ServiceVersion(unknown), Environment(development), OTLPEndpoint(required for New), OTLPInsecure(false) ConsoleConfig (EINHERJAR_OTEL_* env vars): ServiceName(required), ServiceVersion(unknown), Environment(development) - identifiable.go: package-level Module variable (observability.Identifiable) for version identification — telemetry bootstraps before the launcher; not registered as a lifecycle component
33 lines
800 B
Go
33 lines
800 B
Go
package telemetry
|
|
|
|
import (
|
|
"runtime/debug"
|
|
|
|
"code.nochebuena.dev/einherjar/contracts/observability"
|
|
)
|
|
|
|
// Module identifies this package to observability systems.
|
|
// telemetry bootstraps before the launcher and is not registered as a lifecycle
|
|
// component. Register Module manually with any version registry if needed.
|
|
var Module observability.Identifiable = &moduleID{}
|
|
|
|
type moduleID struct{}
|
|
|
|
const modulePath = "code.nochebuena.dev/einherjar/telemetry"
|
|
|
|
func (m *moduleID) ModulePath() string { return modulePath }
|
|
|
|
func (m *moduleID) ModuleVersion() string {
|
|
if info, ok := debug.ReadBuildInfo(); ok {
|
|
for _, dep := range info.Deps {
|
|
if dep.Path == modulePath {
|
|
return dep.Version
|
|
}
|
|
}
|
|
if info.Main.Path == modulePath {
|
|
return info.Main.Version
|
|
}
|
|
}
|
|
return "(devel)"
|
|
}
|