Documentation
¶
Index ¶
- Constants
- func Initialize(registry *prometheus.Registry, namespace, apiname string) errordeprecated
- func Logging(options LoggingOptions) gin.HandlerFunc
- func Metrics() (*prometheus.GaugeVec, *prometheus.CounterVec, *prometheus.HistogramVec)
- func OtelTracing(options TracingOptions) gin.HandlerFunc
- func ParseHeaders(headers map[string][]string) (args map[string]any)
- func ParseUserAgent(rawUserAgent string) (args map[string]any)
- func PrometheusMetrics(registry *prometheus.Registry, namespace string, apiname string, ...) gin.HandlerFunc
- func SpanStatus(status int) (code otelCodes.Code, desc string)
- func Telemetry() gin.HandlerFuncdeprecated
- type LoggingOption
- type LoggingOptions
- type MetricsOption
- type MetricsOptions
- type TracingOption
- type TracingOptions
Constants ¶
const ( UserAgentOS = "http.user_agent.os" UserAgentOSVersion = "http.user_agent.os_version" UserAgentDevice = "http.user_agent.device" UserAgentBrowser = "http.user_agent.browser" UserAgentBrowserVersion = "http.user_agent.browser_version" BrowserChrome = "chrome" BrowserSafari = "safari" BrowserFirefox = "firefox" BrowserOpera = "opera" BrowserIE = "ie" BrowserEdge = "edge" BrowserTrident = "Trident" DeviceMobile = "mobile" DeviceDesktop = "desktop" DeviceBot = "bot" )
const ( Http = "http" Https = "https" HttpMethod = "http.request.method" HttpPath = "http.request.path" HttpRemoteAddr = "http.request.remoteAddr" HttpRequestHost = "http.request.host" HttpStatus = "http.response.status" HttpLatency = "http.response.latency" TLSVersion = "http.tls.serviceVersion" HttpScheme = "http.scheme" )
Variables ¶
This section is empty.
Functions ¶
func Initialize
deprecated
func Initialize(registry *prometheus.Registry, namespace, apiname string) error
Initialize preps the middleware.
Deprecated: use GetMetricsMiddleware, GetTracingMiddleware, and GetLoggingMiddleware which do not require separate initialization.
func Logging ¶ added in v1.2.0
func Logging(options LoggingOptions) gin.HandlerFunc
Logging returns the logging middleware
func Metrics ¶ added in v1.0.0
func Metrics() (*prometheus.GaugeVec, *prometheus.CounterVec, *prometheus.HistogramVec)
Metrics provides the prometheus metrics that are to be tracked.
func OtelTracing ¶ added in v1.2.0
func OtelTracing(options TracingOptions) gin.HandlerFunc
OtelTracing returns the tracing middleware.
func ParseHeaders ¶
ParseHeaders parses the headers and returns a map of attribs.
func ParseUserAgent ¶
ParseUserAgent parses the user agent string and returns a map of attribs.
func PrometheusMetrics ¶ added in v1.2.0
func PrometheusMetrics(registry *prometheus.Registry, namespace string, apiname string, options MetricsOptions) gin.HandlerFunc
PrometheusMetrics returns the metrics middleware used by the Prometheus software.
func SpanStatus ¶
SpanStatus returns the OpenTelemetry statusLabel code as defined in go.opentelemetry.io/old_elemetry/codes and a brief description for a given HTTP statusLabel code.
func Telemetry
deprecated
func Telemetry() gin.HandlerFunc
Telemetry returns middleware that will instrument and trace incoming requests.
Deprecated: use GetMetricsMiddleware, GetTracingMiddleware, and GetLoggingMiddleware to get separated middleware for metrics, tracing, and logging.
Types ¶
type LoggingOption ¶ added in v1.2.0
type LoggingOption func(*LoggingOptions)
type LoggingOptions ¶ added in v1.2.0
type LoggingOptions struct {
}
type MetricsOption ¶ added in v1.2.0
type MetricsOption func(*MetricsOptions)
type MetricsOptions ¶ added in v1.2.0
type MetricsOptions struct {
}
type TracingOption ¶ added in v1.2.0
type TracingOption func(*TracingOptions)
func WithExcludedPaths ¶ added in v1.2.0
func WithExcludedPaths(paths []string) TracingOption
WithExcludedPaths allows to filter out URL paths, so that they are not traced.
type TracingOptions ¶ added in v1.2.0
type TracingOptions struct {
ExcludedPaths map[string]struct{}
}
func NewTracingOptions ¶ added in v1.2.0
func NewTracingOptions(opts ...TracingOption) TracingOptions
NewTracingOptions builds TracingOptions based on the provided options.