export

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package export installs the OpenTelemetry SDK providers a Tacklr host process sends its telemetry to: OTLP traces, metrics and logs (Init), or a Prometheus scrape (PrometheusMeterProvider). The default target is the LGTM stack through one OTLP endpoint (Grafana Alloy or the OpenTelemetry Collector, then Tempo, Loki, Mimir and Grafana).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(ctx context.Context, cfg Config) (func(context.Context) error, error)

Init installs the process-wide TracerProvider, MeterProvider, LoggerProvider, and the W3C propagator (trace context and baggage), so a turn's trace crosses every process and system it touches. With no endpoint the tracer still makes spans, which give the trace's context to the next process, and exports nothing. It returns the shutdown of the providers, which flushes them.

func PrometheusMeterProvider

func PrometheusMeterProvider(reg prometheus.Registerer, serviceName, serviceVersion string) *sdkmetric.MeterProvider

PrometheusMeterProvider builds a MeterProvider that records into reg for classic Prometheus scrape (host serves GET /metrics via promhttp).

The host owns the HTTP server and scrape URL, for example:

reg := prometheus.NewRegistry()
mp := telemetry.PrometheusMeterProvider(reg, "my-agent", "")
// worker.New(c, cfg)
// http.Handle("/metrics", promhttp.HandlerFor(reg, promhttp.HandlerOpts{}))

serviceName/serviceVersion set the same resource attributes as OTLP Init.

func Resource

func Resource(serviceName, serviceVersion string) *resource.Resource

Resource builds a shared Resource for TracerProvider and MeterProvider so backends can correlate service.name across traces, metrics, and logs. Empty serviceName becomes "tacklr".

func SlogHandler

func SlogHandler() slog.Handler

SlogHandler is a slog.Handler that sends each record to the process-wide LoggerProvider as an OpenTelemetry log, with the trace and span of its context: a host installs it (slog.SetDefault(slog.New(...))) so Tacklr's logs, which carry each operation's dynamic values, join its spans.

Types

type Config

type Config struct {
	ServiceName    string
	ServiceVersion string
	OTLPEndpoint   string // host:port or URL; falls back to OTEL_EXPORTER_OTLP_ENDPOINT
	Protocol       string // "grpc" (default) or "http"
	Insecure       bool
	SampleRatio    float64 // (0,1]; <=0 means always sample
	DisableMetrics bool
	DisableLogs    bool
}

Config is the host-facing OTLP setup. An empty OTLPEndpoint (and no OTEL_EXPORTER_OTLP_ENDPOINT) installs a tracer that does not export.

Jump to

Keyboard shortcuts

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