Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Populate InstrumentationLibrary to exporters #700

Merged
merged 6 commits into from
Apr 28, 2021

Conversation

ThomsonTan
Copy link
Contributor

Fixes #695

Changes

Added SetInstrumentationLibrary to Recordable interface which is used to populate instrumentation library to exporters.

For significant contributions please make sure you have completed the following items:

  • CHANGELOG.md updated for non-trivial changes
  • Unit tests have been added
  • Changes in public API reviewed

@ThomsonTan ThomsonTan requested a review from a team April 27, 2021 05:13
@codecov
Copy link

codecov bot commented Apr 27, 2021

Codecov Report

Merging #700 (bee87b3) into main (888c59f) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #700   +/-   ##
=======================================
  Coverage   94.80%   94.81%           
=======================================
  Files         214      214           
  Lines        9744     9750    +6     
=======================================
+ Hits         9238     9244    +6     
  Misses        506      506           
Impacted Files Coverage Δ
sdk/include/opentelemetry/sdk/trace/recordable.h 100.00% <ø> (ø)
...de/opentelemetry/ext/zpages/threadsafe_span_data.h 97.36% <100.00%> (+0.10%) ⬆️
sdk/include/opentelemetry/sdk/trace/span_data.h 100.00% <100.00%> (ø)
sdk/src/trace/span.cc 89.01% <100.00%> (+0.12%) ⬆️

&&instrumentation_library) noexcept
{
span_["otel.library.name"] = instrumentation_library->GetName();
span_["otel.library.version"] = instrumentation_library->GetVersion();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per the specs these should be reported in tags:

OpenTelemetry Span's InstrumentationLibrary MUST be reported as tags to Zipkin using the following mapping.

Similar to what is done for status:

span_["tags"]["otel.status_code"] = code;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the catch. I misread the tags part in the spec. Fixed it.

* Set the instrumentation library of the span.
* @param instrumentation_library the instrumentation library to set
*/
virtual void SetInstrumentationLibrary(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking out loud - should we be instead passing nostd::string_view for name and version - to ensure that exporter(s) won't store this shared_ptr reference locally?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is a good thought. I was trying to avoid dispersing the internal structure of InstruemntationLibrary to places other than the class itself as the spec mentioned it could be expected in future.

I tried define the pointer as std::wake_ptr in the exporter to avoid taking ownership. I could make this change if it looks good to you.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to keep the structure intact, it would be much easier to pass const reference to InstruemntationLibrary, as Tracer::GetInstrumentationLibrary() already returns that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Take const reference could cause use after free if the tracer provider is destructed before the exporter, or the exporter needs to make a copy of the InstrumentationLibrary which I'd like to avoid.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that would happen. As the shutdown is propagated from TracerProvider -> Processor -> Exporter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks reasonable. Could there be case like the exporter runs asynchronously then it is still working after the call of TracerProvider::Shutdown?

Updated the PR to pass const reference of InstrumentationLibrary to exporters.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That shouldn't happen if the exporter is implemented correctly. Exporter::Shutdown() should ensure all cleanups ( that includes pending/ongoing synchronous/asynchronous calls ) are completed before returning. And TracerProvider::Shutdown() would return only after.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But TracerProvicer::Shutdown() could return fail or timeout as the spec mentioned, will TracerProvider continue to destruct in these cases?

Copy link
Member

@lalitb lalitb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
We can see if there are comments from @jsuereth, @pyohannes, and others before merging.

@lalitb lalitb merged commit 7f5252f into open-telemetry:main Apr 28, 2021
@ThomsonTan ThomsonTan deleted the PopulateInstLibToExporter branch November 9, 2022 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Propagate instrumentation library information to exporters
2 participants