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

Add InstrumentationLibrary to Tracer #693

Merged
merged 13 commits into from
Apr 26, 2021

Conversation

ThomsonTan
Copy link
Contributor

@ThomsonTan ThomsonTan commented Apr 22, 2021

Fixes #567 and #694.

Changes

Add InstrumentationLibrary to SDK and return a new tracer for a different InstruementationLibrary.

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

@codecov
Copy link

codecov bot commented Apr 22, 2021

Codecov Report

Merging #693 (5b55dd1) into main (7909008) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #693      +/-   ##
==========================================
+ Coverage   94.79%   94.81%   +0.01%     
==========================================
  Files         212      214       +2     
  Lines        9707     9744      +37     
==========================================
+ Hits         9202     9239      +37     
  Misses        505      505              
Impacted Files Coverage Δ
api/include/opentelemetry/trace/tracer.h 100.00% <ø> (ø)
sdk/test/trace/tracer_test.cc 100.00% <ø> (ø)
...k/instrumentationlibrary/instrumentation_library.h 100.00% <100.00%> (ø)
sdk/include/opentelemetry/sdk/trace/tracer.h 100.00% <100.00%> (ø)
sdk/src/trace/tracer.cc 79.31% <100.00%> (+2.38%) ⬆️
sdk/src/trace/tracer_context.cc 80.00% <100.00%> (ø)
sdk/src/trace/tracer_provider.cc 85.18% <100.00%> (+6.23%) ⬆️
...trumentationlibrary/instrumentationlibrary_test.cc 100.00% <100.00%> (ø)
sdk/test/trace/tracer_provider_test.cc 100.00% <100.00%> (ø)
... and 2 more

@ThomsonTan ThomsonTan changed the title [WIP] Add InstrumentationLibrary to Tracer Add InstrumentationLibrary to Tracer Apr 23, 2021
@ThomsonTan ThomsonTan marked this pull request as ready for review April 23, 2021 00:47
@ThomsonTan ThomsonTan requested a review from a team April 23, 2021 00:47
Copy link
Contributor

@jsuereth jsuereth left a comment

Choose a reason for hiding this comment

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

Change looks good assuming two things:

  1. We create new Tracers for different libraries/versions (you have Support multiple tracers in TracerProvider #694) for that.
  2. We fill out InstrumentationLibrary in the OTLP exporter. Is there a bug open to track that work or do we need to open one?

sdk/src/trace/tracer_provider.cc Outdated Show resolved Hide resolved
@lalitb
Copy link
Member

lalitb commented Apr 23, 2021

2. We fill out InstrumentationLibrary in the OTLP exporter. Is there a bug open to track that work or do we need to open one?

Created #695 for this.

@ThomsonTan
Copy link
Contributor Author

Change looks good assuming two things:

  1. We create new Tracers for different libraries/versions (you have Support multiple tracers in TracerProvider #694) for that.
  2. We fill out InstrumentationLibrary in the OTLP exporter. Is there a bug open to track that work or do we need to open one?

Create new Tracer is also included in this PR (fixed #694). I'll work on filling out InstrumentationLibrary as a separate ticket (#695). We need populate this info to most exporters like OTLP, Zipkin, Jaeger, etc.


const std::lock_guard<std::mutex> guard(lock_);

auto lib = InstrumentationLibrary::create(library_name, library_version);
Copy link
Contributor

Choose a reason for hiding this comment

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

If GetTracer were to be used in an instrumentation to retrieve a tracer when creating spans, this potentially creates 3 allocations and deallocs on a hot path.

Would it make sense to avoid heap allocations here for the usual case when a tracer already exists?

I mean using GetTracer() every time could perhaps be considered bad use of the API as opposed to caching a tracer in the instrumentation, but I think it might be too easy too misuse the API and just default to GetTracer()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@seemk thanks. I think this is a valid concern. I updated the PR and delayed the heap allocation to the time when creating new Tracer is necessary.

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. Thanks for adding this feature.

@lalitb lalitb merged commit 30434fa into open-telemetry:main Apr 26, 2021
@ThomsonTan ThomsonTan deleted the AddInstrumentationLibrary 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.

Implement InstrumentationLibrary Instance in SDK
4 participants