apmgrpc

package module
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2021 License: Apache-2.0 Imports: 17 Imported by: 49

Documentation

Overview

Package apmgrpc provides interceptors for tracing gRPC.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IgnoreNone added in v1.4.0

func IgnoreNone(*grpc.UnaryServerInfo) bool

IgnoreNone is a RequestIgnorerFunc which ignores no requests.

func IgnoreNoneStream added in v1.12.0

func IgnoreNoneStream(*grpc.StreamServerInfo) bool

IgnoreNoneStream is a StreamIgnorerFunc which ignores no stream requests.

func NewStreamClientInterceptor added in v1.12.0

func NewStreamClientInterceptor(o ...ClientOption) grpc.StreamClientInterceptor

NewStreamClientInterceptor returns a grpc.UnaryClientInterceptor that traces gRPC requests with the given options.

The interceptor will trace spans with the "external.grpc" type for each stream request made, for any client method presented with a context containing a sampled apm.Transaction.

Spans are ended when the stream is closed, which can happen in various ways: the initial stream setup request fails, Header, SendMsg or RecvMsg return with an error, or RecvMsg returns for a non-streaming server.

func NewStreamServerInterceptor added in v1.12.0

func NewStreamServerInterceptor(o ...ServerOption) grpc.StreamServerInterceptor

NewStreamServerInterceptor returns a grpc.StreamServerInterceptor that traces gRPC stream requests with the given options.

The interceptor will trace transactions with the "request" type for each incoming stream 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.

func NewUnaryClientInterceptor

func NewUnaryClientInterceptor(o ...ClientOption) grpc.UnaryClientInterceptor

NewUnaryClientInterceptor returns a grpc.UnaryClientInterceptor that traces gRPC requests with the given options.

The interceptor will trace spans with the "external.grpc" type for each request made, for any client method presented with a context containing a sampled apm.Transaction.

func NewUnaryServerInterceptor

func NewUnaryServerInterceptor(o ...ServerOption) grpc.UnaryServerInterceptor

NewUnaryServerInterceptor returns a grpc.UnaryServerInterceptor that traces gRPC requests with the given options.

The interceptor will trace transactions with the "request" 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.

Types

type ClientOption

type ClientOption func(*clientOptions)

ClientOption sets options for client-side tracing.

type RequestIgnorerFunc added in v1.4.0

type RequestIgnorerFunc func(*grpc.UnaryServerInfo) bool

RequestIgnorerFunc is the type of a function for use in WithServerRequestIgnorer.

func DefaultServerRequestIgnorer added in v1.4.0

func DefaultServerRequestIgnorer() RequestIgnorerFunc

DefaultServerRequestIgnorer returns the default RequestIgnorerFunc to use in handlers.

func NewRegexpRequestIgnorer added in v1.4.0

func NewRegexpRequestIgnorer(re *regexp.Regexp) RequestIgnorerFunc

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

type ServerOption func(*serverOptions)

ServerOption sets options for server-side tracing.

func WithRecovery

func WithRecovery() ServerOption

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.

func WithServerRequestIgnorer added in v1.4.0

func WithServerRequestIgnorer(r RequestIgnorerFunc) ServerOption

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.

func WithServerStreamIgnorer added in v1.12.0

func WithServerStreamIgnorer(s StreamIgnorerFunc) ServerOption

WithServerStreamIgnorer returns a ServerOption which sets s as the function to use to determine whether or not a server stream request should be ignored. If s is nil, all stream requests will be reported.

func WithTracer

func WithTracer(t *apm.Tracer) ServerOption

WithTracer returns a ServerOption which sets t as the tracer to use for tracing server requests.

type StreamIgnorerFunc added in v1.12.0

type StreamIgnorerFunc func(*grpc.StreamServerInfo) bool

StreamIgnorerFunc is the type of a function for use in WithServerStreamIgnorer.

func DefaultServerStreamIgnorer added in v1.12.0

func DefaultServerStreamIgnorer() StreamIgnorerFunc

DefaultServerStreamIgnorer returns the default StreamIgnorerFunc to use in handlers.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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