tracing

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2020 License: MIT Imports: 9 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitJaeger

func InitJaeger(app string) error

InitJaeger asserts that the global tracer is initialized.

This will read the configuration from the "JAEGER_*"" environment variables. Overriding the empty values with the supplied app value. If a sampler type is not configured via the environment variables, then InitJaeger will be configured with the constant sampler.

Types

type Tracer added in v1.0.0

type Tracer interface {
	StartSpan(ctx context.Context, operationName string) (opentracing.Span, context.Context)
	FinishSpan(opentracing.Span, error)
}

Tracer contains all the tracing-related functions for any module of the server that uses tracing

Normally, if you have a module that needs tracing you embed the Tracer as following:

type Some struct {
  tracing.Tracer
}

And then initialize the tracer when you initialize the module:

func NewSome() Some {
  return Some{
    Tracer: tracing.NewTracer("package", "Some"),
  }
}

To use the tracing capabilities you use it as following:

func (s Some) Foo(ctx context.Context) (err error) {
  span, ctx := s.StartSpan(ctx, "Foo")
  // since the err is not assigned yet we have to take it into the closure
  defer func() {
    s.FinishSpan(span, err)
  }()
  span.SetTag("something", "important")
  ...
}

func NewTracer added in v1.0.0

func NewTracer(pkgName, componentName string) Tracer

NewTracer create a new tracer that contains implementation for all tracing-related actions

Jump to

Keyboard shortcuts

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