in processor/lsmintervalprocessor/internal/merger/value.go [552:603]
func (s *Value) addMetric(
scopeID identity.Scope,
sm pdataScopeMetrics,
otherM pmetric.Metric,
) (identity.Metric, pdataMetric, bool) {
mID := identity.OfMetric(scopeID, otherM)
if m, ok := s.metricLookup[mID]; ok {
return mID, m, false
}
if sm.metricTracker.CheckOverflow(mID.Hash) {
// Metric overflow detected. In this case no action has to be taken
// at this point since metric overflow should create a new sum metric
// recording the number of unique metric that overflowed. This number
// will be recorded in the limit tracker and the metric will be
// populated on demand.
return identity.Metric{}, pdataMetric{}, true
}
// Clone it *without* the datapoint data
mOrig := sm.Metrics().AppendEmpty()
mOrig.SetName(otherM.Name())
mOrig.SetDescription(otherM.Description())
mOrig.SetUnit(otherM.Unit())
switch otherM.Type() {
case pmetric.MetricTypeGauge:
mOrig.SetEmptyGauge()
case pmetric.MetricTypeSummary:
mOrig.SetEmptySummary()
case pmetric.MetricTypeSum:
otherSum := otherM.Sum()
sum := mOrig.SetEmptySum()
sum.SetAggregationTemporality(otherSum.AggregationTemporality())
sum.SetIsMonotonic(otherSum.IsMonotonic())
case pmetric.MetricTypeHistogram:
otherHist := otherM.Histogram()
hist := mOrig.SetEmptyHistogram()
hist.SetAggregationTemporality(otherHist.AggregationTemporality())
case pmetric.MetricTypeExponentialHistogram:
otherExp := otherM.ExponentialHistogram()
exp := mOrig.SetEmptyExponentialHistogram()
exp.SetAggregationTemporality(otherExp.AggregationTemporality())
}
m := pdataMetric{
Metric: mOrig,
datapointTracker: sm.metricTracker.NewDatapointTracker(),
}
s.metricLookup[mID] = m
return mID, m, false
}