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
- Variables
- func InitializeApiCollectors(r prometheus.Registerer, v prometheus.ObserverVec, ...)
- func InitializeGrpcCollectorsFromPackage(r prometheus.Registerer, v prometheus.ObserverVec, ...)
- func InitializeGrpcCollectorsFromServer(r prometheus.Registerer, v prometheus.ObserverVec, server *grpc.Server, ...)
- func NewStatsHandler(ctx context.Context, o prometheus.ObserverVec) (*statsHandler, error)
- func SplitMethodName(fullMethodName string) (string, string)
- func StatusFromError(err error) *status.Status
- type TestInvoker
- type TestableObserverVec
Constants ¶
const ( LabelGrpcService = "grpc_service" LabelGrpcMethod = "grpc_method" LabelGrpcCode = "grpc_code" LabelHttpPath = "path" LabelHttpMethod = "method" LabelHttpCode = "code" )
Variables ¶
var ( ListGrpcLabels = []string{LabelGrpcService, LabelGrpcMethod, LabelGrpcCode} ListHttpLabels = []string{LabelHttpPath, LabelHttpMethod, LabelHttpCode} )
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 ¶
SplitMethodName returns the service and the method name when given the full method name as provided by the grpc request handler.
func StatusFromError ¶
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 ¶
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 ¶
func (v *TestableObserverVec) With(l prometheus.Labels) prometheus.Observer