telemetry

package module
v0.22.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 6, 2026 License: MIT Imports: 11 Imported by: 0

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.

func (Config) Build

func (c Config) Build() (any, error)

Build returns a Provider resource for unique.Add.

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).

func (Insecure) Usage added in v0.22.1

func (Insecure) Usage() string

func (Insecure) Validate added in v0.22.1

func (Insecure) Validate() error

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.

func (*Provider) Close

func (p *Provider) Close(ctx context.Context) error

Close shuts down the TracerProvider (runner.Closer).

func (*Provider) Deps

func (p *Provider) Deps() []any

func (*Provider) Inject

func (p *Provider) Inject(_ []any)

Directories

Path Synopsis
Package use registers telemetry system defaults in unique.Global.
Package use registers telemetry system defaults in unique.Global.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL