config

package
v2.11.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2017 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaggageRestrictionsConfig

type BaggageRestrictionsConfig struct {
	// DenyBaggageOnInitializationFailure controls the startup failure mode of the baggage restriction
	// manager. If true, the manager will not allow any baggage to be written until baggage restrictions have
	// been retrieved from jaeger-agent. If false, the manager wil allow any baggage to be written until baggage
	// restrictions have been retrieved from jaeger-agent.
	DenyBaggageOnInitializationFailure bool `yaml:"denyBaggageOnInitializationFailure"`

	// HostPort is the hostPort of jaeger-agent's baggage restrictions server
	HostPort string `yaml:"hostPort"`

	// RefreshInterval controls how often the baggage restriction manager will poll
	// jaeger-agent for the most recent baggage restrictions.
	RefreshInterval time.Duration `yaml:"refreshInterval"`
}

BaggageRestrictionsConfig configures the baggage restrictions manager which can be used to whitelist certain baggage keys. All fields are optional.

type Configuration

type Configuration struct {
	Disabled            bool                       `yaml:"disabled"`
	Sampler             *SamplerConfig             `yaml:"sampler"`
	Reporter            *ReporterConfig            `yaml:"reporter"`
	Headers             *jaeger.HeadersConfig      `yaml:"headers"`
	RPCMetrics          bool                       `yaml:"rpc_metrics"`
	BaggageRestrictions *BaggageRestrictionsConfig `yaml:"baggage_restrictions"`
}

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()

	// continue main()
}
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()

// continue main()
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 ContribObserver

func ContribObserver(observer jaeger.ContribObserver) Option

ContribObserver can be registered with the Tracer to recieve notifications about new spans.

func Gen128Bit

func Gen128Bit(gen128Bit bool) Option

Gen128Bit specifies whether to generate 128bit trace IDs.

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 Tag

func Tag(key string, value interface{}) Option

Tag creates an option that adds a tracer-level tag.

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