@@ -75,12 +75,18 @@ func (w *worker) run(ctx context.Context, timeout time.Duration, resultCh chan<-
75
75
jobStart := time .Now ()
76
76
log .Debugw ("start sampling worker" , "from" , w .state .from , "to" , w .state .to )
77
77
78
+ skipped := 0
79
+
78
80
for curr := w .state .from ; curr <= w .state .to ; curr ++ {
79
81
err := w .sample (ctx , timeout , curr )
80
82
if errors .Is (err , context .Canceled ) {
81
83
// sampling worker will resume upon restart
82
84
return
83
85
}
86
+ if errors .Is (err , errOutsideSamplingWindow ) {
87
+ skipped ++
88
+ err = nil
89
+ }
84
90
w .setResult (curr , err )
85
91
}
86
92
@@ -91,6 +97,7 @@ func (w *worker) run(ctx context.Context, timeout time.Duration, resultCh chan<-
91
97
"from" , w .state .from ,
92
98
"to" , w .state .curr ,
93
99
"errors" , len (w .state .failed ),
100
+ "# of headers skipped as outside of sampling window" , skipped ,
94
101
"finished (s)" , time .Since (jobStart ),
95
102
)
96
103
}
@@ -112,6 +119,12 @@ func (w *worker) sample(ctx context.Context, timeout time.Duration, height uint6
112
119
defer cancel ()
113
120
114
121
err = w .sampleFn (ctx , h )
122
+ if errors .Is (err , errOutsideSamplingWindow ) {
123
+ // if header is outside sampling window, do not log
124
+ // or record it.
125
+ return err
126
+ }
127
+
115
128
w .metrics .observeSample (ctx , h , time .Since (start ), w .state .jobType , err )
116
129
if err != nil {
117
130
if ! errors .Is (err , context .Canceled ) {
0 commit comments