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

Implement TracerProvider Shutdown #1489

Merged

Conversation

utpilla
Copy link
Contributor

@utpilla utpilla commented Nov 7, 2020

Fixes #1451

Changes

Implemented Shutdown method for TracerProvider for the issue #1451

  • Added public Shutdown and protected OnShutdown method to TracerProvider
  • Implemented OnShutdown method for TracerProviderSdk

@utpilla utpilla requested a review from a team as a code owner November 7, 2020 00:18
Copy link
Member

@reyang reyang left a comment

Choose a reason for hiding this comment

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

LGTM.

{
bool? result;
var sw = Stopwatch.StartNew();
this.listener?.Dispose();
Copy link
Member

Choose a reason for hiding this comment

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

It is a bit strange to call dispose in shutdown.
Consider clean up the dispose and shutdown methods (e.g. Dispose will dispose the underlying listener).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The spec says that after the TracerProvider Shutdown, any subsequent calls to get a Tracer should result in a no-op tracer. To achieve the equivalent of that requirement, we have to dispose the listener. If we don't dispose the listener we would continue to export the data as the exporters don't implement OnShutdown.

@codecov
Copy link

codecov bot commented Nov 7, 2020

Codecov Report

Merging #1489 (134d4da) into master (6cc8e44) will decrease coverage by 0.27%.
The diff coverage is 8.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1489      +/-   ##
==========================================
- Coverage   81.30%   81.03%   -0.28%     
==========================================
  Files         233      233              
  Lines        6370     6395      +25     
==========================================
+ Hits         5179     5182       +3     
- Misses       1191     1213      +22     
Impacted Files Coverage Δ
...rc/OpenTelemetry/Trace/TracerProviderExtensions.cs 25.00% <0.00%> (-46.43%) ⬇️
src/OpenTelemetry/Trace/TracerProviderSdk.cs 90.15% <0.00%> (-5.05%) ⬇️
...nTelemetry/Internal/OpenTelemetrySdkEventSource.cs 71.76% <40.00%> (-1.99%) ⬇️
...ter.ZPages/Implementation/ZPagesActivityTracker.cs 97.14% <0.00%> (-2.86%) ⬇️
...emetry.Api/Internal/OpenTelemetryApiEventSource.cs 82.35% <0.00%> (+5.88%) ⬆️

@cijothomas cijothomas closed this Nov 10, 2020
@cijothomas cijothomas reopened this Nov 10, 2020
/// </remarks>
internal bool OnShutdown(int timeoutMilliseconds)
{
bool? result;
Copy link
Member

Choose a reason for hiding this comment

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

why not dispose the instrumentations?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The spec just says that any calls to TracerPorvider after Shutdown should result in a no-op. It also explicitly says to call shutdown of each of the processors. We can achieve this by only disposing the listener and calling the CompositeProcessor Shutdown. I didn't dispose instrumentation to keep the Shutdown functionality as minimum as possible and in accordance with the spec.

We could Dispose the instrumentations too and then TracerProviderSdk Shutdown will be functionally pretty close to TracerProviderSdk Dispose with only Sampler and the base TracerProvider not getting disposed.

Copy link
Member

Choose a reason for hiding this comment

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

Spec just says at least processors must be shutdown.
i think shutdown should do same as dispose.

@cijothomas cijothomas merged commit 941a0b9 into open-telemetry:master Nov 13, 2020
@utpilla utpilla deleted the utpilla/Add-TracerProviderSdk-Shutdown branch November 30, 2020 22:25
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 TracerProvider shutdown
5 participants