srvgrpc

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 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

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

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

func NewRequestDurationSeconds(histogram metrics.Histogram) *RequestDurationSeconds

NewRequestDurationSeconds returns a new RequestDurationSeconds instance.

func (*RequestDurationSeconds) Module

Module specifies the module label for RequestDurationSeconds.

func (RequestDurationSeconds) Observe

func (r RequestDurationSeconds) Observe(duration time.Duration)

Observe records the time taken to process the request.

func (*RequestDurationSeconds) Route

Route specifies the method label for RequestDurationSeconds.

func (*RequestDurationSeconds) Service

Service specifies the service label for RequestDurationSeconds.

func (*RequestDurationSeconds) Status

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