http

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package http provides HTTP middleware for metrics collection and monitoring. It offers tools to track and measure HTTP request counts, durations, and response codes, allowing for detailed monitoring and analysis of HTTP traffic in Go applications.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPMetricsMiddleware

type HTTPMetricsMiddleware interface {
	// Handler wraps an existing http.Handler with metrics collection.
	// It tracks request counts and durations with attributes for method, URI, and status code,
	// providing detailed insights into HTTP request handling.
	Handler(next http.Handler) http.Handler
}

HTTPMetricsMiddleware defines an interface for HTTP metrics collection middleware. It provides a way to collect and report metrics for HTTP requests, enabling monitoring of API performance, traffic patterns, and error rates.

func NewHTTPMetricsMiddleware

func NewHTTPMetricsMiddleware() (HTTPMetricsMiddleware, error)

NewHTTPMetricsMiddleware creates a new HTTP metrics middleware that collects request counts and durations for HTTP requests. It sets up OpenTelemetry instruments for tracking request metrics with standardized names and descriptions.

Returns:

  • An HTTPMetricsMiddleware interface for HTTP metrics collection.
  • An error if the meter instruments cannot be created.

Jump to

Keyboard shortcuts

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