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 the metrics dispose/shutdown logic #2404

Merged
merged 5 commits into from
Sep 23, 2021

Conversation

reyang
Copy link
Member

@reyang reyang commented Sep 23, 2021

With #2389 merged, now we can fix the shutdown logic.

Changes

  • Updated the metric readers' logic to make Shutdown actually work.
  • Updated the getting-started docs (no loops anymore).

@reyang reyang requested a review from a team September 23, 2021 02:28
@codecov
Copy link

codecov bot commented Sep 23, 2021

Codecov Report

Merging #2404 (8be85bd) into main (256fc2d) will increase coverage by 0.04%.
The diff coverage is 70.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2404      +/-   ##
==========================================
+ Coverage   80.21%   80.26%   +0.04%     
==========================================
  Files         232      232              
  Lines        7492     7500       +8     
==========================================
+ Hits         6010     6020      +10     
+ Misses       1482     1480       -2     
Impacted Files Coverage Δ
src/OpenTelemetry/Metrics/MetricReader.cs 72.91% <0.00%> (+10.41%) ⬆️
...OpenTelemetry/Metrics/BaseExportingMetricReader.cs 83.63% <77.77%> (-1.48%) ⬇️
...emetry.Api/Internal/OpenTelemetryApiEventSource.cs 79.41% <0.00%> (-2.95%) ⬇️
...nTelemetry/Internal/OpenTelemetrySdkEventSource.cs 70.58% <0.00%> (-0.99%) ⬇️
...Zipkin/Implementation/ZipkinExporterEventSource.cs 72.72% <0.00%> (+9.09%) ⬆️

Co-authored-by: Cijo Thomas <cithomas@microsoft.com>
var sw = Stopwatch.StartNew();
result = this.Collect(timeoutMilliseconds) && result;
var timeout = timeoutMilliseconds - sw.ElapsedMilliseconds;
result = this.exporter.Shutdown((int)Math.Max(timeout, 0)) && result;
Copy link
Member

Choose a reason for hiding this comment

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

we'll need to modify PrometheusExporter to override shutdown, and shut its httpserver, right?
And obviously, for pull based exporters, any pending data is simply lost on shutdown right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes and yes.

Copy link
Member

@cijothomas cijothomas left a comment

Choose a reason for hiding this comment

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

LGTM.
PrometheusExporter need to override onshutdown to cleanup httpserver. but can be done after this

@cijothomas cijothomas merged commit 78baf7c into open-telemetry:main Sep 23, 2021
@reyang reyang deleted the reyang/metrics-sdk-shutdown branch September 23, 2021 15:16
counter.Add(1, new("name", "lemon"), new("color", "yellow"));
counter.Add(2, new("name", "apple"), new("color", "green"));
counter.Add(5, new("name", "apple"), new("color", "red"));
counter.Add(4, new("name", "lemon"), new("color", "yellow"));
Copy link
Contributor

Choose a reason for hiding this comment

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

I like this new example topic!

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.

3 participants