promgrpc

package module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2017 License: MIT Imports: 8 Imported by: 1

README

promgrpc Build Status

GoDoc

Library allows to monitor gRPC based client and server applications.

Metrics

Client
  • grpc_client_errors_total
  • grpc_client_received_messages_total
  • grpc_client_reconnects_total
  • grpc_client_request_duration_microseconds
  • grpc_client_request_duration_microseconds_sum
  • grpc_client_request_duration_microseconds_count
  • grpc_client_requests_total
  • grpc_client_send_messages_total
Server
  • grpc_server_errors_total
  • grpc_server_received_messages_total
  • grpc_server_request_duration_microseconds
  • grpc_server_request_duration_microseconds_sum
  • grpc_server_request_duration_microseconds_count
  • grpc_server_requests_total
  • grpc_server_send_messages_total

Example

inter := promgrpc.NewInterceptor()
dop := []grpc.DialOption{
	grpc.WithDialer(inter.Dialer(func(addr string, timeout time.Duration) (net.Conn, error) {
		return net.DialTimeout("tcp", addr, timeout)
	})),
	grpc.WithStreamInterceptor(inter.StreamClient()),
	grpc.WithUnaryInterceptor(inter.UnaryClient()),
}

sop := []grpc.ServerOption{
	grpc.StreamInterceptor(inter.StreamServer()),
	grpc.UnaryInterceptor(inter.UnaryServer()),
}

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterInterceptor added in v0.3.0

func RegisterInterceptor(s *grpc.Server, i *Interceptor) (err error)

Types

type Interceptor

type Interceptor struct {
	// contains filtered or unexported fields
}

Interceptor ...

func NewInterceptor

func NewInterceptor(opts InterceptorOpts) *Interceptor

NewInterceptor ...

func (*Interceptor) ClientRegistry added in v0.4.0

func (i *Interceptor) ClientRegistry() *prometheus.Registry

ClientRegistry returns the prometheus registry with all client metrics

func (*Interceptor) Dialer

func (i *Interceptor) Dialer(f func(string, time.Duration) (net.Conn, error)) func(string, time.Duration) (net.Conn, error)

Dialer ...

Example
package main

import (
	"net"
	"time"

	"github.com/piotrkowalczuk/promgrpc"
	"google.golang.org/grpc"
)

func main() {
	interceptor := promgrpc.NewInterceptor(promgrpc.InterceptorOpts{})

	var opts []grpc.DialOption
	opts = append(opts, grpc.WithDialer(interceptor.Dialer(func(addr string, timeout time.Duration) (net.Conn, error) {
		return net.DialTimeout("tcp", addr, timeout)
	})))
}
Output:

func (*Interceptor) ServerRegistry added in v0.4.0

func (i *Interceptor) ServerRegistry() *prometheus.Registry

ServerRegistry returns the prometheus registry with all server metrics

func (*Interceptor) StreamClient

func (i *Interceptor) StreamClient() grpc.StreamClientInterceptor

StreamClient ...

func (*Interceptor) StreamServer

func (i *Interceptor) StreamServer() grpc.StreamServerInterceptor

StreamServer ...

func (*Interceptor) UnaryClient

func (i *Interceptor) UnaryClient() grpc.UnaryClientInterceptor

UnaryClient ...

func (*Interceptor) UnaryServer

func (i *Interceptor) UnaryServer() grpc.UnaryServerInterceptor

UnaryServer ...

type InterceptorOpts added in v0.5.0

type InterceptorOpts struct {
	// TrackPeers allow to turn on peer tracking.
	// For more info about peers please visit https://godoc.org/google.golang.org/grpc/peer.
	TrackPeers bool
}

InterceptorOpts ...

Jump to

Keyboard shortcuts

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