-
Notifications
You must be signed in to change notification settings - Fork 854
Implement the metrics dispose/shutdown logic #2404
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,8 @@ | |
| // </copyright> | ||
|
|
||
| using System; | ||
| using System.Diagnostics; | ||
| using System.Threading; | ||
|
|
||
| namespace OpenTelemetry.Metrics | ||
| { | ||
|
|
@@ -97,7 +99,22 @@ protected override bool OnCollect(int timeoutMilliseconds) | |
| /// <inheritdoc /> | ||
| protected override bool OnShutdown(int timeoutMilliseconds) | ||
| { | ||
| return this.exporter.Shutdown(timeoutMilliseconds); | ||
| var result = true; | ||
|
|
||
| if (timeoutMilliseconds == Timeout.Infinite) | ||
| { | ||
| result = this.Collect(Timeout.Infinite) && result; | ||
| result = this.exporter.Shutdown(Timeout.Infinite) && result; | ||
| } | ||
| else | ||
| { | ||
| var sw = Stopwatch.StartNew(); | ||
| result = this.Collect(timeoutMilliseconds) && result; | ||
| var timeout = timeoutMilliseconds - sw.ElapsedMilliseconds; | ||
| result = this.exporter.Shutdown((int)Math.Max(timeout, 0)) && result; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes and yes. |
||
| } | ||
|
|
||
| return result; | ||
| } | ||
|
|
||
| /// <inheritdoc/> | ||
|
|
||
There was a problem hiding this comment.
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!