Documentation
¶
Overview ¶
Package usagemetrics defines middleware that adds usage data (e.g. dispatch counts) to the response.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // DispatchedCountLabels are the labels that DispatchedCountHistogram will // have by default. DispatchedCountLabels = []string{"method", "cached"} // DispatchedCountHistogram is the metric that SpiceDB uses to keep track // of the number of downstream dispatches that are performed to answer a // single query. DispatchedCountHistogram = promauto.NewHistogramVec(prometheus.HistogramOpts{ Namespace: "spicedb", Subsystem: "services", Name: "dispatches", Help: "Histogram of cluster dispatches performed by the instance.", Buckets: []float64{1, 5, 10, 25, 50, 100, 250}, }, DispatchedCountLabels) )
Functions ¶
func FromContext ¶
func FromContext(ctx context.Context) *dispatch.ResponseMeta
FromContext returns any metadata that was stored in the context.
This is useful for testing that a handler is properly setting the context.
func SetInContext ¶
func SetInContext(ctx context.Context, metadata *dispatch.ResponseMeta)
SetInContext should be called in a gRPC handler to correctly set the response metadata for the dispatched request.
func StreamServerInterceptor ¶
func StreamServerInterceptor() grpc.StreamServerInterceptor
StreamServerInterceptor implements a gRPC Middleware for reporting usage metrics in both the trailer of the request, as well as to the registered prometheus metrics
func UnaryServerInterceptor ¶
func UnaryServerInterceptor() grpc.UnaryServerInterceptor
UnaryServerInterceptor implements a gRPC Middleware for reporting usage metrics in both the trailer of the request, as well as to the registered prometheus metrics.
Types ¶
This section is empty.