grpc

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2018 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package grpc contains OpenCensus stats and trace integrations with gRPC.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClientStatsHandler

func NewClientStatsHandler() stats.Handler

NewClientStatsHandler enables OpenCensus stats and trace for gRPC clients. If these features need to be indiviually turned on, see grpcstats and grpctrace packages.

Example
package main

import (
	"log"

	ocgrpc "go.opencensus.io/plugin/grpc"
	"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 connection to the server with the OpenCensus
	// stats handler to enable stats and tracing.
	conn, err := grpc.Dial("address", grpc.WithStatsHandler(ocgrpc.NewClientStatsHandler()))
	if err != nil {
		log.Fatalf("did not connect: %v", err)
	}
	defer conn.Close()
}
Output:

func NewServerStatsHandler

func NewServerStatsHandler() stats.Handler

NewServerStatsHandler enables OpenCensus stats and trace for gRPC servers. If these features need to be indiviually turned on, see grpcstats and grpctrace packages.

Example
package main

import (
	"log"

	ocgrpc "go.opencensus.io/plugin/grpc"
	"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 and tracing.
	s := grpc.NewServer(grpc.StatsHandler(ocgrpc.NewServerStatsHandler()))
	_ = s // use s
}
Output:

Types

This section is empty.

Directories

Path Synopsis
Package grpcstats provides OpenCensus stats support for gRPC clients and servers.
Package grpcstats provides OpenCensus stats support for gRPC clients and servers.
Package grpctrace is a package to assist with tracing incoming and outgoing gRPC requests.
Package grpctrace is a package to assist with tracing incoming and outgoing gRPC requests.

Jump to

Keyboard shortcuts

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