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

Expose a new TracerSdkManagement interface on the OpenTelemetrySdk class. #1723

Merged
merged 5 commits into from
Oct 2, 2020

Conversation

jkwatson
Copy link
Contributor

@jkwatson jkwatson commented Sep 28, 2020

Rather than expose the TracerSdkProvider directly, this introduces a new interface for managing the Tracing SDK. This will make it more obvious that the OpenTelemetrySdk access methods are not to be used for instrumentation purposes, but for operating the SDK itself.

This is a draft of how to resolve #1635 .

Note: this only covers the Tracing side of the house. Metrics and Baggage probably want the same treatment, but I wanted to keep this relatively limited to make sure we're ok with moving in this direction.

@codecov
Copy link

codecov bot commented Sep 28, 2020

Codecov Report

Merging #1723 into master will not change coverage.
The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #1723   +/-   ##
=========================================
  Coverage     85.40%   85.40%           
  Complexity     1384     1384           
=========================================
  Files           164      164           
  Lines          5379     5379           
  Branches        559      559           
=========================================
  Hits           4594     4594           
  Misses          587      587           
  Partials        198      198           
Impacted Files Coverage Δ Complexity Δ
.../main/java/io/opentelemetry/SendTraceToJaeger.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...ain/java/io/opentelemetry/sdk/trace/TracerSdk.java 100.00% <ø> (ø) 6.00 <0.00> (ø)
.../io/opentelemetry/sdk/trace/TracerSdkProvider.java 100.00% <ø> (ø) 11.00 <0.00> (ø)
...io/opentelemetry/sdk/trace/config/TraceConfig.java 95.00% <ø> (ø) 6.00 <0.00> (ø)
...ntelemetry/exporters/inmemory/InMemoryTracing.java 100.00% <100.00%> (ø) 2.00 <0.00> (ø)
...in/java/io/opentelemetry/sdk/OpenTelemetrySdk.java 100.00% <100.00%> (ø) 3.00 <1.00> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 287eae9...9e0d01f. Read the comment docs.

@@ -36,7 +36,7 @@
* io.opentelemetry.OpenTelemetry}. However, if you need a custom implementation of the factory, you
* can create one as needed.
*/
public class TracerSdkProvider implements TracerProvider {
public class TracerSdkProvider implements TracerProvider, TracerSdkManagement {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the new interface allow this to be private? And then maybe we don't need to change the return types

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what do you want to be private?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you want to make TracerSdkProvider package-private, we would need to move the SPI implementation into this package: TracerProviderFactorySdk. That seems possible, if we're ok with moving it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

although it's used in a lot of tests as well right now, so we'd need to do quite a bit of test refactoring.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed all the "production" usages except the SPI implementation class.

Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like moving the SPI implementation into this package is a win, less API is nice - I would say SPI package usually defines an SPI interface, but doesn't have to or even should define an SPI implementation. Doesn't have to be in this PR though.

get rid of almost all production-code references to the TracerSdkProvider
@@ -36,7 +36,7 @@
* io.opentelemetry.OpenTelemetry}. However, if you need a custom implementation of the factory, you
* can create one as needed.
*/
public class TracerSdkProvider implements TracerProvider {
public class TracerSdkProvider implements TracerProvider, TracerSdkManagement {
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like moving the SPI implementation into this package is a win, less API is nice - I would say SPI package usually defines an SPI interface, but doesn't have to or even should define an SPI implementation. Doesn't have to be in this PR though.

@jkwatson
Copy link
Contributor Author

If I move this to a real PR, are we ok with metrics and baggage coming as a separate set of PRs?

@trask
Copy link
Member

trask commented Oct 1, 2020

This is a great change from auto-instrumentation perspective, as it cleanly separates TracerProvider (which we instrument) from the sdk management (which we do not instrument) 👍

@jkwatson
Copy link
Contributor Author

jkwatson commented Oct 1, 2020

do we want this change for 0.9.0, or should we wait until we can do the same with metrics and baggage before releasing in 0.10.0?

@anuraaga anuraaga merged commit 0746ddb into open-telemetry:master Oct 2, 2020
@jkwatson jkwatson deleted the clean_up_trace_config branch June 1, 2021 20:20
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.

Consider not using private type TracerSdk in public API TracerSdkProvider::get
4 participants