Documentation ¶
Index ¶
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 { // Histogram is the underlying histogram of RequestDurationSeconds. Histogram metrics.Histogram // contains filtered or unexported fields }
RequestDurationSeconds is a Histogram that measures the request latency.
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(seconds float64)
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.