metrics

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2025 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Counter: Total number of errors
	TotalErrors = prometheus.NewCounter(
		prometheus.CounterOpts{
			Name: "wallarm_apifw_service_errors_total",
			Help: "Total number of errors occurred in the APIFW service.",
		})

	// Counter: Errors by types
	ErrorTypeCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Name: "wallarm_apifw_service_errors_by_type",
			Help: "Total number of errors by type and endpoint.",
		},
		[]string{"error_type", "schema_id"},
	)

	// Counter: Total number of HTTP requests
	HttpRequestsTotal = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Name: "wallarm_apifw_http_requests_total",
			Help: "Total number of HTTP requests",
		},
		[]string{"schema_id", "status_code"},
	)

	// Histogram: HTTP request duration
	HttpRequestDuration = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Name:    "wallarm_apifw_http_request_duration_seconds",
			Help:    "HTTP request duration in seconds",
			Buckets: []float64{.001, .005, .025, .05, .25, .5, 1, 2.5, 5},
		},
		[]string{"schema_id"},
	)
)

Functions

This section is empty.

Types

type Metrics

type Metrics interface {
	IncErrorTypeCounter(err string, schemaID int)
	IncHTTPRequestStat(start time.Time, schemaID int, statusCode int)
	IncHTTPRequestTotalCountOnly(schemaID int, statusCode int)
}

type Options

type Options struct {
	EndpointName string
	Host         string
	ReadTimeout  time.Duration
	WriteTimeout time.Duration
}

type PrometheusMetrics

type PrometheusMetrics struct {
	// contains filtered or unexported fields
}

func NewPrometheusMetrics

func NewPrometheusMetrics(enabled bool) *PrometheusMetrics

func (*PrometheusMetrics) IncErrorTypeCounter

func (p *PrometheusMetrics) IncErrorTypeCounter(err string, schemaID int)

func (*PrometheusMetrics) IncHTTPRequestStat

func (p *PrometheusMetrics) IncHTTPRequestStat(start time.Time, schemaID int, statusCode int)

func (*PrometheusMetrics) IncHTTPRequestTotalCountOnly

func (p *PrometheusMetrics) IncHTTPRequestTotalCountOnly(schemaID int, statusCode int)

func (*PrometheusMetrics) StartService

func (p *PrometheusMetrics) StartService(logger *zerolog.Logger, options *Options) error

Jump to

Keyboard shortcuts

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