Skip to content

Commit a176135

Browse files
committed
metricstarttimeprocessor: add subtractinitial strategy implementation
This change addresses open-telemetry#38379.
1 parent d7544ff commit a176135

File tree

6 files changed

+1438
-10
lines changed

6 files changed

+1438
-10
lines changed

.chloggen/decouple-cache.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: metricstarttimeprocessor
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Decouples the cache from the strategies for adjusting
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [38382]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: []

processor/metricstarttimeprocessor/internal/datapointstorage/timeseries_map.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ func (tsm *TimeseriesMap) GC() {
101101
tsm.Mark = false
102102
}
103103

104+
<<<<<<< HEAD
104105
// IsResetHistogram compares the given histogram datapoint h, to tsi.Histogram
105106
// and determines whether the metric has been reset based on the values. It is
106107
// a reset if any of the bucket boundaries have changed, if any of the bucket
@@ -110,6 +111,13 @@ func (tsi *TimeseriesInfo) IsResetHistogram(h pmetric.HistogramDataPoint) bool {
110111
return true
111112
}
112113
if h.Sum() < tsi.Histogram.Sum() {
114+
=======
115+
func (tsi *TimeseriesInfo) IsResetHistogram(h pmetric.HistogramDataPoint) bool {
116+
if h.Count() != 0 && tsi.Histogram.Count() != 0 && h.Count() < tsi.Histogram.Count() {
117+
return true
118+
}
119+
if h.Sum() != 0 && tsi.Histogram.Sum() != 0 && h.Sum() < tsi.Histogram.Sum() {
120+
>>>>>>> a9034e93c8 (metricstarttimeprocessor: add reset detection for histograms)
113121
return true
114122
}
115123

@@ -137,6 +145,7 @@ func (tsi *TimeseriesInfo) IsResetHistogram(h pmetric.HistogramDataPoint) bool {
137145
return false
138146
}
139147

148+
<<<<<<< HEAD
140149
// IsResetExponentialHistogram compares the given exponential histogram
141150
// datapoint eh, to tsi.ExponentialHistogram and determines whether the metric
142151
// has been reset based on the values. It is a reset if any of the bucket
@@ -148,6 +157,14 @@ func (tsi *TimeseriesInfo) IsResetExponentialHistogram(eh pmetric.ExponentialHis
148157
return true
149158
}
150159
if eh.Sum() < tsi.ExponentialHistogram.Sum() {
160+
=======
161+
func (tsi *TimeseriesInfo) IsResetExponentialHistogram(eh pmetric.ExponentialHistogramDataPoint) bool {
162+
// Same as the histogram implementation
163+
if eh.Count() != 0 && tsi.ExponentialHistogram.Count() != 0 && eh.Count() < tsi.ExponentialHistogram.Count() {
164+
return true
165+
}
166+
if eh.Sum() != 0 && tsi.ExponentialHistogram.Sum() != 0 && eh.Sum() < tsi.ExponentialHistogram.Sum() {
167+
>>>>>>> a9034e93c8 (metricstarttimeprocessor: add reset detection for histograms)
151168
return true
152169
}
153170

@@ -177,6 +194,7 @@ func (tsi *TimeseriesInfo) IsResetExponentialHistogram(eh pmetric.ExponentialHis
177194
return false
178195
}
179196

197+
<<<<<<< HEAD
180198
// IsResetSummary compares the given summary datapoint s to tsi.Summary and
181199
// determines whether the metric has been reset based on the values. It is a
182200
// reset if the count or sum has decreased.
@@ -187,6 +205,13 @@ func (tsi *TimeseriesInfo) IsResetSummary(s pmetric.SummaryDataPoint) bool {
187205
// IsResetSum compares the given number datapoint s to tsi.Number and determines
188206
// whether the metric has been reset based on the values. It is a reset if the
189207
// value has decreased.
208+
=======
209+
func (tsi *TimeseriesInfo) IsResetSummary(s pmetric.SummaryDataPoint) bool {
210+
return (s.Count() != 0 && tsi.Summary.Count() != 0 && s.Count() < tsi.Summary.Count()) ||
211+
(s.Sum() != 0 && tsi.Summary.Sum() != 0 && s.Sum() < tsi.Summary.Sum())
212+
}
213+
214+
>>>>>>> a9034e93c8 (metricstarttimeprocessor: add reset detection for histograms)
190215
func (tsi *TimeseriesInfo) IsResetSum(s pmetric.NumberDataPoint) bool {
191216
return s.DoubleValue() < tsi.Number.DoubleValue()
192217
}

0 commit comments

Comments
 (0)