trace

package
v0.2.9 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2019 License: ISC Imports: 10 Imported by: 0

README

trace

This is a helper package for creating a Jaeger tracer that reports traces in OpenTracing format.

Quick Start

For creating a tracer with a constant sampler and an agent reporter:

package main

import (
  "github.com/moorara/goto/trace"
  "github.com/opentracing/opentracing-go/ext"
  "github.com/opentracing/opentracing-go/log"
  "github.com/prometheus/client_golang/prometheus"
)

func main() {
  tracer, closer, _ := trace.NewTracer(trace.Options{Name: "hello_service"})
  defer closer.Close()

  span := tracer.StartSpan("hello-world")
  defer span.Finish()
  ext.HTTPMethod.Set(span, "GET")
  ext.HTTPStatusCode.Set(span, 200)
  span.LogFields(
    log.String("environment", "prodcution"),
    log.String("region", "us-east-1"),
  )
}

Documentation

Overview

Package trace can be used for creating Jaeger tracers Deprecated: this package has been frozen and deprecated in favor of https://github.com/moorara/observe/trace

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAgentReporter

func NewAgentReporter(agentAddr string, logSpans bool) *jconfig.ReporterConfig

NewAgentReporter creates a Jaeger reporter reporting to jaeger-agent

agentAddr is the address of Jaeger agent
logSpans true will log all spans

func NewCollectorReporter

func NewCollectorReporter(collectorAddr string, logSpans bool) *jconfig.ReporterConfig

NewCollectorReporter creates a Jaeger reporter reporting to jaeger-collector

collectorAddr is the address of Jaeger collector
logSpans true will log all spans

func NewConstSampler

func NewConstSampler(enabled bool) *jconfig.SamplerConfig

NewConstSampler creates a constant Jaeger sampler

enabled true will report all traces
enabled false will skip all traces

func NewProbabilisticSampler

func NewProbabilisticSampler(probability float64) *jconfig.SamplerConfig

NewProbabilisticSampler creates a probabilistic Jaeger sampler

probability is between 0 and 1

func NewRateLimitingSampler

func NewRateLimitingSampler(rate float64) *jconfig.SamplerConfig

NewRateLimitingSampler creates a rate limited Jaeger sampler

rate is the number of spans per second

func NewRemoteSampler

func NewRemoteSampler(probability float64, serverURL string, interval time.Duration) *jconfig.SamplerConfig

NewRemoteSampler creates a Jaeger sampler pulling remote sampling strategies

probability is the initial probability between 0 and 1 before a remote sampling strategy is recieved
serverURL is the address of sampling server
interval specifies the rate of polling remote sampling strategies

func NewTracer

func NewTracer(opts Options) (opentracing.Tracer, io.Closer, error)

NewTracer creates a new tracer

Types

type Options added in v0.2.6

type Options struct {
	Name     string
	Sampler  *jconfig.SamplerConfig
	Reporter *jconfig.ReporterConfig
	Logger   log.Logger
	PromReg  prometheus.Registerer
}

Options contains optional options for Tracer

Jump to

Keyboard shortcuts

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