otel

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package otel provides thin OpenTelemetry middleware helpers for Loom HTTP servers and clients.

The package intentionally wraps the official OpenTelemetry contrib HTTP instrumentation instead of implementing tracing itself. Applications remain responsible for configuring the tracer provider, exporter, and resource attributes. Loom owns the transport seam so generated and hand-written handlers can share one instrumentation path.

Use Middleware with loomhttp.NewMuxer so spans can inherit the matched METHOD-plus-route pattern from r.Pattern:

mux := loomhttp.NewMuxer()
mux.Use(otel.Middleware("service"))

For generated HTTP clients, wrap an *http.Client before passing it anywhere a Loom HTTP Doer is expected:

client := otel.WrapClient(&http.Client{})

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handler

func Handler(handler http.Handler, service string, opts ...Option) http.Handler

Handler wraps an HTTP handler with OpenTelemetry instrumentation.

func Middleware

func Middleware(service string, opts ...Option) func(http.Handler) http.Handler

Middleware instruments an HTTP handler chain using the official OpenTelemetry HTTP middleware.

The provided service name is used as the fallback operation name. When the request carries a matched Loom route pattern in r.Pattern, the middleware uses that pattern as the span name so spans remain stable across path parameters.

func WrapClient

func WrapClient(client *http.Client, opts ...Option) *http.Client

WrapClient returns a shallow copy of client whose Transport is instrumented with OpenTelemetry.

If client is nil, WrapClient returns a new client using the default instrumented transport.

func WrapTransport

func WrapTransport(rt http.RoundTripper, opts ...Option) http.RoundTripper

WrapTransport instruments an HTTP RoundTripper using the official OpenTelemetry HTTP transport wrapper.

Types

type Option

type Option = otelhttp.Option

Option configures HTTP OpenTelemetry instrumentation.

Jump to

Keyboard shortcuts

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