lotus/tracing/setup.go
Jakub Sztandera 1ed62628a7
Update go-log to v2
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
2020-01-08 20:22:31 +01:00

35 lines
692 B
Go

package tracing
import (
"os"
"contrib.go.opencensus.io/exporter/jaeger"
logging "github.com/ipfs/go-log/v2"
"go.opencensus.io/trace"
)
var log = logging.Logger("tracing")
func SetupJaegerTracing(serviceName string) *jaeger.Exporter {
if _, ok := os.LookupEnv("LOTUS_JAEGER"); !ok {
return nil
}
agentEndpointURI := os.Getenv("LOTUS_JAEGER")
je, err := jaeger.NewExporter(jaeger.Options{
AgentEndpoint: agentEndpointURI,
ServiceName: serviceName,
})
if err != nil {
log.Errorw("Failed to create the Jaeger exporter", "error", err)
return nil
}
trace.RegisterExporter(je)
trace.ApplyConfig(trace.Config{
DefaultSampler: trace.AlwaysSample(),
})
return je
}