Skip to content

Commit 307a956

Browse files
dasbusclaude
andcommitted
promql: add temporary debug logging to yrate start-timestamp codepath
Logs when start timestamps are found during yrate/yincrease evaluation and when they trigger counter reset detection. This is temporary logging for integration testing on red.prodref — to be removed after validation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Shannon Price <sprice@invoca.com>
1 parent b3423dd commit 307a956

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

‎promql/yrate_funcs.go‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,15 @@
1414
package promql
1515

1616
import (
17+
"log/slog"
18+
1719
"github.com/prometheus/prometheus/promql/parser"
1820
"github.com/prometheus/prometheus/util/annotations"
1921
)
2022

23+
// TEMPORARY: debug logger for start-timestamp verification. Remove after integration testing.
24+
varyrateSTLogger=slog.Default().With("component", "yrate-st-debug")
25+
2126
// yIncrease is a utility function for yincrease/yrate/ydelta.
2227
// It calculates the increase of the range (allowing for counter resets if isCounter is true),
2328
// 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
6671
ifisCounter&&isYCounterReset(startTimestamps, prevST, currentST, points[i].T, rangeStartMsec, points[i].F, lastInRange) {
6772
// Counter reset: accumulate as if 0 had come before this sample.
6873
inRangeResetIncreases+=lastInRange
74+
// TEMPORARY: log counter reset detection details.
75+
stTriggered:=startTimestamps!=nil&&currentST!=0&&currentST!=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+
)
6985

7086
if!foundInRangeSample {
7187
// 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
132148
funcyStartTimestamps(points []FPoint, enh*EvalNodeHelper) []int64 {
133149
ifenh.StartTimestamps!=nil&&len(enh.StartTimestamps.Floats) ==len(points) {
134150
startTimestamps:=enh.StartTimestamps.Floats
135-
for_, startTimestamp:=rangestartTimestamps {
151+
fori, startTimestamp:=rangestartTimestamps {
136152
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+
)
137159
returnstartTimestamps
138160
}
139161
}

0 commit comments

Comments
 (0)