config

package
v2.7.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2017 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Configuration

type Configuration struct {
	Disabled   bool            `yaml:"disabled"`
	Sampler    *SamplerConfig  `yaml:"sampler"`
	Reporter   *ReporterConfig `yaml:"reporter"`
	RPCMetrics bool            `yaml:"rpc_metrics"`
}

Configuration configures and creates Jaeger Tracer

func (Configuration) InitGlobalTracer

func (c Configuration) InitGlobalTracer(
	serviceName string,
	options ...Option,
) (io.Closer, error)

InitGlobalTracer creates a new Jaeger Tracer, and sets it as global OpenTracing Tracer. It returns a closer func that can be used to flush buffers before shutdown.

Example (Production)
package main

import (
	"log"

	"github.com/uber/jaeger-lib/metrics"

	jaegercfg "github.com/uber/jaeger-client-go/config"

	jaegerlog "github.com/uber/jaeger-client-go/log"
)

func main() {
	// Recommended configuration for production.
	cfg := jaegercfg.Configuration{}

	// Example logger and metrics factory. Use github.com/uber/jaeger-client-go/log
	// and github.com/uber/jaeger-lib/metrics respectively to bind to real logging and metrics
	// frameworks.
	jLogger := jaegerlog.StdLogger
	jMetricsFactory := metrics.NullFactory

	// Initialize tracer with a logger and a metrics factory
	closer, err := cfg.InitGlobalTracer(
		"serviceName",
		jaegercfg.Logger(jLogger),
		jaegercfg.Metrics(jMetricsFactory),
	)
	if err != nil {
		log.Printf("Could not initialize jaeger tracer: %s", err.Error())
		return
	}
	defer closer.Close()
}
Output:

Example (Testing)
// Sample configuration for testing. Use constant sampling to sample every trace
// and enable LogSpan to log every span via configured Logger.
cfg := jaegercfg.Configuration{
	Sampler: &jaegercfg.SamplerConfig{
		Type:  jaeger.SamplerTypeConst,
		Param: 1,
	},
	Reporter: &jaegercfg.ReporterConfig{
		LogSpans: true,
	},
}

// Example logger and metrics factory. Use github.com/uber/jaeger-client-go/log
// and github.com/uber/jaeger-lib/metrics respectively to bind to real logging and metrics
// frameworks.
jLogger := jaegerlog.StdLogger
jMetricsFactory := metrics.NullFactory

// Initialize tracer with a logger and a metrics factory
closer, err := cfg.InitGlobalTracer(
	"serviceName",
	jaegercfg.Logger(jLogger),
	jaegercfg.Metrics(jMetricsFactory),
)
if err != nil {
	log.Printf("Could not initialize jaeger tracer: %s", err.Error())
	return
}
defer closer.Close()
Output:

func (Configuration) New

func (c Configuration) New(
	serviceName string,
	options ...Option,
) (opentracing.Tracer, io.Closer, error)

New creates a new Jaeger Tracer, and a closer func that can be used to flush buffers before shutdown.

type Option

type Option func(c *Options)

Option is a function that sets some option on the client.

func Logger

func Logger(logger jaeger.Logger) Option

Logger can be provided to log Reporter errors, as well as to log spans if Reporter.LogSpans is set to true.

func Metrics

func Metrics(factory metrics.Factory) Option

Metrics creates an Option that initializes Metrics in the tracer, which is used to emit statistics about spans.

func Observer

func Observer(observer jaeger.Observer) Option

Observer can be registered with the Tracer to receive notifications about new Spans.

func Reporter

func Reporter(reporter jaeger.Reporter) Option

Reporter can be provided explicitly to override the configuration. Useful for testing, e.g. by passing InMemoryReporter.

func ZipkinSharedRPCSpan

func ZipkinSharedRPCSpan(zipkinSharedRPCSpan bool) Option

ZipkinSharedRPCSpan creates an option that enables sharing span ID between client and server spans a la zipkin. If false, client and server spans will be assigned different IDs.

type Options

type Options struct {
	// contains filtered or unexported fields
}

Options control behavior of the client.

type ReporterConfig

type ReporterConfig struct {
	// QueueSize controls how many spans the reporter can keep in memory before it starts dropping
	// new spans. The queue is continuously drained by a background go-routine, as fast as spans
	// can be sent out of process.
	QueueSize int `yaml:"queueSize"`

	// BufferFlushInterval controls how often the buffer is force-flushed, even if it's not full.
	// It is generally not useful, as it only matters for very low traffic services.
	BufferFlushInterval time.Duration

	// LogSpans, when true, enables LoggingReporter that runs in parallel with the main reporter
	// and logs all submitted spans. Main Configuration.Logger must be initialized in the code
	// for this option to have any effect.
	LogSpans bool `yaml:"logSpans"`

	// LocalAgentHostPort instructs reporter to send spans to jaeger-agent at this address
	LocalAgentHostPort string `yaml:"localAgentHostPort"`
}

ReporterConfig configures the reporter. All fields are optional.

func (*ReporterConfig) NewReporter

func (rc *ReporterConfig) NewReporter(
	serviceName string,
	metrics *jaeger.Metrics,
	logger jaeger.Logger,
) (jaeger.Reporter, error)

NewReporter instantiates a new reporter that submits spans to tcollector

type SamplerConfig

type SamplerConfig struct {
	// Type specifies the type of the sampler: const, probabilistic, rateLimiting, or remote
	Type string `yaml:"type"`

	// Param is a value passed to the sampler.
	// Valid values for Param field are:
	// - for "const" sampler, 0 or 1 for always false/true respectively
	// - for "probabilistic" sampler, a probability between 0 and 1
	// - for "rateLimiting" sampler, the number of spans per second
	// - for "remote" sampler, param is the same as for "probabilistic"
	//   and indicates the initial sampling rate before the actual one
	//   is received from the mothership
	Param float64 `yaml:"param"`

	// SamplingServerURL is the address of jaeger-agent's HTTP sampling server
	SamplingServerURL string `yaml:"samplingServerURL"`

	// MaxOperations is the maximum number of operations that the sampler
	// will keep track of. If an operation is not tracked, a default probabilistic
	// sampler will be used rather than the per operation specific sampler.
	MaxOperations int `yaml:"maxOperations"`

	// SamplingRefreshInterval controls how often the remotely controlled sampler will poll
	// jaeger-agent for the appropriate sampling strategy.
	SamplingRefreshInterval time.Duration `yaml:"samplingRefreshInterval"`
}

SamplerConfig allows initializing a non-default sampler. All fields are optional.

func (*SamplerConfig) NewSampler

func (sc *SamplerConfig) NewSampler(
	serviceName string,
	metrics *jaeger.Metrics,
) (jaeger.Sampler, error)

NewSampler creates a new sampler based on the configuration

Jump to

Keyboard shortcuts

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