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 ¶
- Variables
- func ContextWithRequestID(ctx context.Context, rid string) context.Context
- func EnsureRequestID(next http.Handler) http.Handler
- func InterceptServerRequestID(ctx context.Context) (string, error)
- func RequestIDFromContext(ctx context.Context) string
- func StreamServerInterceptor(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, ...) error
- func UnaryServerInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, ...) (interface{}, error)
Constants ¶
This section is empty.
Variables ¶
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 ¶
ContextWithRequestID takes a context and an *http.Request and returns a new context with the RequestID.
func EnsureRequestID ¶
EnsureRequestID will create a Request ID header if one is not found
func InterceptServerRequestID ¶
InterceptServerRequestID will derive a request id from the context
func RequestIDFromContext ¶
RequestIDFromContext extracts the RequestID from the supplied context.
func StreamServerInterceptor ¶
func StreamServerInterceptor(srv interface{}, ss grpc.ServerStream, info *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{}, info *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.