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

Update Metric Point for Counter and Gauge #2667

Conversation

utpilla
Copy link
Contributor

@utpilla utpilla commented Nov 23, 2021

Changes

  • Added public methods GetCounterSumLong, GetCounterSumDouble, GetGaugeLastValueLong, GetGaugeLastValueDouble, GetStartTime, and GetEndTime. to MetricPoint
  • Removed the public properties for these

Please provide a brief description of the changes here.

For significant contributions please make sure you have completed the following items:

  • CHANGELOG.md updated for non-trivial changes
  • Changes in public API reviewed

@utpilla utpilla requested a review from a team November 23, 2021 22:44
@codecov
Copy link

codecov bot commented Nov 23, 2021

Codecov Report

Merging #2667 (bdf52d3) into main (f7c718e) will decrease coverage by 0.04%.
The diff coverage is 89.36%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2667      +/-   ##
==========================================
- Coverage   82.92%   82.88%   -0.05%     
==========================================
  Files         249      249              
  Lines        8691     8705      +14     
==========================================
+ Hits         7207     7215       +8     
- Misses       1484     1490       +6     
Impacted Files Coverage Δ
src/OpenTelemetry/Metrics/MetricPoint.cs 85.48% <80.00%> (-2.24%) ⬇️
...tryProtocol/Implementation/MetricItemExtensions.cs 90.64% <100.00%> (ø)
...ometheus/Implementation/PrometheusSerializerExt.cs 100.00% <100.00%> (ø)
...emetry.Api/Internal/OpenTelemetryApiEventSource.cs 76.47% <0.00%> (-5.89%) ⬇️
...ter.ZPages/Implementation/ZPagesActivityTracker.cs 97.14% <0.00%> (-2.86%) ⬇️
...nTelemetry/Internal/OpenTelemetrySdkEventSource.cs 73.33% <0.00%> (-0.96%) ⬇️
...Telemetry/Internal/SelfDiagnosticsEventListener.cs 97.65% <0.00%> (+0.78%) ⬆️
src/OpenTelemetry/Metrics/MetricTypeExtensions.cs 20.00% <0.00%> (+20.00%) ⬆️

}
}

public long GetLastLongValue()
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
public long GetLastLongValue()
public long GetLastValueLong()

Copy link
Member

@CodeBlanch CodeBlanch Nov 23, 2021

Choose a reason for hiding this comment

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

Is "last value" something meaningful from the spec? If not something like GetGaugeValueLong might be more clear.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Basically, Gauge in OpenTelemetry is a stream of metric points, and each point is a combination of {last value, timestamps, attributes, exemplars}.

Copy link
Member

Choose a reason for hiding this comment

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

We do have some helper methods with "Histogram" in the name (at least currently), what if we added a type in all the names? Something like...

GetCounterSumAsLong, GetCounterSumAsDouble, GetGaugeLastValueAsLong, GetGaugeLastValueAsDouble

Copy link
Member

Choose a reason for hiding this comment

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

^ I like this, except the "As" in the name which indicates we are doing some cast..
GetCounterSumLong and friends, sounds better to me.


internal MetricPointStatus MetricPointStatus { get; private set; }
public double GetDoubleSum()
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
public double GetDoubleSum()
public double GetSumDouble()

^ thoughts?

Copy link
Member

@reyang reyang Nov 24, 2021

Choose a reason for hiding this comment

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

GetSum<double> 😆 (return value sucks)

Copy link
Member

Choose a reason for hiding this comment

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

To me GetDoubleSum reads better than GetSumDouble.
But: below I think it makes sense to call GetLastValueLong as others suggested. So.. now I'm in doubt on this one. It would be kinda inconsistent then if we go with GetDoubleSum, no? 🤔

Copy link
Member

Choose a reason for hiding this comment

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

@joaopgrassi #2667 (comment) we currently settled with this. Please let us know what do you think.

src/OpenTelemetry/CHANGELOG.md Show resolved Hide resolved

internal MetricPointStatus MetricPointStatus { get; private set; }
public double GetDoubleSum()
Copy link
Member

Choose a reason for hiding this comment

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

To me GetDoubleSum reads better than GetSumDouble.
But: below I think it makes sense to call GetLastValueLong as others suggested. So.. now I'm in doubt on this one. It would be kinda inconsistent then if we go with GetDoubleSum, no? 🤔

src/OpenTelemetry/Metrics/MetricPoint.cs Show resolved Hide resolved
cursor = WriteLong(buffer, cursor, metricPoint.GetLongSum());
}
else
{
Copy link
Member

Choose a reason for hiding this comment

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

It seems we do this code in a few places now (if sum - GetLongSum..). Maybe we could use an extension method on metricPoint that accepts the MetricType?

Copy link
Member

Choose a reason for hiding this comment

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

These checks be avoided. We have a TODO in line 68 about this.

@cijothomas cijothomas merged commit 9e83587 into open-telemetry:main Nov 24, 2021
@utpilla utpilla deleted the utpilla/Update-MetricPoint-For-Counter-Gauge branch November 3, 2023 22:11
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.

5 participants