Documentation
¶
Index ¶
- Constants
- Variables
- func Extract(ctx context.Context, md *metadata.MD, opts ...Option) (baggage.Baggage, trace.SpanContext)
- func Inject(ctx context.Context, md *metadata.MD, opts ...Option)
- func SemVersion() stringdeprecated
- func StreamClientInterceptor(opts ...Option) grpc.StreamClientInterceptor
- func StreamServerInterceptor(opts ...Option) grpc.StreamServerInterceptor
- func UnaryClientInterceptor(opts ...Option) grpc.UnaryClientInterceptor
- func UnaryServerInterceptor(opts ...Option) grpc.UnaryServerInterceptor
- func Version() string
- type Filter
- type InterceptorInfo
- type InterceptorType
- type Option
Examples ¶
Constants ¶
const ( // Name of message transmitted or received. RPCNameKey = attribute.Key("name") // Type of message transmitted or received. RPCMessageTypeKey = attribute.Key("message.type") // Identifier of message transmitted or received. RPCMessageIDKey = attribute.Key("message.id") // The compressed size of the message transmitted or received in bytes. RPCMessageCompressedSizeKey = attribute.Key("message.compressed_size") // The uncompressed size of the message transmitted or received in // bytes. RPCMessageUncompressedSizeKey = attribute.Key("message.uncompressed_size") )
Semantic conventions for attribute keys for gRPC.
const ( // GRPCStatusCodeKey is convention for numeric status code of a gRPC request. GRPCStatusCodeKey = attribute.Key("rpc.grpc.status_code") )
Variables ¶
var ( // Semantic convention for gRPC as the remoting system. RPCSystemGRPC = semconv.RPCSystemGRPC // Semantic convention for a message named message. RPCNameMessage = RPCNameKey.String("message") // Semantic conventions for RPC message types. RPCMessageTypeSent = RPCMessageTypeKey.String("SENT") RPCMessageTypeReceived = RPCMessageTypeKey.String("RECEIVED") )
Semantic conventions for common RPC attributes.
Functions ¶
func Extract ¶
func Extract(ctx context.Context, md *metadata.MD, opts ...Option) (baggage.Baggage, trace.SpanContext)
Extract returns the correlation context and span context that another service encoded in the gRPC metadata object with Inject. This function is meant to be used on incoming requests. Deprecated: Unnecessary public func.
func Inject ¶
Inject injects correlation context and span context into the gRPC metadata object. This function is meant to be used on outgoing requests. Deprecated: Unnecessary public func.
func SemVersion
deprecated
added in
v0.24.0
func StreamClientInterceptor ¶
func StreamClientInterceptor(opts ...Option) grpc.StreamClientInterceptor
StreamClientInterceptor returns a grpc.StreamClientInterceptor suitable for use in a grpc.Dial call.
Example ¶
_, _ = grpc.Dial("localhost", grpc.WithStreamInterceptor(StreamClientInterceptor()))
Output:
func StreamServerInterceptor ¶
func StreamServerInterceptor(opts ...Option) grpc.StreamServerInterceptor
StreamServerInterceptor returns a grpc.StreamServerInterceptor suitable for use in a grpc.NewServer call.
Example ¶
_ = grpc.NewServer(grpc.StreamInterceptor(StreamServerInterceptor()))
Output:
func UnaryClientInterceptor ¶
func UnaryClientInterceptor(opts ...Option) grpc.UnaryClientInterceptor
UnaryClientInterceptor returns a grpc.UnaryClientInterceptor suitable for use in a grpc.Dial call.
Example ¶
_, _ = grpc.Dial("localhost", grpc.WithUnaryInterceptor(UnaryClientInterceptor()))
Output:
func UnaryServerInterceptor ¶
func UnaryServerInterceptor(opts ...Option) grpc.UnaryServerInterceptor
UnaryServerInterceptor returns a grpc.UnaryServerInterceptor suitable for use in a grpc.NewServer call.
Example ¶
_ = grpc.NewServer(grpc.UnaryInterceptor(UnaryServerInterceptor()))
Output:
Types ¶
type Filter ¶ added in v0.35.0
type Filter func(*InterceptorInfo) bool
Filter is a predicate used to determine whether a given request in interceptor info should be traced. A Filter must return true if the request should be traced.
type InterceptorInfo ¶ added in v0.35.0
type InterceptorInfo struct { // Method is method name registered to UnaryClient and StreamClient Method string // UnaryServerInfo is the metadata for UnaryServer UnaryServerInfo *grpc.UnaryServerInfo // StreamServerInfo if the metadata for StreamServer StreamServerInfo *grpc.StreamServerInfo // Type is the type for interceptor Type InterceptorType }
InterceptorInfo is the union of some arguments to four types of gRPC interceptors.
type InterceptorType ¶ added in v0.35.0
type InterceptorType uint8
InterceptorType is the flag to define which gRPC interceptor the InterceptorInfo object is.
const ( // UndefinedInterceptor is the type for the interceptor information that is not // well initialized or categorized to other types. UndefinedInterceptor InterceptorType = iota // UnaryClient is the type for grpc.UnaryClient interceptor. UnaryClient // StreamClient is the type for grpc.StreamClient interceptor. StreamClient // UnaryServer is the type for grpc.UnaryServer interceptor. UnaryServer // StreamServer is the type for grpc.StreamServer interceptor. StreamServer )
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option applies an option value for a config.
func WithInterceptorFilter ¶ added in v0.35.0
WithInterceptorFilter returns an Option to use the request filter.
func WithMeterProvider ¶ added in v0.37.0
func WithMeterProvider(mp metric.MeterProvider) Option
WithMeterProvider returns an Option to use the MeterProvider when creating a Meter. If this option is not provide the global MeterProvider will be used.
func WithPropagators ¶
func WithPropagators(p propagation.TextMapPropagator) Option
WithPropagators returns an Option to use the Propagators when extracting and injecting trace context from requests.
func WithTracerProvider ¶ added in v0.13.0
func WithTracerProvider(tp trace.TracerProvider) Option
WithTracerProvider returns an Option to use the TracerProvider when creating a Tracer.