Skip to content

Commit 99266e0

Browse files
committed
Replaced receiverRegex.FindStringSubmatch with receiverRegex.FindStringSubmatchIndex
Signed-off-by: Alexander Wert <[email protected]>
1 parent 6c2277f commit 99266e0

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

exporter/elasticsearchexporter/data_stream_router.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,15 @@ func routeRecord(
191191
if selfTelemetryScopeNames[scope.Name()] {
192192
// For collector self-telemetry, use a fixed dataset name
193193
dataset = collectorSelfTelemetryDataStreamDataset
194-
} else if submatch := receiverRegex.FindStringSubmatch(scope.Name()); len(submatch) > 0 {
194+
} else {
195195
// Receiver-based routing
196196
// For example, hostmetricsreceiver (or hostmetricsreceiver.otel in the OTel output mode)
197197
// for the scope name
198198
// github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/scraper/cpuscraper
199-
receiverName := submatch[1]
200-
dataset = receiverName
199+
loc := receiverRegex.FindStringSubmatchIndex(scope.Name())
200+
if len(loc) == 4 {
201+
dataset = scope.Name()[loc[2]:loc[3]]
202+
}
201203
}
202204
}
203205

0 commit comments

Comments
 (0)