open-telemetry / opentelemetry-cpp

The OpenTelemetry C++ Client
https://opentelemetry.io/
Apache License 2.0
860 stars 410 forks source link

Simple Example Not Working #287

Closed snehilchopra closed 4 years ago

snehilchopra commented 4 years ago

The simple example does not seem to be working. I believe this is because the span destructor is not being invoked, which in turn invokes the span.End() method.

As a workaround, one has to explicitly call the span.End() method.

However, this is causing a lot of memory leaks. I tried running the example with bazel run --config=asan //example/simple:example_simple, and the report is too long to be pasted here.

I believe this has something to do with the newly implemented Runtime context, as per the report.

Any insights on this would be really appreciated, thanks!

snehilchopra commented 4 years ago

@pyohannes @reyang @maxgolov

pyohannes commented 4 years ago

I think the reason is that our Context implementation is not memory safe. A gobal context_handler_ is initialized, but never de-initialized.

I will look into sanitizing and stabilizing the Context part.

nadiaciobanu commented 4 years ago

This affects all similar examples (e.g. the OTLP exporter example). As a workaround, I could add calls to span.End() in the examples. What are your thoughts?

nadiaciobanu commented 4 years ago

I've created an OTLP exporter example using explicit calls to span->End() (https://github.com/open-telemetry/opentelemetry-cpp/pull/296). These calls should be removed once this issue is resolved.

jajanet commented 4 years ago

BTW the zPages example is buggy too, which is related to running spans that don't end I believe

pyohannes commented 4 years ago

End() calls are added for spans (this is required now). Also, #321 fixes the memory problems related to the global context_handler_ variable.