Documentation ¶
Index ¶
- Variables
- func ContextWithSpan(ctx context.Context, span opentracing.Span) context.Context
- func Global() core.Tracer
- func Init(opts TracerOptions) core.Tracer
- func LogErrorMessage(ctx context.Context, message string, fields ...log.Field)
- func LogErrorObject(ctx context.Context, e error, fields ...log.Field)
- func LogInfo(ctx context.Context, event string, fields ...log.Field)
- func SpanFromContext(ctx context.Context) opentracing.Span
- func StartSpanFromContext(ctx context.Context, operationName string, opts ...opentracing.StartSpanOption) (opentracing.Span, context.Context)
- func TracedHTTPClientTransport(t http.RoundTripper, interceptor ...TracedHTTPInterceptor) http.RoundTripper
- func TracedHTTPHandler(h http.Handler, interceptor ...TracedHTTPInterceptor) http.Handler
- func TracedHTTPHandlerFunc(fn func(http.ResponseWriter, *http.Request), ...) http.HandlerFunc
- type LambdaFunction
- type LambdaFunctionInterceptor
- type SpanConfig
- type TracedHTTPInterceptor
- type TracedLambdaFunction
- type TracerOptions
Constants ¶
This section is empty.
Variables ¶
var ChildOf = opentracing.ChildOf
ChildOf returns a StartSpanOption pointing to a dependent parent span. If sc == nil, the option has no effect.
See ChildOfRef, SpanReference
Functions ¶
func ContextWithSpan ¶
ContextWithSpan returns a new `context.Context` that holds a reference to `span`'s SpanContext.
func Init ¶
func Init(opts TracerOptions) core.Tracer
Init initializes the global Tracer returned by Global().
func LogErrorMessage ¶
LogErrorMessage allows the logging of an Error with a Message based on the current context.Context. If a running span does not exist on the current context, nothing is logged.
func LogErrorObject ¶
LogErrorObject allows the logging of an Error Object based on the current context.Context. If a running span does not exist on the current context, nothing is logged.
func LogInfo ¶
LogInfo allows the logging of an Info Event based on the current context.Context. If a running span does not exist on the current context, nothing is logged.
func SpanFromContext ¶
func SpanFromContext(ctx context.Context) opentracing.Span
SpanFromContext returns the `Span` previously associated with `ctx`, or `nil` if no such `Span` could be found.
NOTE: context.Context != SpanContext: the former is Go's intra-process context propagation mechanism, and the latter houses OpenTracing's per-Span identity and baggage information.
func StartSpanFromContext ¶
func StartSpanFromContext(ctx context.Context, operationName string, opts ...opentracing.StartSpanOption) (opentracing.Span, context.Context)
StartSpanFromContext starts and returns a Span with `operationName`, using any Span found within `ctx` as a ChildOfRef. If no such parent could be found, StartSpanFromContext creates a root (parentless) Span.
The second return value is a context.Context object built around the returned Span.
Example usage:
SomeFunction(ctx context.Context, ...) { sp, ctx := opentracing.StartSpanFromContext(ctx, "SomeFunction") defer sp.Finish() ... }
func TracedHTTPClientTransport ¶
func TracedHTTPClientTransport( t http.RoundTripper, interceptor ...TracedHTTPInterceptor, ) http.RoundTripper
TracedHTTPClientTransport creates a new Transporter (http.RoundTripper) that intercepts and traces egress requests.
func TracedHTTPHandler ¶
func TracedHTTPHandler( h http.Handler, interceptor ...TracedHTTPInterceptor, ) http.Handler
TracedHTTPHandler returns a http.Handler that is traced as an opentracing.Span
func TracedHTTPHandlerFunc ¶
func TracedHTTPHandlerFunc( fn func(http.ResponseWriter, *http.Request), interceptor ...TracedHTTPInterceptor, ) http.HandlerFunc
TracedHTTPHandlerFunc returns a http.HandlerFunc that is traced as an opentracing.Span
Types ¶
type LambdaFunction ¶
type LambdaFunction func( evt *apigatewayproxyevt.Event, lambdaCtx *runtime.Context, ) (interface{}, error)
LambdaFunction is the defined function for Lambda handlers
func TracedAPIGwLambdaProxyHandler ¶
func TracedAPIGwLambdaProxyHandler( fn TracedLambdaFunction, interceptor ...LambdaFunctionInterceptor, ) LambdaFunction
TracedAPIGwLambdaProxyHandler is a decorator (wrapper) that wraps the Lambda handler function for tracing. It handles starting a span when the handler is called and finishing it upon completion. To customize the OperationName or Tags pass in a LambdaFunctionInterceptor
type LambdaFunctionInterceptor ¶
type LambdaFunctionInterceptor func(evt *apigatewayproxyevt.Event, ctx *runtime.Context) SpanConfig
LambdaFunctionInterceptor is the defined function for intercepting the TracedApiGwLambdaProxyHandler calls for providing custom OperationName and/or custom Tags
type SpanConfig ¶
type SpanConfig struct { // OperationName is the custom operation name decided by interceptor OperationName string // IgnoredPaths are URL paths ignored by tracer (ex.. /health to be ignored as it is used by a load balancer) Ignored *regexp.Regexp // Tags are the custom start span options decided by interceptor. Tags []opentracing.StartSpanOption }
SpanConfig is used by middleware interceptors to return custom OperationName and Tags
func ConfigSpan ¶
func ConfigSpan( operationName string, ignored *regexp.Regexp, tags ...opentracing.StartSpanOption, ) SpanConfig
ConfigSpan function is used by middleware interceptors to construct a SpanConfig for customizing the starting of a span. For example:
ctrace.TracedHttpHandler( http.DefaultServeMux, func (r *http.Request) SpanConfig { return ConfigSpan( "MyOperation:" + r.URL.String(), ext.String("MyTag", "MyValue") ) }, )
type TracedHTTPInterceptor ¶
type TracedHTTPInterceptor func(r *http.Request) SpanConfig
TracedHTTPInterceptor is a defined function called during HTTP tracing to return custom OperationName and/or Tags for the given request
type TracedLambdaFunction ¶
type TracedLambdaFunction func( ctx context.Context, evt *apigatewayproxyevt.Event, lambdaCtx *runtime.Context, ) (interface{}, error)
TracedLambdaFunction is the defined function for traced Lambda handlers it adds context.Context as the first parameter.
type TracerOptions ¶
type TracerOptions core.TracerOptions
TracerOptions allows creating a customized Tracer via NewWithOptions. The object must not be updated when there is an active tracer using it. This is an alias of core.TracerOptions.