Skip to content

Memory leak issue with Open Telemetry and jaeger exporter #1490

@varun06

Description

@varun06

We are using Open Telemetry in a reverse Proxy at scale and seeing memory leak.

func InitTracing(serviceName string, collectorEndpoint string, sample float64) (func(), error) {
	tc := propagation.TraceContext{}
	// Register the TraceContext propagator globally.
	otel.SetTextMapPropagator(tc)

	// Create and install Jaeger export pipeline.
	return jaeger.InstallNewPipeline(
		jaeger.WithCollectorEndpoint(collectorEndpoint),
		jaeger.WithProcess(jaeger.Process{
			ServiceName: serviceName,
			Tags: []label.KeyValue{
				label.String("exporter", "jaeger"),
			},
		}),
		jaeger.WithSDK(&sdktrace.Config{DefaultSampler: sdktrace.TraceIDRatioBased(sample)}),
	)
}

This is how I am initiating tracer.

	if cfg.TracingEnabled {
		// Initialize tracing and set global tracer
		flush, err := tracing.InitTracing("odnd", cfg.TracingCollectorEndpoint, cfg.TracingSampleValue)
		if err != nil {
			proxyLogger.Error("Failed to initialize tracing collector", logger.Error(err))
		}
		if flush != nil {
			defer flush()
		}
	}

This is how it is used to create a global tracer.

	tc := otel.GetTextMapPropagator()
	ctx := tc.Extract(originalReq.Context(), originalReq.Header)

	tracer := otel.Tracer(tracing.TracerName)

	tracingCtx, span := tracer.Start(ctx, "serveHTTP", trace.WithSpanKind(trace.SpanKindServer))
	originalReq = originalReq.WithContext(tracingCtx)
	defer span.End()

That's how we are creating a span and then few more child spans are created. But we are seeing this

Screen Shot 2021-01-25 at 9 48 25 AM

It goes up as we add more spans and off course that impacts GC and CPU usage on node. Can someone please have a look and let me know if i am doing something wrong in code or it's related to lib??

Metadata

Metadata

Assignees

Labels

area:tracePart of OpenTelemetry tracingbugSomething isn't workingpkg:APIRelated to an API package

Type

No type

Projects

Status

Closed

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions