otelhttpmetrics

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultAttributes = func(request *http.Request) []attribute.KeyValue {
	attrs := []attribute.KeyValue{
		semconv.HTTPMethodKey.String(request.Method),
	}
	origin := request.Host
	target := request.URL.Path
	if origin != "" {
		attrs = append(attrs, semconv.HTTPHostKey.String(origin))
	}
	if target != "" {
		attrs = append(attrs, semconv.HTTPTargetKey.String(target))
	}
	return attrs
}

Functions

func NewTransport

func NewTransport(base http.RoundTripper, options ...Option) *transport

func SemVersion

func SemVersion() string

SemVersion is the semantic version to be supplied to tracer/meter creation.

func Version

func Version() string

Version is the current release version of the gin instrumentation.

Types

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option applies a configuration to the given config

func WithAttributes

func WithAttributes(attributes func(*http.Request) []attribute.KeyValue) Option

WithAttributes sets a func using which what attributes to be recorded can be specified. By default the DefaultAttributes is used

func WithGroupedStatusDisabled

func WithGroupedStatusDisabled() Option

WithGroupedStatus determines whether to group the response status codes or not. If true 2xx, 3xx will be stored By default the groupedStatus is true

func WithRecordDurationDisabled

func WithRecordDurationDisabled() Option

WithRecordDuration determines whether to record Duration of Requests or not By default the recordDuration is true

func WithRecordInFlightDisabled

func WithRecordInFlightDisabled() Option

WithRecordInFlight determines whether to record In Flight Requests or not By default the recordInFlight is true

func WithRecordSizeDisabled

func WithRecordSizeDisabled() Option

WithRecordSize determines whether to record Size of Requests and Responses or not By default the recordSize is true

func WithRecorder

func WithRecorder(recorder Recorder) Option

WithRecorder sets a recorder for recording requests By default the open telemetry recorder is used

func WithShouldRecordFunc

func WithShouldRecordFunc(shouldRecord func(*http.Request) bool) Option

WithShouldRecordFunc sets a func using which whether a record should be recorded By default the all api calls are recorded

type Recorder

type Recorder interface {
	// AddRequests increments the number of requests being processed.
	AddRequests(ctx context.Context, quantity int64, attributes []attribute.KeyValue)

	// ObserveHTTPRequestDuration measures the duration of an HTTP request.
	ObserveHTTPRequestDuration(ctx context.Context, duration time.Duration, attributes []attribute.KeyValue)

	// ObserveHTTPRequestSize measures the size of an HTTP request in bytes.
	ObserveHTTPRequestSize(ctx context.Context, sizeBytes int64, attributes []attribute.KeyValue)

	// ObserveHTTPResponseSize measures the size of an HTTP response in bytes.
	ObserveHTTPResponseSize(ctx context.Context, sizeBytes int64, attributes []attribute.KeyValue)

	// AddInflightRequests increments and decrements the number of inflight request being processed.
	AddInflightRequests(ctx context.Context, quantity int64, attributes []attribute.KeyValue)
}

func GetRecorder

func GetRecorder(metricsPrefix string) Recorder

Jump to

Keyboard shortcuts

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