grpcstats

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2017 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package grpcstats provides OpenCensus stats support for gRPC clients and servers.

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	// Available client measures
	RPCClientErrorCount       *stats.MeasureInt64
	RPCClientRoundTripLatency *stats.MeasureFloat64
	RPCClientRequestBytes     *stats.MeasureInt64
	RPCClientResponseBytes    *stats.MeasureInt64
	RPCClientStartedCount     *stats.MeasureInt64
	RPCClientFinishedCount    *stats.MeasureInt64
	RPCClientRequestCount     *stats.MeasureInt64
	RPCClientResponseCount    *stats.MeasureInt64

	// Predefined client views
	RPCClientErrorCountView       *stats.View
	RPCClientRoundTripLatencyView *stats.View
	RPCClientRequestBytesView     *stats.View
	RPCClientResponseBytesView    *stats.View
	RPCClientRequestCountView     *stats.View
	RPCClientResponseCountView    *stats.View

	RPCClientRoundTripLatencyMinuteView *stats.View
	RPCClientRequestBytesMinuteView     *stats.View
	RPCClientResponseBytesMinuteView    *stats.View
	RPCClientErrorCountMinuteView       *stats.View
	RPCClientStartedCountMinuteView     *stats.View
	RPCClientFinishedCountMinuteView    *stats.View
	RPCClientRequestCountMinuteView     *stats.View
	RPCClientResponseCountMinuteView    *stats.View

	RPCClientRoundTripLatencyHourView *stats.View
	RPCClientRequestBytesHourView     *stats.View
	RPCClientResponseBytesHourView    *stats.View
	RPCClientErrorCountHourView       *stats.View
	RPCClientStartedCountHourView     *stats.View
	RPCClientFinishedCountHourView    *stats.View
	RPCClientRequestCountHourView     *stats.View
	RPCClientResponseCountHourView    *stats.View
)

The following variables are measures and views made available for gRPC clients. Client connection needs to use a ClientStatsHandler in order to enable collection.

View Source
var (
	// Available server measures
	RPCServerErrorCount        *stats.MeasureInt64
	RPCServerServerElapsedTime *stats.MeasureFloat64
	RPCServerRequestBytes      *stats.MeasureInt64
	RPCServerResponseBytes     *stats.MeasureInt64
	RPCServerStartedCount      *stats.MeasureInt64
	RPCServerFinishedCount     *stats.MeasureInt64
	RPCServerRequestCount      *stats.MeasureInt64
	RPCServerResponseCount     *stats.MeasureInt64

	// Predefined server views
	RPCServerErrorCountView        *stats.View
	RPCServerServerElapsedTimeView *stats.View
	RPCServerRequestBytesView      *stats.View
	RPCServerResponseBytesView     *stats.View
	RPCServerRequestCountView      *stats.View
	RPCServerResponseCountView     *stats.View

	RPCServerServerElapsedTimeMinuteView *stats.View
	RPCServerRequestBytesMinuteView      *stats.View
	RPCServerResponseBytesMinuteView     *stats.View
	RPCServerErrorCountMinuteView        *stats.View
	RPCServerStartedCountMinuteView      *stats.View
	RPCServerFinishedCountMinuteView     *stats.View
	RPCServerRequestCountMinuteView      *stats.View
	RPCServerResponseCountMinuteView     *stats.View

	RPCServerServerElapsedTimeHourView *stats.View
	RPCServerRequestBytesHourView      *stats.View
	RPCServerResponseBytesHourView     *stats.View
	RPCServerErrorCountHourView        *stats.View
	RPCServerStartedCountHourView      *stats.View
	RPCServerFinishedCountHourView     *stats.View
	RPCServerRequestCountHourView      *stats.View
	RPCServerResponseCountHourView     *stats.View
)

The following variables are measures and views made available for gRPC clients. Server needs to use a ServerStatsHandler in order to enable collection.

Functions

This section is empty.

Types

type ClientStatsHandler

type ClientStatsHandler struct{}

ClientStatsHandler is a stats.Handler implementation that collects stats for a gRPC client. Predefined measures and views can be used to access the collected data.

func NewClientStatsHandler

func NewClientStatsHandler() *ClientStatsHandler

NewClientStatsHandler returns a stats.Handler implementation that collects stats for a gRPC client. Predefined measures and views can be used to access the collected data.

Example
package main

import (
	"log"

	"go.opencensus.io/plugin/grpc/grpcstats"
	"google.golang.org/grpc"
)

func main() {
	// Subscribe to collect client request count.
	if err := grpcstats.RPCClientRequestCountView.Subscribe(); err != nil {
		log.Fatal(err)
	}

	// Set up a new client connection with the OpenCensus
	// stats handler to enable stats collection from the views.
	conn, err := grpc.Dial("address", grpc.WithStatsHandler(grpcstats.NewClientStatsHandler()))
	if err != nil {
		log.Fatalf("did not connect: %v", err)
	}
	defer conn.Close()
}
Output:

func (*ClientStatsHandler) HandleConn

func (h *ClientStatsHandler) HandleConn(ctx context.Context, s stats.ConnStats)

HandleConn processes the connection events.

func (*ClientStatsHandler) HandleRPC

func (h *ClientStatsHandler) HandleRPC(ctx context.Context, s stats.RPCStats)

HandleRPC processes the RPC events.

func (*ClientStatsHandler) TagConn

TagConn adds connection related data to the given context and returns the new context.

func (*ClientStatsHandler) TagRPC

TagRPC gets the tag.Map populated by the application code, serializes its tags into the GRPC metadata in order to be sent to the server.

type ServerStatsHandler

type ServerStatsHandler struct{}

ServerStatsHandler is a stats.Handler implementation that collects stats for a gRPC server. Predefined measures and views can be used to access the collected data.

func NewServerStatsHandler

func NewServerStatsHandler() *ServerStatsHandler

NewServerStatsHandler returns a stats.Handler implementation that collects stats for a gRPC server. Predefined measures and views can be used to access the collected data.

Example
package main

import (
	"log"

	"go.opencensus.io/plugin/grpc/grpcstats"
	"google.golang.org/grpc"
)

func main() {
	// Subscribe to collect server request count.
	if err := grpcstats.RPCServerRequestCountView.Subscribe(); err != nil {
		log.Fatal(err)
	}

	// Set up a new server with the OpenCensus stats handler
	// to enable stats collection from the views.
	s := grpc.NewServer(grpc.StatsHandler(grpcstats.NewClientStatsHandler()))
	_ = s // use s
}
Output:

func (*ServerStatsHandler) HandleConn

func (h *ServerStatsHandler) HandleConn(ctx context.Context, s stats.ConnStats)

HandleConn processes the connection events.

func (*ServerStatsHandler) HandleRPC

func (h *ServerStatsHandler) HandleRPC(ctx context.Context, s stats.RPCStats)

HandleRPC processes the RPC events.

func (*ServerStatsHandler) TagConn

TagConn adds connection related data to the given context and returns the new context.

func (*ServerStatsHandler) TagRPC

TagRPC gets the metadata from gRPC context, extracts the encoded tags from it and creates a new tag.Map and puts them into the returned context.

Jump to

Keyboard shortcuts

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