Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientOption ¶
type ClientOption func(c *ClientOptions)
ClientOption is a function that sets some option on the client.
func Logger ¶
func Logger(logger jaeger.Logger) ClientOption
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) ClientOption
Metrics creates a ClientOption that initializes Metrics in the client, which is used to emit statistics.
func Observer ¶
func Observer(observer jaeger.Observer) ClientOption
Observer can be registered with the Tracer to receive notifications about new Spans.
type ClientOptions ¶
type ClientOptions struct {
// contains filtered or unexported fields
}
ClientOptions control behavior of the client.
type Configuration ¶
type Configuration struct { ClientOptions Disabled bool `yaml:"disabled"` Sampler *SamplerConfig `yaml:"sampler"` Reporter *ReporterConfig `yaml:"reporter"` }
Configuration configures and creates Jaeger Tracer
func (Configuration) InitGlobalTracer ¶
func (c Configuration) InitGlobalTracer( serviceName string, options ...ClientOption, ) (io.Closer, error)
InitGlobalTracer creates a new Jaeger Tracer, and sets is 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 ...ClientOption, ) (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 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