apmgrpc

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2018 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package apmgrpc provides interceptors for tracing gRPC.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 "grpc" type for each request made, for any client method presented with a context containing a sampled elasticapm.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 "grpc" type for each incoming request. The transaction will be added to the context, so server methods can use elasticapm.StartSpan with the provided context.

By default, the interceptor will trace with elasticapm.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 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 WithTracer

func WithTracer(t *elasticapm.Tracer) ServerOption

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

Jump to

Keyboard shortcuts

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