otelx

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package otelx holds low-level OpenTelemetry helpers shared across the project. It must stay a leaf package — it has no dependencies on other internal packages — so every feature package (auth, download, indexer, ...) can import it without creating cycles through internal/observability.

Index

Constants

This section is empty.

Variables

View Source
var HTTPClient = &http.Client{
	Transport: otelhttp.NewTransport(http.DefaultTransport),
}

HTTPClient is a shared *http.Client with OTel instrumentation wired into the transport. Every outbound request becomes a child span of the caller's context with HTTP semconv attributes, and metrics are recorded via the global meter provider. Use for every outbound HTTP call (external APIs, indexers, media servers, download clients) so traces, latencies, and errors are visible in the backend.

Functions

func Must

func Must[T any](v T, err error) T

Must panics when err is non-nil and returns v otherwise. Use for OTel instrument creation at package init(), where a failure is a programmer error (invalid instrument name/unit) that should abort startup:

counter = otelx.Must(meter.Int64Counter("streamline.foo", ...))

func RecordSpanError

func RecordSpanError(span trace.Span, err error) error

RecordSpanError marks span as failed (records err + sets Error status) and returns err unchanged so callers can use it inline at a return site:

if err != nil {
    return nil, otelx.RecordSpanError(span, fmt.Errorf("..."))
}

Types

This section is empty.

Jump to

Keyboard shortcuts

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