otelgrpc

package module
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2021 License: Apache-2.0 Imports: 18 Imported by: 963

Documentation

Index

Examples

Constants

View Source
const (

	// GRPCStatusCodeKey is convention for numeric status code of a gRPC request.
	GRPCStatusCodeKey = label.Key("rpc.grpc.status_code")
)

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(opts ...Option) grpc.StreamClientInterceptor

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

Example
_, _ = grpc.Dial("localhost", grpc.WithStreamInterceptor(StreamClientInterceptor()))
Output:

func StreamServerInterceptor

func StreamServerInterceptor(opts ...Option) grpc.StreamServerInterceptor

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

Example
_ = grpc.NewServer(grpc.StreamInterceptor(StreamServerInterceptor()))
Output:

func UnaryClientInterceptor

func UnaryClientInterceptor(opts ...Option) grpc.UnaryClientInterceptor

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

Example
_, _ = grpc.Dial("localhost", grpc.WithUnaryInterceptor(UnaryClientInterceptor()))
Output:

func UnaryServerInterceptor

func UnaryServerInterceptor(opts ...Option) grpc.UnaryServerInterceptor

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

Example
_ = grpc.NewServer(grpc.UnaryInterceptor(UnaryServerInterceptor()))
Output:

Types

type Option

type Option interface {
	Apply(*config)
}

Option applies an option value for a config.

func WithPropagators

func WithPropagators(p propagation.TextMapPropagator) Option

WithPropagators returns an Option to use the Propagators when extracting and injecting trace context from requests.

func WithTracerProvider added in v0.13.0

func WithTracerProvider(tp trace.TracerProvider) Option

WithTracerProvider returns an Option to use the TracerProvider when creating a Tracer.

Directories

Path Synopsis
example module
test module

Jump to

Keyboard shortcuts

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