inner

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Goroutine middlewares

Goroutine middlewares

Index

Constants

This section is empty.

Variables

View Source
var ErrPanic = errors.New("captured panic")

ErrPanic is an error for captured panic

View Source
var (
	// ErrTypeCast is an error for type assertion from interface
	ErrTypeCast = errors.New("unable to cast interface to type")
)

Functions

This section is empty.

Types

type InternalMiddleware

type InternalMiddleware func(next InternalMiddlewareFn) InternalMiddlewareFn

func InternalMiddlewareChain

func InternalMiddlewareChain(mws ...InternalMiddleware) InternalMiddleware

func Logger

func Logger(values map[string]string, beginLevel slog.Level, endLevel slog.Level) InternalMiddleware

Logger is a middleware for logging begin and end messages. A new logger with values is added to the context.

func Metrics

func Metrics(ctx context.Context, meter metric_api.Meter, name string,
	description string, attributes map[string]string, errFormatter middleware.ErrFormatter,
) InternalMiddleware

Metrics is a middleware to make count and duration report

Prometheus-specific implementation:
The "_total" suffix is appended to the counter name, defined in "counterSuffix", see:
https://github.com/open-telemetry/opentelemetry-go/blob/main/exporters/prometheus/exporter.go#L100
The unit "s" is appended as "_seconds" to the metric name (injected before the "_total" suffix),
defined in "unitSuffixes", see
https://github.com/open-telemetry/opentelemetry-go/blob/main/exporters/prometheus/exporter.go#L343

func SemAcquire

func SemAcquire(sem *semaphore.Weighted) InternalMiddleware

SemAcquire is a middleware to acquire semaphore

func Span

func Span(tr trace.Tracer, spanName string) InternalMiddleware

Span is a middleware to start/end a new span, using from context. Sets "traceID", "spanParentID" and "spanID" log values.

func TryCatch

func TryCatch() InternalMiddleware

TryCatch is a middleware for catching Go panic and propagating it as an error

type InternalMiddlewareFn

type InternalMiddlewareFn func(ctx context.Context) (interface{}, error)

Jump to

Keyboard shortcuts

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