Documentation ¶
Index ¶
- Variables
- func Metrics(metrics *RequestDurationSeconds) grpc.UnaryServerInterceptor
- type HealthCheckModule
- type MetricsModule
- type RequestDurationSeconds
- func (r *RequestDurationSeconds) Module(module string) *RequestDurationSeconds
- func (r RequestDurationSeconds) Observe(duration time.Duration)
- func (r *RequestDurationSeconds) Route(route string) *RequestDurationSeconds
- func (r *RequestDurationSeconds) Service(service string) *RequestDurationSeconds
- func (r *RequestDurationSeconds) Status(status int) *RequestDurationSeconds
Constants ¶
This section is empty.
Variables ¶
var Trace = otgrpc.OpenTracingServerInterceptor
Trace is an alias of otgrpc.OpenTracingServerInterceptor. It is recommended to use the trace implementation in github.com/opentracing-contrib/go-grpc. This alias serves as a pointer to it.
Functions ¶
func Metrics ¶ added in v0.9.0
func Metrics(metrics *RequestDurationSeconds) grpc.UnaryServerInterceptor
Metrics is a unary interceptor for grpc package. It records the request duration in a histogram.
Types ¶
type HealthCheckModule ¶
type HealthCheckModule struct{}
HealthCheckModule defines a grpc provider for container.Container.
func (HealthCheckModule) ProvideGRPC ¶
func (h HealthCheckModule) ProvideGRPC(server *grpc.Server)
ProvideGRPC implements container.GRPCProvider
type MetricsModule ¶
type MetricsModule struct{}
MetricsModule exposes prometheus metrics. Here only provides a simple call, more complex use, please refer to github.com/grpc-ecosystem/go-grpc-prometheus.
Need to actively provide grpc.Server:
opts := []grpc.ServerOption{ grpc.UnaryInterceptor(grpc_prometheus.UnaryServerInterceptor), grpc.StreamInterceptor(grpc_prometheus.StreamServerInterceptor), } server = grpc.NewServer(opts...)
func (MetricsModule) ProvideGRPC ¶
func (m MetricsModule) ProvideGRPC(server *grpc.Server)
ProvideGRPC implements container.GRPCProvider
type RequestDurationSeconds ¶ added in v0.9.0
type RequestDurationSeconds struct {
// contains filtered or unexported fields
}
RequestDurationSeconds is a wrapper around a histogram that measures the request latency. The RequestDurationSeconds exposes label setters such as module, service and route. If a label is set more than once, the one set last will take precedence.
func NewRequestDurationSeconds ¶ added in v0.11.0
func NewRequestDurationSeconds(histogram metrics.Histogram) *RequestDurationSeconds
NewRequestDurationSeconds returns a new RequestDurationSeconds instance.
func (*RequestDurationSeconds) Module ¶ added in v0.9.0
func (r *RequestDurationSeconds) Module(module string) *RequestDurationSeconds
Module specifies the module label for RequestDurationSeconds.
func (RequestDurationSeconds) Observe ¶ added in v0.9.0
func (r RequestDurationSeconds) Observe(duration time.Duration)
Observe records the time taken to process the request.
func (*RequestDurationSeconds) Route ¶ added in v0.9.0
func (r *RequestDurationSeconds) Route(route string) *RequestDurationSeconds
Route specifies the method label for RequestDurationSeconds.
func (*RequestDurationSeconds) Service ¶ added in v0.9.0
func (r *RequestDurationSeconds) Service(service string) *RequestDurationSeconds
Service specifies the service label for RequestDurationSeconds.
func (*RequestDurationSeconds) Status ¶ added in v0.12.0
func (r *RequestDurationSeconds) Status(status int) *RequestDurationSeconds
Status specifies the status label for RequestDurationSeconds.