|
14 | 14 | package promql |
15 | 15 |
|
16 | 16 | import ( |
| 17 | +"log/slog" |
| 18 | + |
17 | 19 | "github.com/prometheus/prometheus/promql/parser" |
18 | 20 | "github.com/prometheus/prometheus/util/annotations" |
19 | 21 | ) |
20 | 22 |
|
| 23 | +// TEMPORARY: debug logger for start-timestamp verification. Remove after integration testing. |
| 24 | +varyrateSTLogger=slog.Default().With("component", "yrate-st-debug") |
| 25 | + |
21 | 26 | // yIncrease is a utility function for yincrease/yrate/ydelta. |
22 | 27 | // It calculates the increase of the range (allowing for counter resets if isCounter is true), |
23 | 28 | // taking into account the sample at the end of the previous range (just before rangeStartMsec). |
@@ -66,6 +71,17 @@ func yIncrease(points []FPoint, rangeStartMsec, rangeEndMsec int64, isCounter bo |
66 | 71 | ifisCounter&&isYCounterReset(startTimestamps, prevST, currentST, points[i].T, rangeStartMsec, points[i].F, lastInRange) { |
67 | 72 | // Counter reset: accumulate as if 0 had come before this sample. |
68 | 73 | inRangeResetIncreases+=lastInRange |
| 74 | +// TEMPORARY: log counter reset detection details. |
| 75 | +stTriggered:=startTimestamps!=nil&¤tST!=0&¤tST!=prevST |
| 76 | +yrateSTLogger.Info("yrate counter reset detected", |
| 77 | +"value_drop", points[i].F<lastInRange, |
| 78 | +"st_triggered", stTriggered, |
| 79 | +"prev_st", prevST, |
| 80 | +"current_st", currentST, |
| 81 | +"sample_t", points[i].T, |
| 82 | +"sample_value", points[i].F, |
| 83 | +"last_in_range", lastInRange, |
| 84 | + ) |
69 | 85 |
|
70 | 86 | if!foundInRangeSample { |
71 | 87 | // This reset was *also* the first in-range sample. Since we just counted |
@@ -132,8 +148,14 @@ func funcYrate(_ []Vector, matrixVals Matrix, args parser.Expressions, enh *Eval |
132 | 148 | funcyStartTimestamps(points []FPoint, enh*EvalNodeHelper) []int64 { |
133 | 149 | ifenh.StartTimestamps!=nil&&len(enh.StartTimestamps.Floats) ==len(points) { |
134 | 150 | startTimestamps:=enh.StartTimestamps.Floats |
135 | | -for_, startTimestamp:=rangestartTimestamps { |
| 151 | +fori, startTimestamp:=rangestartTimestamps { |
136 | 152 | ifstartTimestamp!=0 { |
| 153 | +// TEMPORARY: log when start timestamps are found for yrate/yincrease evaluation. |
| 154 | +yrateSTLogger.Info("start timestamps found for yrate evaluation", |
| 155 | +"num_points", len(points), |
| 156 | +"first_nonzero_st_index", i, |
| 157 | +"first_nonzero_st_value", startTimestamp, |
| 158 | + ) |
137 | 159 | returnstartTimestamps |
138 | 160 | } |
139 | 161 | } |
|
0 commit comments