@@ -47,6 +47,7 @@ const (
47
47
var errMetricNameNotFound = errors .New ("metricName not found from labels" )
48
48
var errTransactionAborted = errors .New ("transaction aborted" )
49
49
var errNoJobInstance = errors .New ("job or instance cannot be found from labels" )
50
+ var errNoStartTimeMetrics = errors .New ("process_start_time_seconds metric is missing" )
50
51
51
52
// A transaction is corresponding to an individual scrape operation or stale report.
52
53
// That said, whenever prometheus receiver scrapped a target metric endpoint a page of raw metrics is returned,
@@ -157,12 +158,17 @@ func (tr *transaction) Commit() error {
157
158
}
158
159
159
160
if tr .useStartTimeMetric {
160
- // AdjustStartTime - startTime has to be non-zero in this case.
161
+ // startTime is mandatory in this case, but may be zero when the
162
+ // process_start_time_seconds metric is missing from the target endpoint.
161
163
if tr .metricBuilder .startTime == 0.0 {
162
- metrics = []* metricspb.Metric {}
163
- } else {
164
- adjustStartTime (tr .metricBuilder .startTime , metrics )
164
+ // Since we are unable to adjust metrics properly, we will drop them
165
+ // and return an error.
166
+ err = errNoStartTimeMetrics
167
+ obsreport .EndMetricsReceiveOp (ctx , dataformat , 0 , 0 , err )
168
+ return err
165
169
}
170
+
171
+ adjustStartTime (tr .metricBuilder .startTime , metrics )
166
172
} else {
167
173
// AdjustMetrics - jobsMap has to be non-nil in this case.
168
174
// Note: metrics could be empty after adjustment, which needs to be checked before passing it on to ConsumeMetricsData()
0 commit comments