otgrpc

package
v0.0.0-...-d047bce Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpenTracingClientInterceptor

func OpenTracingClientInterceptor(tracer opentracing.Tracer) grpc.UnaryClientInterceptor

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

For example:

conn, err := grpc.Dial(
    address,
    ...,  // (existing DialOptions)
    grpc.WithUnaryInterceptor(otgrpc.OpenTracingClientInterceptor(tracer)))

All gRPC client spans will inject the OpenTracing SpanContext into the gRPC metadata; they will also look in the context.Context for an active in-process parent Span and establish a ChildOf reference if such a parent Span could be found.

func OpenTracingServerInterceptor

func OpenTracingServerInterceptor(tracer opentracing.Tracer) grpc.UnaryServerInterceptor

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

For example:

s := grpc.NewServer(
    ...,  // (existing ServerOptions)
    grpc.UnaryInterceptor(otgrpc.OpenTracingServerInterceptor(tracer)))

All gRPC server spans will look for an OpenTracing SpanContext in the gRPC metadata; if found, the server span will act as the ChildOf that RPC SpanContext.

Root or not, the server Span will be embedded in the context.Context for the application-specific gRPC handler(s) to access.

func SetSpanTags

func SetSpanTags(span opentracing.Span, err error, client bool)

SetSpanTags sets one or more tags on the given span according to the error.

Types

type Class

type Class string

A Class is a set of types of outcomes (including errors) that will often be handled in the same way.

const (
	Unknown Class = "0xx"
	// Success represents outcomes that achieved the desired results.
	Success Class = "2xx"
	// ClientError represents errors that were the client's fault.
	ClientError Class = "4xx"
	// ServerError represents errors that were the server's fault.
	ServerError Class = "5xx"
)

func ErrorClass

func ErrorClass(err error) Class

ErrorClass returns the class of the given error

Jump to

Keyboard shortcuts

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