Documentation ¶
Overview ¶
Package rkgrpcctx provides utility functions deal with metadata in RPC context
Index ¶
- func AddHeaderToClient(ctx context.Context, key, value string)
- func EndTraceSpan(ctx context.Context, span trace.Span, success bool)
- func GetCursor(ctx context.Context) *rkcursor.Cursor
- func GetEntryName(ctx context.Context) string
- func GetEvent(ctx context.Context) rkquery.Event
- func GetIncomingHeaders(ctx context.Context) metadata.MD
- func GetJwtToken(ctx context.Context) *jwt.Token
- func GetLogger(ctx context.Context) *zap.Logger
- func GetRequestId(ctx context.Context) string
- func GetTraceId(ctx context.Context) string
- func GetTraceSpan(ctx context.Context) trace.Span
- func GetTracer(ctx context.Context) trace.Tracer
- func GetTracerPropagator(ctx context.Context) propagation.TextMapPropagator
- func GetTracerProvider(ctx context.Context) trace.TracerProvider
- func GormCtx(ctx context.Context) context.Context
- func InjectSpanToHttpRequest(ctx context.Context, req *http.Request)
- func InjectSpanToNewContext(ctx context.Context) context.Context
- func NewTraceSpan(ctx context.Context, name string) trace.Span
- func SetPointerCreator(creator rkcursor.PointerCreator)
- type GrpcMetadataCarrier
- type WrappedServerStream
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddHeaderToClient ¶
AddHeaderToClient Headers that would be sent to client.
func EndTraceSpan ¶
EndTraceSpan End span
func GetEntryName ¶
GetEntryName Extract the call-scoped entry name.
func GetIncomingHeaders ¶
GetIncomingHeaders Extract call-scoped incoming headers
func GetJwtToken ¶
GetJwtToken return jwt.Token if exists
func GetRequestId ¶
GetRequestId Get request id in outgoing metadata.
func GetTraceSpan ¶
GetTraceSpan Extract the call-scoped span from context.
func GetTracerPropagator ¶
func GetTracerPropagator(ctx context.Context) propagation.TextMapPropagator
GetTracerPropagator Extract the call-scoped span processor from middleware.
func GetTracerProvider ¶
func GetTracerProvider(ctx context.Context) trace.TracerProvider
GetTracerProvider Extract the call-scoped tracer provider from context.
func InjectSpanToHttpRequest ¶
InjectSpanToHttpRequest Inject current trace information into http request
func InjectSpanToNewContext ¶
InjectSpanToNewContext Inject current trace information into context
func NewTraceSpan ¶
NewTraceSpan Start a new span
func SetPointerCreator ¶ added in v2.2.16
func SetPointerCreator(creator rkcursor.PointerCreator)
SetPointerCreator override rkcursor.PointerCreator
Types ¶
type GrpcMetadataCarrier ¶
GrpcMetadataCarrier Grpc metadata carrier which will carries tracing info into grpc metadata to server side.
func (*GrpcMetadataCarrier) Get ¶
func (carrier *GrpcMetadataCarrier) Get(key string) string
Get value with key from grpc metadata.
func (*GrpcMetadataCarrier) Keys ¶
func (carrier *GrpcMetadataCarrier) Keys() []string
Keys List keys in grpc metadata.
func (*GrpcMetadataCarrier) Set ¶
func (carrier *GrpcMetadataCarrier) Set(key string, value string)
Set value with key into grpc metadata.
type WrappedServerStream ¶
type WrappedServerStream struct { grpc.ServerStream // WrappedContext is the wrapper's own Context. You can assign it. WrappedContext context.Context }
WrappedServerStream is a thin wrapper around grpc.ServerStream that allows modifying context.
func WrapServerStream ¶
func WrapServerStream(stream grpc.ServerStream) *WrappedServerStream
WrapServerStream returns a ServerStream that has the ability to overwrite context.
func (*WrappedServerStream) Context ¶
func (w *WrappedServerStream) Context() context.Context
Context returns the wrapper's WrappedContext, overwriting the nested grpc.ServerStream.Context()