metric

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2022 License: MPL-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package metric provides functions to initialize the controller specific collectors and hooks to measure metrics and update the relevant collectors.

Package metric provides functions to initialize the controller specific collectors and hooks to measure metrics and update the relevant collectors.

Index

Constants

View Source
const (
	LabelGrpcService = "grpc_service"
	LabelGrpcMethod  = "grpc_method"
	LabelGrpcCode    = "grpc_code"
	LabelHttpPath    = "path"
	LabelHttpMethod  = "method"
	LabelHttpCode    = "code"
)

Variables

Functions

func InitializeApiCollectors

func InitializeApiCollectors(r prometheus.Registerer, v prometheus.ObserverVec, expectedPathsToMethods map[string][]string, expectedStatusCodesPerMethod map[string][]int)

InitializeApiCollectors registers and zeroes a Prometheus histogram, populating all path, code, and method labels from the provided maps in its parameters.

func InitializeGrpcCollectorsFromPackage

func InitializeGrpcCollectorsFromPackage(r prometheus.Registerer, v prometheus.ObserverVec, pkg protoreflect.FileDescriptor, codes []codes.Code)

InitializeGrpcCollectorsFromPackage registers and zeroes a Prometheus histogram, populating all service and method labels by ranging through a given protobuf package.

func InitializeGrpcCollectorsFromServer

func InitializeGrpcCollectorsFromServer(r prometheus.Registerer, v prometheus.ObserverVec, server *grpc.Server, codes []codes.Code)

InitializeGrpcCollectorsFromServer registers and zeroes a Prometheus histogram, finding all service and method labels from the provided gRPC server.

func NewStatsHandler

func NewStatsHandler(ctx context.Context, o prometheus.ObserverVec) (*statsHandler, error)

NewStatsHandler takes a request latency metric (prometheus.ObserverVec) and returns a grpc stats.Handler that updates the provided metric with the request latency.

func SplitMethodName

func SplitMethodName(fullMethodName string) (string, string)

SplitMethodName returns the service and the method name when given the full method name as provided by the grpc request handler.

func StatusFromError

func StatusFromError(err error) *status.Status

StatusFromError retrieves the *status.Status from the provided error. It'll attempt to unwrap the *status.Error, which is something status.FromError does not do.

Types

type TestInvoker

type TestInvoker struct {
	T      *testing.T
	Called bool
	RetErr error
}

func (*TestInvoker) Invoke

func (i *TestInvoker) Invoke(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, opts ...grpc.CallOption) error

type TestableObserverVec

type TestableObserverVec struct {
	Observations []*testableObserver
	prometheus.ObserverVec
}

testableObserverVec allows us to assert which observations are being made with which labels.

func (*TestableObserverVec) With

Jump to

Keyboard shortcuts

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