func()

in pipeline/inputs/aggregator.go [227:255]


func (ar *aggregatedReport) accept(mr metrics.MetricReport) (bool, error) {
	if mr.Name != ar.Name || !reflect.DeepEqual(mr.Labels, ar.Labels) {
		return false, nil
	}

	// Only one of these values should be non-nil. We rely on prior validation to ensure the proper
	// value (i.e., the one specified in the metrics.Definition) is provided.
	if mr.Value.Int64Value != nil {
		if ar.Value.Int64Value == nil {
			ar.Value.Int64Value = util.NewInt64(0)
		}
		*ar.Value.Int64Value += *mr.Value.Int64Value
	} else if mr.Value.DoubleValue != nil {
		if ar.Value.DoubleValue == nil {
			ar.Value.DoubleValue = util.NewFloat64(0)
		}
		*ar.Value.DoubleValue += *mr.Value.DoubleValue
	}

	// Expand the aggregated start time if the given MetricReport has ealier start time.
	if mr.StartTime.Before(ar.StartTime) {
		ar.StartTime = mr.StartTime
	}
	// Expand the aggregated end time if the given MetricReport has later end time.
	if mr.EndTime.After(ar.StartTime) {
		ar.EndTime = mr.EndTime
	}
	return true, nil
}