trace

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 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() {
	sampler := trace.NewConstSampler(true)
	reporter := trace.NewAgentReporter("localhost:6831", false)
	tracer, closer, _ := trace.NewTracer("hello_service", sampler, reporter, nil, prometheus.DefaultRegisterer)
	defer closer.Close()

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

Documentation

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(name string, sampler *jconfig.SamplerConfig, reporter *jconfig.ReporterConfig, logger log.Logger, reg prometheus.Registerer) (opentracing.Tracer, io.Closer, error)

NewTracer creates a new tracer

Types

This section is empty.

Jump to

Keyboard shortcuts

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