Skip to content

Commit

Permalink
eliminate zero splits.
Browse files Browse the repository at this point in the history
  • Loading branch information
zzhlogin committed Nov 13, 2024
1 parent a301f8f commit 8aa6806
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions exporter/awsemfexporter/datapoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,22 +259,6 @@ func (dps exponentialHistogramDataPointSlice) CalculateDeltaDatapoints(idx int,
totalBucketLen++
}

if totalBucketLen == 0 {
return []dataPoint{{
name: dps.metricName,
value: &cWMetricHistogram{
Values: []float64{},
Counts: []float64{},
Count: metric.Count(),
Sum: metric.Sum(),
Max: metric.Max(),
Min: metric.Min(),
},
labels: createLabels(metric.Attributes()),
timestampMs: unixNanoToMilliseconds(metric.Timestamp()),
}}, true
}

for currentBucketIndex < totalBucketLen {
// Create a new dataPointSplit with a capacity of up to splitThreshold buckets
capacity := splitThreshold
Expand Down Expand Up @@ -308,13 +292,31 @@ func (dps exponentialHistogramDataPointSlice) CalculateDeltaDatapoints(idx int,
// Set collect values from negative buckets and save into split.
currentBucketIndex, currentNegativeIndex = collectDatapointsWithNegativeBuckets(&split, metric, currentBucketIndex, currentNegativeIndex)

// Add the current split to the datapoints list
datapoints = append(datapoints, dataPoint{
name: dps.metricName,
value: split.cWMetricHistogram,
if split.length > 0 {
// Add the current split to the datapoints list
datapoints = append(datapoints, dataPoint{
name: dps.metricName,
value: split.cWMetricHistogram,
labels: createLabels(metric.Attributes()),
timestampMs: unixNanoToMilliseconds(metric.Timestamp()),
})
}
}

if len(datapoints) == 0 {
return []dataPoint{{
name: dps.metricName,
value: &cWMetricHistogram{
Values: []float64{},
Counts: []float64{},
Count: metric.Count(),
Sum: metric.Sum(),
Max: metric.Max(),
Min: metric.Min(),
},
labels: createLabels(metric.Attributes()),
timestampMs: unixNanoToMilliseconds(metric.Timestamp()),
})
}}, true
}

// Override the min and max values of the first and last splits with the raw data of the metric.
Expand Down

0 comments on commit 8aa6806

Please sign in to comment.