func()

in remappers/hostmetrics/hostmetrics.go [79:116]


func (r *Remapper) Remap(
	src pmetric.ScopeMetrics,
	out pmetric.MetricSlice,
	resource pcommon.Resource,
) {
	if !r.Valid(src) {
		return
	}

	scope := src.Scope()
	scraper := path.Base(scope.Name())

	dataset, ok := scraperToElasticDataset[scraper]
	if !ok {
		r.logger.Warn("no dataset defined for scraper", zap.String("scraper", scraper))
		return
	}
	datasetMutator := func(m pmetric.NumberDataPoint) {
		m.Attributes().PutStr(common.EventDatasetLabel, dataset)
		m.Attributes().PutStr(common.EventModuleLabel, "system")
		if r.cfg.SystemIntegrationDataset {
			m.Attributes().PutStr(common.DatastreamDatasetLabel, dataset)
		}
	}

	remapFunc, ok := remapFuncs[scraper]
	if !ok {
		return
	}
	err := remapFunc(src.Metrics(), out, resource, datasetMutator)
	if err != nil {
		r.logger.Warn(
			"failed to remap OTel hostmetrics",
			zap.String("scope", scope.Name()),
			zap.Error(err),
		)
	}
}