Package apmgrpc provides interceptors for tracing gRPC.
IgnoreNone is a RequestIgnorerFunc which ignores no requests.
NewUnaryClientInterceptor returns a grpc.UnaryClientInterceptor that traces gRPC requests with the given options.
The interceptor will trace spans with the "grpc" type for each request made, for any client method presented with a context containing a sampled apm.Transaction.
NewUnaryServerInterceptor returns a grpc.UnaryServerInterceptor that traces gRPC requests with the given options.
The interceptor will trace transactions with the "grpc" type for each incoming request. The transaction will be added to the context, so server methods can use apm.StartSpan with the provided context.
By default, the interceptor will trace with apm.DefaultTracer, and will not recover any panics. Use WithTracer to specify an alternative tracer, and WithRecovery to enable panic recovery.
type ClientOption func(*clientOptions)
ClientOption sets options for client-side tracing.
RequestIgnorerFunc is the type of a function for use in WithServerRequestIgnorer.
DefaultServerRequestIgnorer returns the default RequestIgnorer to use in handlers.
NewRegexpRequestIgnorer returns a RequestIgnorerFunc which matches requests' URLs against re. Note that for server requests, typically only Path and possibly RawQuery will be set, so the regular expression should take this into account.
type ServerOption func(*serverOptions)
ServerOption sets options for server-side tracing.
WithRecovery returns a ServerOption which enables panic recovery in the gRPC server interceptor.
The interceptor will report panics as errors to Elastic APM, but unless this is enabled, they will still cause the server to be terminated. With recovery enabled, panics will be translated to gRPC errors with the code gprc/codes.Internal.
WithServerRequestIgnorer returns a ServerOption which sets r as the function to use to determine whether or not a server request should be ignored. If r is nil, all requests will be reported.
WithTracer returns a ServerOption which sets t as the tracer to use for tracing server requests.