Skip to content

Commit 1413216

Browse files
authored
Check if map is initialized prior using it (#711)
## Type of change - [ ] Refactor - [ ] New feature - [ ] Bug fix - [x] Optimization - [ ] Documentation Update ## Description Let's check these maps are initialized before using them to prevent potential issues ## Related Tickets & Documents - Related Issue kube-burner/kube-burner-ocp#120 - Closes # Signed-off-by: Raul Sevilla <[email protected]>
1 parent 1ffe5f8 commit 1413216

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pkg/util/metrics/metrics.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,12 @@ func ProcessMetricsScraperConfig(scraperConfig ScraperConfig) Scraper {
4545
}
4646
// Combine users provided metadata with metrics and summary metadata
4747
for k, v := range userMetadata {
48-
scraperConfig.SummaryMetadata[k] = v
49-
scraperConfig.MetricsMetadata[k] = v
48+
if scraperConfig.SummaryMetadata != nil {
49+
scraperConfig.SummaryMetadata[k] = v
50+
}
51+
if scraperConfig.MetricsMetadata != nil {
52+
scraperConfig.MetricsMetadata[k] = v
53+
}
5054
}
5155
// MetricsEndpoint has preference over the configuration file
5256
if scraperConfig.MetricsEndpoint != "" {

0 commit comments

Comments
 (0)