-
Notifications
You must be signed in to change notification settings - Fork 893
Update MetricPoint for Histograms #2657
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 2 commits
5c325ba
d72a8cf
3118ef5
de12519
5739710
002ec79
188d377
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -91,11 +91,11 @@ public static int WriteMetric(byte[] buffer, int cursor, Metric metric) | |
| var tags = metricPoint.Tags; | ||
| var timestamp = metricPoint.EndTime.ToUnixTimeMilliseconds(); | ||
|
|
||
| if (metricPoint.BucketCounts != null) | ||
| var bucketCounts = metricPoint.GetBucketCounts(); | ||
| if (bucketCounts != null) | ||
| { | ||
| // Histogram buckets | ||
| var bucketCounts = metricPoint.BucketCounts; | ||
| var explicitBounds = metricPoint.ExplicitBounds; | ||
| var explicitBounds = metricPoint.GetExplicitBounds(); | ||
| long totalCount = 0; | ||
| for (int idxBound = 0; idxBound < explicitBounds.Length + 1; idxBound++) | ||
| { | ||
|
|
@@ -133,6 +133,9 @@ public static int WriteMetric(byte[] buffer, int cursor, Metric metric) | |
| } | ||
|
|
||
| // Histogram sum | ||
| var count = metricPoint.GetHistogramCount(); | ||
|
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. Do we need to declare these variables here, or just use them inline?
Contributor
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. Fixed this in #2664 |
||
| var sum = metricPoint.GetHistogramSum(); | ||
|
|
||
| cursor = WriteMetricName(buffer, cursor, metric.Name, metric.Unit); | ||
| cursor = WriteAsciiStringNoEscape(buffer, cursor, "_sum"); | ||
|
|
||
|
|
@@ -156,7 +159,7 @@ public static int WriteMetric(byte[] buffer, int cursor, Metric metric) | |
|
|
||
| buffer[cursor++] = unchecked((byte)' '); | ||
|
|
||
| cursor = WriteDouble(buffer, cursor, metricPoint.DoubleValue); | ||
| cursor = WriteDouble(buffer, cursor, sum); | ||
| buffer[cursor++] = unchecked((byte)' '); | ||
|
|
||
| cursor = WriteLong(buffer, cursor, timestamp); | ||
|
|
@@ -187,7 +190,7 @@ public static int WriteMetric(byte[] buffer, int cursor, Metric metric) | |
|
|
||
| buffer[cursor++] = unchecked((byte)' '); | ||
|
|
||
| cursor = WriteLong(buffer, cursor, metricPoint.LongValue); | ||
| cursor = WriteLong(buffer, cursor, count); | ||
| buffer[cursor++] = unchecked((byte)' '); | ||
|
|
||
| cursor = WriteLong(buffer, cursor, timestamp); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,10 +56,12 @@ OpenTelemetry.Metrics.Metric.Name.get -> string | |
| OpenTelemetry.Metrics.Metric.Temporality.get -> OpenTelemetry.Metrics.AggregationTemporality | ||
| OpenTelemetry.Metrics.Metric.Unit.get -> string | ||
| OpenTelemetry.Metrics.MetricPoint | ||
| OpenTelemetry.Metrics.MetricPoint.BucketCounts.get -> long[] | ||
| OpenTelemetry.Metrics.MetricPoint.DoubleValue.get -> double | ||
| OpenTelemetry.Metrics.MetricPoint.EndTime.get -> System.DateTimeOffset | ||
| OpenTelemetry.Metrics.MetricPoint.ExplicitBounds.get -> double[] | ||
| OpenTelemetry.Metrics.MetricPoint.GetBucketCounts() -> long[] | ||
|
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. as a follow up we need to do something similar to whats done for Tags. (readonly something) |
||
| OpenTelemetry.Metrics.MetricPoint.GetExplicitBounds() -> double[] | ||
| OpenTelemetry.Metrics.MetricPoint.GetHistogramCount() -> long | ||
| OpenTelemetry.Metrics.MetricPoint.GetHistogramSum() -> double | ||
| OpenTelemetry.Metrics.MetricPoint.LongValue.get -> long | ||
| OpenTelemetry.Metrics.MetricPoint.MetricPoint() -> void | ||
| OpenTelemetry.Metrics.MetricPoint.StartTime.get -> System.DateTimeOffset | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| // <copyright file="HistogramMeasurements.cs" company="OpenTelemetry Authors"> | ||
| // Copyright The OpenTelemetry Authors | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
| // </copyright> | ||
|
|
||
| namespace OpenTelemetry.Metrics | ||
| { | ||
| internal class HistogramMeasurements | ||
|
cijothomas marked this conversation as resolved.
|
||
| { | ||
| internal readonly long[] BucketCounts; | ||
|
|
||
| internal readonly long[] AggregatedBucketCounts; | ||
|
|
||
| internal readonly double[] ExplicitBounds; | ||
|
|
||
| internal long CountVal; | ||
|
|
||
| internal long Count; | ||
|
|
||
| internal double SumVal; | ||
|
|
||
| internal double Sum; | ||
|
|
||
| internal HistogramMeasurements(double[] histogramBounds) | ||
| { | ||
| this.ExplicitBounds = histogramBounds; | ||
| this.BucketCounts = histogramBounds != null ? new long[histogramBounds.Length + 1] : null; | ||
| this.AggregatedBucketCounts = histogramBounds != null ? new long[histogramBounds.Length + 1] : null; | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.