Merge pull request #7760 from filecoin-project/feat/open-telemetry-fix

Minor improvement for OpenTelemetry
This commit is contained in:
Łukasz Magiera 2021-12-12 12:14:55 +01:00 committed by GitHub
commit 8652f80ab3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,6 +11,7 @@ import (
"go.opentelemetry.io/otel/sdk/resource" "go.opentelemetry.io/otel/sdk/resource"
tracesdk "go.opentelemetry.io/otel/sdk/trace" tracesdk "go.opentelemetry.io/otel/sdk/trace"
semconv "go.opentelemetry.io/otel/semconv/v1.7.0" semconv "go.opentelemetry.io/otel/semconv/v1.7.0"
"go.uber.org/zap"
logging "github.com/ipfs/go-log/v2" logging "github.com/ipfs/go-log/v2"
) )
@ -50,7 +51,7 @@ func jaegerOptsFromEnv() jaeger.EndpointOption {
} }
if e, ok = os.LookupEnv(envAgentHost); ok { if e, ok = os.LookupEnv(envAgentHost); ok {
options := []jaeger.AgentEndpointOption{jaeger.WithAgentHost(e)} options := []jaeger.AgentEndpointOption{jaeger.WithAgentHost(e), jaeger.WithLogger(zap.NewStdLog(log.Desugar()))}
var ep string var ep string
if p, ok := os.LookupEnv(envAgentPort); ok { if p, ok := os.LookupEnv(envAgentPort); ok {
options = append(options, jaeger.WithAgentPort(p)) options = append(options, jaeger.WithAgentPort(p))
@ -82,6 +83,7 @@ func SetupJaegerTracing(serviceName string) *tracesdk.TracerProvider {
semconv.SchemaURL, semconv.SchemaURL,
semconv.ServiceNameKey.String(serviceName), semconv.ServiceNameKey.String(serviceName),
)), )),
tracesdk.WithSampler(tracesdk.AlwaysSample()),
) )
otel.SetTracerProvider(tp) otel.SetTracerProvider(tp)
tracer := tp.Tracer(serviceName) tracer := tp.Tracer(serviceName)