@@ -20,35 +20,38 @@ import (
2020 "time"
2121
2222 "github.com/opentracing/opentracing-go"
23+ jaeger "github.com/uber/jaeger-client-go"
2324 jaegercfg "github.com/uber/jaeger-client-go/config"
25+ "github.com/uber/jaeger-client-go/transport"
2426)
2527
2628// SetupTracer sets up the tracer to send data to honeycomb
27- func SetupTracer (isDev bool , disableTelemetry bool ) (io.Closer , opentracing.Tracer ) {
28- var collectorEndpoint = "https://slackb.com/traces/v1/jaeger"
29+ func SetupTracer (isDev bool ) (io.Closer , opentracing.Tracer ) {
30+ collectorEndpoint : = "https://slackb.com/traces/v1/jaeger"
2931 if isDev {
3032 collectorEndpoint = "https://dev.slackb.com/traces/v1/jaeger"
3133 }
3234 // Recommended configuration for production.
33- var jCfg = jaegercfg.Configuration {
35+ jCfg : = jaegercfg.Configuration {
3436 ServiceName : "slack-cli" , // Don't change this. Required to distinguish logs & traces coming from the CLI
3537 Disabled : false , // Keep tracer active so span contexts and trace IDs are still generated
36- Reporter : & jaegercfg.ReporterConfig {
37- LogSpans : false ,
38- CollectorEndpoint : collectorEndpoint ,
39- BufferFlushInterval : 100 * time .Millisecond ,
40- // Having a larger value here results in longer execution of every single CLI command
41- // We may need to adjust the size here if we observe lost data in metrics.
42- QueueSize : 1 ,
43- },
4438 Sampler : & jaegercfg.SamplerConfig {
4539 Type : "const" ,
4640 Param : 1 ,
4741 },
4842 }
4943
44+ // Create HTTP transport with a short timeout to prevent hangs on unreachable hosts
45+ sender := transport .NewHTTPTransport (collectorEndpoint , transport .HTTPTimeout (1 * time .Second ))
46+ reporter := jaeger .NewRemoteReporter (sender ,
47+ jaeger .ReporterOptions .BufferFlushInterval (100 * time .Millisecond ),
48+ // Having a larger value here results in longer execution of every single CLI command
49+ // We may need to adjust the size here if we observe lost data in metrics.
50+ jaeger .ReporterOptions .QueueSize (1 ),
51+ )
52+
5053 // Initialize tracer with a logger and a metrics factory
51- var tracer , jaegerCloser , traceErr = jCfg .NewTracer ()
54+ tracer , jaegerCloser , traceErr : = jCfg .NewTracer (jaegercfg . Reporter ( reporter ) )
5255 if traceErr != nil {
5356 log .Fatalf ("Could not initialize jaeger tracer: %s" , traceErr .Error ())
5457 }
0 commit comments