otel

package
v1.6.31 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTTPHandler

func HTTPHandler(serverName string, log *slog.Logger) func(http.Handler) http.Handler

HTTPHandler returns an HTTP middleware that instruments requests with otelhttp and logs a request summary after the handler completes.

func HTTPHandlerFunc

func HTTPHandlerFunc(serverAddress string, log *slog.Logger) func(http.HandlerFunc) http.HandlerFunc

HTTPHandlerFunc is like HTTPHandler but wraps http.HandlerFunc directly. This is useful for routers that use HandlerFunc.

func NewLogger added in v1.6.21

func NewLogger(endpoint, header, name string, attrs ...Attr) (func(context.Context) error, error)

func NewMeter added in v1.6.21

func NewMeter(endpoint, header, name string, attrs ...Attr) (func(context.Context) error, error)

func NewTracer added in v1.6.21

func NewTracer(endpoint, header, name string, attrs ...Attr) (func(context.Context) error, error)

func ShutdownProvider added in v1.6.21

func ShutdownProvider(ctx context.Context) error

Types

type Attr added in v1.6.21

type Attr struct {
	Key   string
	Value string
}

type Provider added in v1.6.21

type Provider struct {
	// contains filtered or unexported fields
}

func NewProvider added in v1.6.21

func NewProvider(tracesEndpoint, metricsEndpoint, logsEndpoint, header, name string, attrs ...Attr) (*Provider, error)

func (*Provider) Logger added in v1.6.21

func (p *Provider) Logger(name string, opts ...otellog.LoggerOption) otellog.Logger

func (*Provider) Meter added in v1.6.21

func (p *Provider) Meter(name string, opts ...metric.MeterOption) metric.Meter

func (*Provider) Shutdown added in v1.6.21

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

func (*Provider) Tracer added in v1.6.21

func (p *Provider) Tracer(name string, opts ...trace.TracerOption) trace.Tracer

type ResponseWriter added in v1.6.21

type ResponseWriter interface {
	http.ResponseWriter

	// Status returns the status code of the response or 0 if the response has
	// not been written
	Status() int

	// Written returns whether or not the ResponseWriter has been written.
	Written() bool

	// Size returns the size of the response body.
	Size() int
}

ResponseWriter is a wrapper around http.ResponseWriter that provides extra information about the response. It is recommended that middleware handlers use this construct to wrap a responsewriter if the functionality calls for it.

func NewResponseWriter added in v1.6.21

func NewResponseWriter(rw http.ResponseWriter) ResponseWriter

NewResponseWriter creates a ResponseWriter that wraps a http.ResponseWriter

Jump to

Keyboard shortcuts

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