slo

package
v0.249.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusOK         Status   = "ok"
	StatusError      Status   = "error"
	EndpointHealth   Endpoint = "health"
	EndpointQuery    Endpoint = "query"
	EndpointResource Endpoint = "resource"
	SourceDownstream Source   = "downstream"
	SourcePlugin     Source   = "plugin"
)
View Source
const DataSourceSLOMiddlewareName = "slo"

DataSourceSLOMiddlewareName is the middleware name used by Middleware.

Variables

Functions

func AddMiddleware added in v0.235.0

AddMiddleware adds the middleware to the http client options.

func FromStatus added in v0.235.0

func FromStatus(status backend.Status) backend.ErrorSource

FromStatus returns the error source from backend status

func Middleware

func Middleware() httpclient.Middleware

Middleware applies the duration to the context.

func NewClient added in v0.235.0

func NewClient(opts ...httpclient.Options) (*http.Client, error)

NewClient wraps the existing http client constructor and adds the duration middleware

func RoundTripper

func RoundTripper(_ httpclient.Options, next http.RoundTripper) http.RoundTripper

RoundTripper captures the duration of the request in the context

func SanitizeLabelName

func SanitizeLabelName(name string) (string, error)

Types

type Collector added in v0.235.0

type Collector interface {
	CollectDuration(source Source, status Status, statusCode int, duration float64)
	WithEndpoint(endpoint Endpoint) Collector
}

func NewMetrics added in v0.235.0

func NewMetrics(dsName, dsType string) Collector

NewMetrics creates a new Metrics instance

type Duration added in v0.235.0

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

Duration is stored in the Context and used to collect metrics

func NewDuration added in v0.235.0

func NewDuration(value float64) *Duration

func (*Duration) Add added in v0.235.0

func (d *Duration) Add(value float64, source Source, statusCode int, err error)

func (*Duration) Value added in v0.235.0

func (d *Duration) Value() float64

type DurationKey added in v0.235.0

type DurationKey struct{}

DurationKey is a key for storing the duration in the context

type Endpoint added in v0.235.0

type Endpoint string

Endpoint is the endpoint of the request (health, query, resource)

type Metrics added in v0.235.0

type Metrics struct {
	DSName   string
	DSType   string
	Endpoint Endpoint
}

Metrics is an abstraction for collecting metrics

func (Metrics) CollectDuration added in v0.235.0

func (m Metrics) CollectDuration(source Source, status Status, statusCode int, duration float64)

CollectDuration collects the duration as a metric

func (Metrics) WithEndpoint added in v0.235.0

func (m Metrics) WithEndpoint(endpoint Endpoint) Collector

WithEndpoint returns a new Metrics instance with the given endpoint

type MetricsWrapper added in v0.235.0

type MetricsWrapper struct {
	Name string
	Type string

	Metrics Collector
	// contains filtered or unexported fields
}

MetricsWrapper is a wrapper for a plugin that collects metrics

func NewMetricsWrapper added in v0.235.0

func NewMetricsWrapper(plugin any, s backend.DataSourceInstanceSettings, c ...Collector) *MetricsWrapper

NewMetricsWrapper creates a new MetricsWrapper instance

func (*MetricsWrapper) CallResource added in v0.235.0

CallResource calls the CallResourceHandler and collects metrics

func (*MetricsWrapper) CheckHealth added in v0.235.0

CheckHealth calls the CheckHealthHandler and collects metrics

func (*MetricsWrapper) QueryData added in v0.235.0

QueryData calls the QueryDataHandler and collects metrics

type Source added in v0.235.0

type Source string

Source is the source of the error (downstream, plugin)

type Status added in v0.235.0

type Status string

Status is the status of the request

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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