srvgrpc

package
v0.12.3 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

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

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

Route specifies the method label for RequestDurationSeconds.

func (*RequestDurationSeconds) Service added in v0.9.0

Service specifies the service label for RequestDurationSeconds.

func (*RequestDurationSeconds) Status added in v0.12.0

Status specifies the status label for RequestDurationSeconds.

Jump to

Keyboard shortcuts

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