behavior

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package behavior holds build in [Behavior] implementations for [Mediator].

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLogger

func NewLogger(l *slog.Logger) mediator.Behavior

NewLogger creates a new Slogger mediator.Behavior.

func NewOtelTracer

func NewOtelTracer(opt ...OtelTracerOption) mediator.Behavior

NewOtelTracer creates a new OtelTracer mediator.Behavior.

Types

type OtelTracer

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

OtelTracer is a mediator.Behavior that adds tracing to the chain.

The behavior creates a new span for every request that passes through it and adds it to the context. It will also adjust the status and add an error attribute to the span if the resulting error of the request is not nil.

func (*OtelTracer) Handler

func (b *OtelTracer) Handler(next mediator.Handler) mediator.Handler

Handler runs the OtelTracer behavior.

type OtelTracerOption

type OtelTracerOption func(*otelTracerOptions)

OtelTracerOption defines the method to customize NewOtelTracer.

func WithTracerProvider

func WithTracerProvider(provider trace.TracerProvider) OtelTracerOption

WithTracerProvider overwrites the [tracer.TracerProvider] that the OtelTracer mediator.Behavior uses.

type Slogger

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

Slogger is a mediator.Behavior that adds logging to the chain.

The logger behavior adds a `request` slog.Attr with the request name to the logger that is passed through it. It also logs the request after it is handled. This includes the time it took to handle the request and the error if it is not nil.

func (Slogger) Handler

func (b Slogger) Handler(next mediator.Handler) mediator.Handler

Handler runs the Slogger behavior.

Jump to

Keyboard shortcuts

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