grpc

package module
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2020 License: Apache-2.0 Imports: 16 Imported by: 6

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Extract

func Extract(ctx context.Context, metadata *metadata.MD, opts ...Option) ([]label.KeyValue, trace.SpanContext)

Extract returns the correlation context and span context that another service encoded in the gRPC metadata object with Inject. This function is meant to be used on incoming requests.

func Inject

func Inject(ctx context.Context, metadata *metadata.MD, opts ...Option)

Inject injects correlation context and span context into the gRPC metadata object. This function is meant to be used on outgoing requests.

func StreamClientInterceptor

func StreamClientInterceptor(tracer trace.Tracer, opts ...Option) grpc.StreamClientInterceptor

StreamClientInterceptor returns a grpc.StreamClientInterceptor suitable for use in a grpc.Dial call.

Example
tracer := global.Tracer("client-instrumentation")
_, _ = grpc.Dial(
	"localhost",
	grpc.WithStreamInterceptor(StreamClientInterceptor(tracer)),
)
Output:

func StreamServerInterceptor

func StreamServerInterceptor(tracer trace.Tracer, opts ...Option) grpc.StreamServerInterceptor

StreamServerInterceptor returns a grpc.StreamServerInterceptor suitable for use in a grpc.NewServer call.

Example
tracer := global.Tracer("server-instrumentation")
_ = grpc.NewServer(
	grpc.StreamInterceptor(StreamServerInterceptor(tracer)),
)
Output:

func UnaryClientInterceptor

func UnaryClientInterceptor(tracer trace.Tracer, opts ...Option) grpc.UnaryClientInterceptor

UnaryClientInterceptor returns a grpc.UnaryClientInterceptor suitable for use in a grpc.Dial call.

Example
tracer := global.Tracer("client-instrumentation")
_, _ = grpc.Dial(
	"localhost",
	grpc.WithUnaryInterceptor(UnaryClientInterceptor(tracer)),
)
Output:

func UnaryServerInterceptor

func UnaryServerInterceptor(tracer trace.Tracer, opts ...Option) grpc.UnaryServerInterceptor

UnaryServerInterceptor returns a grpc.UnaryServerInterceptor suitable for use in a grpc.NewServer call.

Example
tracer := global.Tracer("server-instrumentation")
_ = grpc.NewServer(
	grpc.UnaryInterceptor(UnaryServerInterceptor(tracer)),
)
Output:

Types

type Option

type Option func(*config)

Option is a function that allows configuration of the grpc Extract() and Inject() functions

func WithPropagators

func WithPropagators(props propagation.Propagators) Option

WithPropagators sets the propagators to use for Extraction and Injection

Directories

Path Synopsis
example module
otelgrpc module
example Module
test Module

Jump to

Keyboard shortcuts

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