otelgrpc – go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc Index | Examples | Files

package otelgrpc

import "go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"

Index

Examples

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

Code:

{
	_, _ = grpc.Dial("localhost", grpc.WithStreamInterceptor(StreamClientInterceptor()))
}

func StreamServerInterceptor

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

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

Example

Code:

{
	_ = grpc.NewServer(grpc.StreamInterceptor(StreamServerInterceptor()))
}

func UnaryClientInterceptor

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

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

Example

Code:

{
	_, _ = grpc.Dial("localhost", grpc.WithUnaryInterceptor(UnaryClientInterceptor()))
}

func UnaryServerInterceptor

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

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

Example

Code:

{
	_ = grpc.NewServer(grpc.UnaryInterceptor(UnaryServerInterceptor()))
}

Types

type Option

type Option interface {
	Apply(*config)
}

Option applies an option value for a config.

func WithPropagators

func WithPropagators(p otel.TextMapPropagator) Option

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

func WithTracerProvider

func WithTracerProvider(tp trace.TracerProvider) Option

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

Source Files

grpctrace.go interceptor.go

Version
v0.13.0
Published
Oct 10, 2020
Platform
js/wasm
Imports
16 packages
Last checked
8 hours ago

Tools for package owners.