observability

package
v0.0.0-...-ef3af43 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package observability implements various observability handlers for the API servers

Index

Constants

View Source
const (
	// MetricSubsystem is the subsystem for the metric
	MetricSubsystem = "api_server"
	// MetricName is the name of the metric
	MetricName = "request_duration_seconds"
)

Variables

View Source
var CaptureRouteTemplateMiddleware mux.MiddlewareFunc = CaptureRouteTemplateMiddlewareWithPrefix("")

When the router is mounted under http.StripPrefix, use CaptureRouteTemplateMiddlewareWithPrefix instead to preserve the full path in the metric tag.

Functions

func CaptureRouteTemplateMiddlewareWithPrefix

func CaptureRouteTemplateMiddlewareWithPrefix(prefix string) mux.MiddlewareFunc

CaptureRouteTemplateMiddlewareWithPrefix returns a gorilla/mux middleware that captures the matched route template and prepends prefix to it. Use this when the router is mounted via http.StripPrefix so that the full request path is reflected in the metric tag.

Must be registered via gorilla/mux Router.Use() so that it runs inside the routing context where mux.CurrentRoute returns the matched route.

func LogResponseHandler

func LogResponseHandler(servername string) mux.MiddlewareFunc

LogResponseHandler is a middleware that logs the response code and other various information about the request

Types

type TelemetryMiddlewareFactory

type TelemetryMiddlewareFactory interface {
	Middleware(serverName string) mux.MiddlewareFunc
}

TelemetryMiddlewareFactory creates a telemetry middleware tagged with a given server name

func NewTelemetryMiddlewareFactory

func NewTelemetryMiddlewareFactory(telemetry telemetry.Component, authTagGetter func(r *http.Request) string) TelemetryMiddlewareFactory

NewTelemetryMiddlewareFactory creates a new TelemetryMiddlewareFactory

This function must be called only once for a given telemetry Component, as it creates a new metric, and Prometheus panics if the same metric is registered twice.

Jump to

Keyboard shortcuts

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