metrics

package
v1.25.0-alpha.8 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BkBcsStorage for storage module metrics prefix
	BkBcsStorage = "bkbcs_storage"
)

Variables

This section is empty.

Functions

func ReportQueuePushMetrics

func ReportQueuePushMetrics(name string, err error, started time.Time)

ReportQueuePushMetrics report all queue push metrics

func ReportWatchHTTPResponseSize

func ReportWatchHTTPResponseSize(handler, table string, sizeBytes int64)

ObserveHTTPResponseSize report responseSize metrics when break connection

func ReportWatchRequestDec

func ReportWatchRequestDec(handler, table string)

ReportWatchRequestDec report watch connection des

func ReportWatchRequestInc

func ReportWatchRequestInc(handler, table string)

ReportWatchRequestInc report watch connection inc

Types

type Config

type Config struct {
	// Prefix is the prefix that will be set on the metrics, by default it will be empty.
	Prefix string
	// DurationBuckets are the buckets used by Prometheus for the HTTP request duration metrics,
	// by default uses Prometheus default buckets (from 5ms to 10s).
	DurationBuckets []float64
	// SizeBuckets are the buckets used by Prometheus for the HTTP response size metrics,
	// by default uses a exponential buckets from 100B to 1GB.
	SizeBuckets []float64
	// Registry is the registry that will be used by the recorder to store the metrics,
	// if the default registry is not used then it will use the default one.
	Registry prometheus.Registerer
	// HandlerIDLabel is the name that will be set to the handler ID label, by default is `handler`.
	HandlerIDLabel string
	// StatusCodeLabel is the name that will be set to the status code label, by default is `code`.
	StatusCodeLabel string
	// MethodLabel is the name that will be set to the method label, by default is `method`.
	MethodLabel string
	// ClusterIDLabel is the name that will be set to the cluster_id label, default is `cluster_id`
	ClusterIDLabel string
	// ResourceTypeLabel is the name that will be set to the resource_type label, default is `resource_type`
	ResourceTypeLabel string
}

Config has the dependencies and values of the recorder.

type HTTPProperties

type HTTPProperties struct {
	// ID is the id of the request handler or handlerName.
	Handler string
	// Method is the method of the request.
	Method string
}

HTTPProperties for the global server metrics.

type HTTPReqProperties

type HTTPReqProperties struct {
	// ID is the id of the request handler or handlerName.
	Handler string
	// Method is the method of the request.
	Method string
	// Code is the response of the request.
	Code string
	// ClusterID is the parameter of the request
	ClusterID string
	// ResourceType is the parameter of the request
	ResourceType string
}

HTTPReqProperties for the metrics based on client request.

type Recorder

type Recorder interface {
	// ObserveHTTPRequestCounterDuration measures the count and duration of an HTTP request.
	ObserveHTTPRequestCounterDuration(ctx context.Context, props HTTPReqProperties, duration time.Duration)
	// ObserveHTTPResponseSize measures the size of an HTTP response in bytes.
	ObserveHTTPResponseSize(ctx context.Context, props HTTPReqProperties, sizeBytes int64)
	// AddInflightRequests increments and decrements the number of inflight request being processed.
	AddInflightRequests(ctx context.Context, props HTTPProperties, quantity int)
}

Recorder record and measure the metrics. This Interface has the required methods to be used with the HTTP middleware.

func NewRecorder

func NewRecorder(cfg Config) Recorder

NewRecorder returns a new metrics recorder that implements the recorder using Prometheus as the backend.

Jump to

Keyboard shortcuts

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