diff --git a/pkg/collector/hostname_collector.go b/pkg/collector/hostname_collector.go index 1948a5ee..835c5dd0 100644 --- a/pkg/collector/hostname_collector.go +++ b/pkg/collector/hostname_collector.go @@ -44,6 +44,10 @@ func (p *HostnameCollectorPlugin) NewCollector( // Need to copy config and add a promQL query in order to get // RPS data from a specific hostname from prometheus. The idea // of the copy is to not modify the original config struct. + if config == nil { + return nil, fmt.Errorf("Metric config not present, it is not possible to initialize the collector.") + } + confCopy := *config hostname := config.Config["hostname"] @@ -76,14 +80,6 @@ func (c *HostnameCollector) GetMetrics() ([]CollectedMetric, error) { if len(v) != 1 { return nil, fmt.Errorf("expected to only get one metric value, got %d", len(v)) } - - // TBD(Lucas): - // The explanation bellow is only true if we want to implement object metrics. - // I believe external metrics would suffice. - // Apparently in case of k8s