instrument

package
v0.0.0-...-1273577 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2019 License: MIT Imports: 4 Imported by: 0

README

instrument

under development.

Usage

import (
	"github.com/mercari/go-grpc-interceptor/instrument"
)

func main() {
	uIntOpt := grpc.UnaryInterceptor(instrument.UnaryServerInterceptor)
	sIntOpt := grpc.StreamInterceptor(instrument.StreamServerInterceptor)
	grpc.NewServer(uIntOpt, sIntOpt)
}

Built-in instrumentation

Prometheus
import (
	"github.com/mercari/go-grpc-interceptor/instrument/prometheus"
)
metrics
  • grpc_calls_total (counter)
  • The total number of gRPC calls
  • grpc_calls_errors (counter)
  • The total number of gRPC calls that returned error
  • grpc_calls_duration (summary)
  • Duration of gRPC calls
  • optional: Call EnableDurationSummary To enable this metric.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InstallInstrumentor

func InstallInstrumentor(i Instrumentor)

func StreamServerInterceptor

func StreamServerInterceptor(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) (err error)

func UnaryServerInterceptor

func UnaryServerInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error)

Types

type Instrumentor

type Instrumentor func(MethodCall)

type MethodCall

type MethodCall struct {
	Context     context.Context
	StartedAt   time.Time
	Duration    time.Duration
	FullMethod  string
	Service     string
	Method      string
	ServerInfo  interface{}
	IsStreaming bool
	Error       error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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