Documentation ¶
Index ¶
- Variables
- func Middleware(service string, options ...Option) gin.HandlerFunc
- func SemVersion() string
- func Version() string
- type Option
- func WithAttributes(...) Option
- func WithGroupedStatusDisabled() Option
- func WithRecordDurationDisabled() Option
- func WithRecordInFlightDisabled() Option
- func WithRecordSizeDisabled() Option
- func WithRecorder(recorder Recorder) Option
- func WithShouldRecordFunc(shouldRecord func(serverName, route string, request *http.Request) bool) Option
- type Recorder
Constants ¶
This section is empty.
Variables ¶
var DefaultAttributes = func(serverName, route string, request *http.Request) []attribute.KeyValue { attrs := []attribute.KeyValue{ semconv.HTTPRequestMethodKey.String(request.Method), } if serverName != "" { attrs = append(attrs, semconv.ServiceNameKey.String(serverName)) } if route != "" { attrs = append(attrs, semconv.HTTPRouteKey.String(route)) } return attrs }
Functions ¶
func Middleware ¶
func Middleware(service string, options ...Option) gin.HandlerFunc
Middleware returns middleware that will trace incoming requests. The service parameter should describe the name of the (virtual) server handling the request.
func SemVersion ¶
func SemVersion() string
SemVersion is the semantic version to be supplied to tracer/meter creation.
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(serverName, route string, request *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 ¶
WithRecorder sets a recorder for recording requests By default the open telemetry recorder is used
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) }