grpctrace

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: 7 Imported by: 0

Documentation

Overview

Package grpctrace is a package to assist with tracing incoming and outgoing gRPC requests.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientStatsHandler

type ClientStatsHandler struct{}

ClientStatsHandler is a an implementation of grpc.StatsHandler that can be passed to grpc.Dial using grpc.WithStatsHandler to enable trace context propagation and automatic span creation for outgoing gRPC requests.

func NewClientStatsHandler

func NewClientStatsHandler() *ClientStatsHandler

NewClientStatsHandler returns a StatsHandler that can be passed to grpc.Dial using grpc.WithStatsHandler to enable trace context propagation and automatic span creation for outgoing gRPC requests.

Example
package main

import (
	"log"

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

func main() {
	// Set up a new client connection with the OpenCensus
	// stats handler to enable tracing for the outgoing requests.
	conn, err := grpc.Dial("address", grpc.WithStatsHandler(grpctrace.NewClientStatsHandler()))
	if err != nil {
		log.Fatalf("did not connect: %v", err)
	}
	defer conn.Close()
}
Output:

func (*ClientStatsHandler) HandleConn

func (c *ClientStatsHandler) HandleConn(ctx context.Context, cs stats.ConnStats)

HandleConn is a no-op for this StatsHandler.

func (*ClientStatsHandler) HandleRPC

func (c *ClientStatsHandler) HandleRPC(ctx context.Context, rs stats.RPCStats)

HandleRPC processes the RPC stats, adding information to the current trace span.

func (*ClientStatsHandler) TagConn

TagConn is a no-op for this StatsHandler.

func (*ClientStatsHandler) TagRPC

TagRPC creates a new trace span for the client side of the RPC.

It returns ctx with the new trace span added and a serialization of the SpanContext added to the outgoing gRPC metadata.

type ServerStatsHandler

type ServerStatsHandler struct{}

ServerStatsHandler is a an implementation of grpc.StatsHandler that can be passed to grpc.NewServer using grpc.StatsHandler to enable trace context propagation and automatic span creation for incoming gRPC requests..

func NewServerStatsHandler

func NewServerStatsHandler() *ServerStatsHandler

NewServerStatsHandler returns a StatsHandler that can be passed to grpc.NewServer using grpc.StatsHandler to enable trace context propagation and automatic span creation for incoming gRPC requests.

Example
package main

import (
	"go.opencensus.io/plugin/grpc/grpctrace"
	"google.golang.org/grpc"
)

func main() {
	// Set up a new client connection with the OpenCensus
	// stats handler to enable tracing for the incoming requests.
	s := grpc.NewServer(grpc.StatsHandler(grpctrace.NewServerStatsHandler()))
	_ = s // use s
}
Output:

func (*ServerStatsHandler) HandleConn

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

HandleConn is a no-op for this StatsHandler.

func (*ServerStatsHandler) HandleRPC

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

HandleRPC processes the RPC stats, adding information to the current trace span.

func (*ServerStatsHandler) TagConn

TagConn is a no-op for this StatsHandler.

func (*ServerStatsHandler) TagRPC

TagRPC creates a new trace span for the server side of the RPC.

It checks the incoming gRPC metadata in ctx for a SpanContext, and if it finds one, uses that SpanContext as the parent context of the new span.

It returns ctx, with the new trace span added.

Jump to

Keyboard shortcuts

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