fix(processors.aws_ec2): Remove leading slash and cancel worker only if it exists (#15965)

This commit is contained in:
Sven Rebhan 2024-10-07 16:09:13 +02:00 committed by GitHub
parent 40d7961e31
commit ba413e36f8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 2 deletions

View File

@ -163,7 +163,10 @@ func (r *AwsEc2Processor) Stop() {
if r.parallel != nil {
r.parallel.Stop()
}
r.cancelCleanupWorker()
if r.cancelCleanupWorker != nil {
r.cancelCleanupWorker()
r.cancelCleanupWorker = nil
}
}
func (r *AwsEc2Processor) logCacheStatistics(ctx context.Context) {
@ -268,7 +271,7 @@ func (r *AwsEc2Processor) lookupMetadata(metric telegraf.Metric) telegraf.Metric
key = strings.ReplaceAll(key, "/", "_")
} else {
if idx := strings.LastIndex(key, "/"); idx > 0 {
key = key[idx:]
key = key[idx+1:]
}
}