interceptor

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLoggingInterceptor

func NewLoggingInterceptor(log *zap.SugaredLogger) fiber.Interceptor

NewLoggingInterceptor is a creator factory for a ResponseLoggingInterceptor

func NewMetricsInterceptor

func NewMetricsInterceptor(client StatsdClient) fiber.Interceptor

NewMetricsInterceptor creates a new MetricsInterceptor with the given client

func NewTracingInterceptor

func NewTracingInterceptor(tracer opentracing.Tracer) fiber.Interceptor

NewTracingInterceptor creates a TracingInterceptor

Types

type MetricsInterceptor

type MetricsInterceptor struct {
	fiber.NoopAfterDispatchInterceptor
	// contains filtered or unexported fields
}

MetricsInterceptor is an interceptor to log metrics

func (*MetricsInterceptor) AfterCompletion

func (i *MetricsInterceptor) AfterCompletion(ctx context.Context, req fiber.Request, queue fiber.ResponseQueue)

AfterCompletion computes and submits the request completion time

func (*MetricsInterceptor) BeforeDispatch

func (i *MetricsInterceptor) BeforeDispatch(ctx context.Context, req fiber.Request) context.Context

BeforeDispatch records count of the requests through a component and the request start time

type MetricsKey

type MetricsKey string

MetricsKey is an alias for a string

var (
	CtxDispatchStartTimeKey MetricsKey = "CTX_DISPATCH_START_TIME"
)

CtxDispatchStartTimeKey is used to record the start time of a request

type ResponseLoggingInterceptor

type ResponseLoggingInterceptor struct {
	fiber.NoopBeforeDispatchInterceptor
	fiber.NoopAfterCompletionInterceptor
	// contains filtered or unexported fields
}

ResponseLoggingInterceptor is the structural interceptor used for logging responses

func (*ResponseLoggingInterceptor) AfterDispatch

func (i *ResponseLoggingInterceptor) AfterDispatch(ctx context.Context, req fiber.Request, queue fiber.ResponseQueue)

AfterDispatch logs the success or failure information of a request

type StatsdClient

type StatsdClient interface {
	Increment(string)
	Unique(string, string)
	Timing(string, interface{})
}

StatsdClient is an interface for a stats listener

type TracingInterceptor

type TracingInterceptor struct {
	fiber.NoopAfterDispatchInterceptor
	// contains filtered or unexported fields
}

TracingInterceptor allows for tracing requests

func (*TracingInterceptor) AfterCompletion

func (i *TracingInterceptor) AfterCompletion(ctx context.Context, req fiber.Request, queue fiber.ResponseQueue)

AfterCompletion returns the Span previously associated with context

func (*TracingInterceptor) BeforeDispatch

func (i *TracingInterceptor) BeforeDispatch(ctx context.Context, req fiber.Request) context.Context

BeforeDispatch starts and returns a span with the given operation name

Jump to

Keyboard shortcuts

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