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

Support UpDownCounter and ObservableUpDownCounter #3606

Merged
merged 19 commits into from
Sep 2, 2022

Conversation

alanwest
Copy link
Member

@alanwest alanwest commented Aug 25, 2022

Support for aggregating measurements from UpDownCounters. Includes updates to OTLP and Prometheus exporters.

@codecov
Copy link

codecov bot commented Aug 25, 2022

Codecov Report

Merging #3606 (2bd8778) into main (46e6c8a) will decrease coverage by 0.04%.
The diff coverage is 92.59%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3606      +/-   ##
==========================================
- Coverage   87.33%   87.29%   -0.05%     
==========================================
  Files         280      280              
  Lines       10066    10081      +15     
==========================================
+ Hits         8791     8800       +9     
- Misses       1275     1281       +6     
Impacted Files Coverage Δ
src/OpenTelemetry/Metrics/Metric.cs 94.38% <90.00%> (-1.28%) ⬇️
...tryProtocol/Implementation/MetricItemExtensions.cs 93.83% <100.00%> (ø)
...s.HttpListener/Internal/PrometheusSerializerExt.cs 100.00% <100.00%> (ø)
src/OpenTelemetry/Metrics/MetricReader.cs 87.61% <100.00%> (-0.53%) ⬇️
src/OpenTelemetry/Metrics/MetricTypeExtensions.cs 50.00% <100.00%> (+10.00%) ⬆️
src/OpenTelemetry/Logs/Pool/LogRecordSharedPool.cs 78.94% <0.00%> (-21.06%) ⬇️
...ZPages/Implementation/ZPagesExporterEventSource.cs 56.25% <0.00%> (-6.25%) ⬇️
...ter.ZPages/Implementation/ZPagesActivityTracker.cs 97.14% <0.00%> (-2.86%) ⬇️
src/OpenTelemetry/Metrics/MetricReaderExt.cs 84.54% <0.00%> (-0.14%) ⬇️
...Telemetry/Internal/SelfDiagnosticsEventListener.cs 97.65% <0.00%> (+0.78%) ⬆️
... and 2 more

@alanwest alanwest marked this pull request as ready for review August 31, 2022 18:09
@alanwest alanwest requested a review from a team as a code owner August 31, 2022 18:09
exportedItems.Clear();

#if NETFRAMEWORK
Thread.Sleep(5000); // Compensates for low resolution timing in netfx.
Copy link
Member

Choose a reason for hiding this comment

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

Curious, why 5000 (this is a very long time from the CPU's perspective)?

Copy link
Member Author

@alanwest alanwest Sep 1, 2022

Choose a reason for hiding this comment

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

CPUs always want things right now! They oughta learn to have some patience.

But, yea you're right... I decreased it to 10 ms and also decreased it from the test I borrowed this from.

@@ -25,7 +25,7 @@ internal static partial class PrometheusSerializer
{
private static readonly string[] MetricTypes = new string[]
{
"untyped", "counter", "gauge", "summary", "histogram", "histogram", "histogram", "histogram", "untyped",
"untyped", "counter", "gauge", "summary", "histogram", "histogram", "histogram", "histogram", "gauge",
Copy link
Member

Choose a reason for hiding this comment

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

TODO: it might be good add a comment here to explain why. (like UpDownCounters are exported as Prometheus Gauge etc.)

var attributes = ToAttributes(keysValues).ToArray();
if (longValue.HasValue)
{
var counter = meter.CreateUpDownCounter<long>(name, unit, description);
Copy link
Member

Choose a reason for hiding this comment

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

nit: var counterUpDownCounter

[Theory]
[InlineData(true)]
[InlineData(false)]
public void ObservableUpDownCounterWithTagsAggregationTest(bool exportDelta)
Copy link
Member

Choose a reason for hiding this comment

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

TODO: why UpDownCounterWithTagsAggregationTest is missing?

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! we finally get updowncounter yay!

Left couple of nits, mostly about adding some code comments. Will merge.

@cijothomas cijothomas merged commit c2f5e80 into open-telemetry:main Sep 2, 2022
@alanwest alanwest deleted the alanwest/updown branch September 30, 2022 22:04
@cijothomas cijothomas mentioned this pull request Oct 7, 2022
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.

None yet

3 participants