trace

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package trace implements a OpenTelemetry middleware for labstack/echo.

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = Config{
	Skipper:       middleware.DefaultSkipper,
	ComponentName: defaultComponentName,
	DumpBodies:    false,
	LimitBodySize: defaultBodyLimit,
}

Functions

func Record

func Record(ctx context.Context, err error, keyVals ...string)

Record adds an error to the current span and appends keyVal as attributes.

func RecordAndLog

func RecordAndLog(ctx context.Context, err error, keyVals ...string)

func WithConfig

func WithConfig(config Config) echo.MiddlewareFunc

trunk-ignore(golangci-lint/cyclop)

Types

type Config

type Config struct {
	// Skipper defines a function to skip middleware.
	Skipper middleware.Skipper

	// Tracer is the default tracer that should be used.
	// If empty, a new tracer is retrieved using otel.Tracer("")
	Tracer trace.Tracer

	// ComponentName used for describing the tracing component.
	ComponentName string

	// DumpBodies should be set to true if the request and response
	// bodies should be dumped to spans.
	DumpBodies bool

	// LimitBodySize holds the maximum number of bytes that are appended to
	// a span.
	LimitBodySize int
}

type ResponseRecorder

type ResponseRecorder struct {
	http.ResponseWriter
	// contains filtered or unexported fields
}

ResponseRecorder can record a labstack/echo response body.

func NewResponseRecorder

func NewResponseRecorder(resp *echo.Response) *ResponseRecorder

New ResponseRecorder returns a new response recorder that stores the body written to resp.

func (*ResponseRecorder) GetResponse

func (d *ResponseRecorder) GetResponse() string

GetResponse returns the response recorded in d.

func (*ResponseRecorder) Write

func (d *ResponseRecorder) Write(b []byte) (int, error)

Write proxies calls to the actual *echo.Response and a buffer.

Jump to

Keyboard shortcuts

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