tracing

package
v1.11.1 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package tracing wires an OpenTelemetry TracerProvider for graphdb. It is off by default: unless GRAPHDB_TRACING_ENABLED is set, no global provider is installed and the spans the query layer already creates stay no-ops.

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 a global OpenTelemetry TracerProvider from cfg and returns a shutdown func that flushes and stops it. When cfg.Enabled is false it installs nothing (the global provider stays a no-op) and returns a no-op shutdown, so tracing has zero cost unless explicitly turned on.

The returned shutdown should be deferred by the caller (e.g. cmd/server) so buffered spans are flushed on exit.

Types

type Config

type Config struct {
	// Enabled is the master switch (GRAPHDB_TRACING_ENABLED). When false, Init
	// installs no provider and tracing costs nothing.
	Enabled bool
	// Exporter selects the span exporter: "otlp" (gRPC to a collector) or
	// "console" (stdout, for dev/demo). Unknown values fall back to "otlp".
	Exporter string
	// Endpoint is the OTLP target (OTEL_EXPORTER_OTLP_ENDPOINT); empty uses the
	// OTLP SDK default.
	Endpoint string
	// ServiceName tags every span's resource (OTEL_SERVICE_NAME).
	ServiceName string
}

Config is the resolved tracing configuration. It is a plain value so tests can compare it directly and callers can construct it without env.

func ConfigFromEnv

func ConfigFromEnv() Config

ConfigFromEnv resolves Config from environment variables, reusing OpenTelemetry's own conventions (OTEL_*) so operator knowledge transfers, with a GRAPHDB_-scoped master switch.

Jump to

Keyboard shortcuts

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