@@ -36,19 +36,19 @@ type metricFamily struct {
36
36
// a couple data complexValue (buckets and count/sum), a group of a metric family always share a same set of tags. for
37
37
// simple types like counter and gauge, each data point is a group of itself
38
38
type metricGroup struct {
39
- mtype pmetric.MetricType
40
- ts int64
41
- ls labels.Labels
42
- count float64
43
- hasCount bool
44
- sum float64
45
- hasSum bool
46
- created float64
47
- value float64
48
- hValue * histogram.Histogram
49
- fhValue * histogram.FloatHistogram
50
- complexValue []* dataPoint
51
- exemplars pmetric.ExemplarSlice
39
+ mtype pmetric.MetricType
40
+ ts int64
41
+ ls labels.Labels
42
+ count float64
43
+ hasCount bool
44
+ sum float64
45
+ hasSum bool
46
+ createdSeconds float64
47
+ value float64
48
+ hValue * histogram.Histogram
49
+ fhValue * histogram.FloatHistogram
50
+ complexValue []* dataPoint
51
+ exemplars pmetric.ExemplarSlice
52
52
}
53
53
54
54
func newMetricFamily (metricName string , mc scrape.MetricMetadataStore , logger * zap.Logger ) * metricFamily {
@@ -143,8 +143,8 @@ func (mg *metricGroup) toDistributionPoint(dest pmetric.HistogramDataPointSlice)
143
143
144
144
// The timestamp MUST be in retrieved from milliseconds and converted to nanoseconds.
145
145
tsNanos := timestampFromMs (mg .ts )
146
- if mg .created != 0 {
147
- point .SetStartTimestamp (timestampFromFloat64 (mg .created ))
146
+ if mg .createdSeconds != 0 {
147
+ point .SetStartTimestamp (timestampFromFloat64 (mg .createdSeconds ))
148
148
} else if ! removeStartTimeAdjustment .IsEnabled () {
149
149
// metrics_adjuster adjusts the startTimestamp to the initial scrape timestamp
150
150
point .SetStartTimestamp (tsNanos )
@@ -221,8 +221,8 @@ func (mg *metricGroup) toExponentialHistogramDataPoints(dest pmetric.Exponential
221
221
}
222
222
223
223
tsNanos := timestampFromMs (mg .ts )
224
- if mg .created != 0 {
225
- point .SetStartTimestamp (timestampFromFloat64 (mg .created ))
224
+ if mg .createdSeconds != 0 {
225
+ point .SetStartTimestamp (timestampFromFloat64 (mg .createdSeconds ))
226
226
} else if ! removeStartTimeAdjustment .IsEnabled () {
227
227
// metrics_adjuster adjusts the startTimestamp to the initial scrape timestamp
228
228
point .SetStartTimestamp (tsNanos )
@@ -315,8 +315,8 @@ func (mg *metricGroup) toSummaryPoint(dest pmetric.SummaryDataPointSlice) {
315
315
// The timestamp MUST be in retrieved from milliseconds and converted to nanoseconds.
316
316
tsNanos := timestampFromMs (mg .ts )
317
317
point .SetTimestamp (tsNanos )
318
- if mg .created != 0 {
319
- point .SetStartTimestamp (timestampFromFloat64 (mg .created ))
318
+ if mg .createdSeconds != 0 {
319
+ point .SetStartTimestamp (timestampFromFloat64 (mg .createdSeconds ))
320
320
} else if ! removeStartTimeAdjustment .IsEnabled () {
321
321
// metrics_adjuster adjusts the startTimestamp to the initial scrape timestamp
322
322
point .SetStartTimestamp (tsNanos )
@@ -329,8 +329,8 @@ func (mg *metricGroup) toNumberDataPoint(dest pmetric.NumberDataPointSlice) {
329
329
point := dest .AppendEmpty ()
330
330
// gauge/undefined types have no start time.
331
331
if mg .mtype == pmetric .MetricTypeSum {
332
- if mg .created != 0 {
333
- point .SetStartTimestamp (timestampFromFloat64 (mg .created ))
332
+ if mg .createdSeconds != 0 {
333
+ point .SetStartTimestamp (timestampFromFloat64 (mg .createdSeconds ))
334
334
} else if ! removeStartTimeAdjustment .IsEnabled () {
335
335
// metrics_adjuster adjusts the startTimestamp to the initial scrape timestamp
336
336
point .SetStartTimestamp (tsNanos )
@@ -398,7 +398,7 @@ func (mf *metricFamily) addSeries(seriesRef uint64, metricName string, ls labels
398
398
mg .count = v
399
399
mg .hasCount = true
400
400
case metricName == mf .metadata .Metric + metricSuffixCreated :
401
- mg .created = v
401
+ mg .createdSeconds = v
402
402
default :
403
403
boundary , err := getBoundary (mf .mtype , ls )
404
404
if err != nil {
@@ -408,11 +408,11 @@ func (mf *metricFamily) addSeries(seriesRef uint64, metricName string, ls labels
408
408
}
409
409
case pmetric .MetricTypeExponentialHistogram :
410
410
if metricName == mf .metadata .Metric + metricSuffixCreated {
411
- mg .created = v
411
+ mg .createdSeconds = v
412
412
}
413
413
case pmetric .MetricTypeSum :
414
414
if metricName == mf .metadata .Metric + metricSuffixCreated {
415
- mg .created = v
415
+ mg .createdSeconds = v
416
416
} else {
417
417
mg .value = v
418
418
}
@@ -425,9 +425,9 @@ func (mf *metricFamily) addSeries(seriesRef uint64, metricName string, ls labels
425
425
return nil
426
426
}
427
427
428
- func (mf * metricFamily ) addCreationTimestamp (seriesRef uint64 , ls labels.Labels , atMs , created int64 ) {
428
+ func (mf * metricFamily ) addCreationTimestamp (seriesRef uint64 , ls labels.Labels , atMs , ctMs int64 ) {
429
429
mg := mf .loadMetricGroupOrCreate (seriesRef , ls , atMs )
430
- mg .created = float64 (created )
430
+ mg .createdSeconds = float64 (ctMs ) / 1000.0
431
431
}
432
432
433
433
func (mf * metricFamily ) addExponentialHistogramSeries (seriesRef uint64 , metricName string , ls labels.Labels , t int64 , h * histogram.Histogram , fh * histogram.FloatHistogram ) error {
0 commit comments