handlers

package
v0.0.0-...-57ec133 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddSegmentToContext

func AddSegmentToContext(seg *segment.Segment, ctx context.Context) context.Context

AddSegmentToContext adds a segment reference to a context.Context instance.

func GRPCClientUnaryInterceptor

func GRPCClientUnaryInterceptor(
	ctx context.Context,
	method string,
	req interface{},
	reply interface{},
	cc *grpc.ClientConn,
	invoker grpc.UnaryInvoker,
	opts ...grpc.CallOption,
) error

GRPCClientUnaryInterceptor is a gRPC unary interceptor for tracing outbound gRPC requests

func GRPCServerUnaryInterceptor

func GRPCServerUnaryInterceptor(name string) func(
	ctx context.Context,
	req interface{},
	info *grpc.UnaryServerInfo,
	handler grpc.UnaryHandler,
) (interface{}, error)

GRPCServerUnaryInterceptor is a gRPC unary interceptor for tracing inbound gRPC requests.

func GetSegmentFromContext

func GetSegmentFromContext(ctx context.Context) (*segment.Segment, error)

GetSegmentFromContext retrieves a segment from a context.Context instance.

func NewGRPCClientConn

func NewGRPCClientConn(
	target string,
	opts ...grpc.DialOption,
) (*grpc.ClientConn, error)

NewGRPCClientConn creates a new gRPC client connection with a unary interceptor that performs traces of gRPC requests.

func NewHTTPClient

func NewHTTPClient(seg *segment.Segment) *http.Client

NewHTTPClient creates a new HTTP client for a segment.

func NewHTTPInterceptor

func NewHTTPInterceptor(seg *segment.Segment) http.RoundTripper

NewHTTPInterceptor creates a new HTTPInterceptor.

func SetSegmentCacheDuration

func SetSegmentCacheDuration(duration time.Duration)

SetSegmentCacheDuration updates the duration of segments in in-memory cache

Types

type HTTPInterceptor

type HTTPInterceptor struct {
	// contains filtered or unexported fields
}

HTTPInterceptor represents an http.RoundTripper that also performs tracing of requests by creating subsegments of the segment.

func (HTTPInterceptor) RoundTrip

func (h HTTPInterceptor) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements http.RoundTripper interface. Adds a new subsegment, adds trace header to HTTP requests, performs the requests, and records remote response data.

Jump to

Keyboard shortcuts

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