tracingmw

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package tracingmw allows setting and tracing a request by injecting an id as part of it's headers, when dealing with HTTP, or it's context, when dealing with GRPC.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNewRequestID happens when the application failed to generate a new
	// request id
	ErrNewRequestID = status.Error(codes.InvalidArgument, "request id could not be generated")

	// ErrMetadataMissing happens when there is no metadata with the request
	ErrMetadataMissing = status.Error(codes.InvalidArgument, "metadata missing")
)

Functions

func ContextWithRequestID

func ContextWithRequestID(ctx context.Context, rid string) context.Context

ContextWithRequestID takes a context and an *http.Request and returns a new context with the RequestID.

func EnsureRequestID

func EnsureRequestID(next http.Handler) http.Handler

EnsureRequestID will create a Request ID header if one is not found

func InterceptServerRequestID

func InterceptServerRequestID(ctx context.Context) (string, error)

InterceptServerRequestID will derive a request id from the context

func RequestIDFromContext

func RequestIDFromContext(ctx context.Context) string

RequestIDFromContext extracts the RequestID from the supplied context.

func StreamServerInterceptor

func StreamServerInterceptor(srv interface{}, ss grpc.ServerStream, _ *grpc.StreamServerInfo, handler grpc.StreamHandler) error

StreamServerInterceptor is a gRPC server-side streaming interceptor that checks that there is a request ID and ensures one gets set

func UnaryServerInterceptor

func UnaryServerInterceptor(ctx context.Context, req interface{}, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)

UnaryServerInterceptor is a gRPC server-side unary interceptor that checks that there is a request ID and ensures one gets set

Types

This section is empty.

Jump to

Keyboard shortcuts

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