From a8beec29cc880ddeea5e8b483b370367bd9c9a4b Mon Sep 17 00:00:00 2001 From: Holger Obermaier <40787752+ho-ob@users.noreply.github.com> Date: Wed, 17 Aug 2022 15:11:21 +0200 Subject: [PATCH] Skip non existing processor metrics URLs --- receivers/redfishReceiver.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/receivers/redfishReceiver.go b/receivers/redfishReceiver.go index 1e4c94e..20fa0c7 100644 --- a/receivers/redfishReceiver.go +++ b/receivers/redfishReceiver.go @@ -30,6 +30,8 @@ type RedfishReceiverClientConfig struct { doProcessorMetrics bool doThermalMetrics bool + skipProcessorMetricsURL map[string]bool + gofish gofish.ClientConfig } @@ -314,12 +316,23 @@ func (r *RedfishReceiver) readProcessorMetrics( timestamp := time.Now() - // Golang 1.19: URL, _ := url.JoinPath(processor.ODataID, "ProcessorMetrics") + // URL to processor metrics URL := processor.ODataID + "/ProcessorMetrics" + + // Skip previously detected non existing URLs + if clientConfig.skipProcessorMetricsURL[URL] { + return nil + } + resp, err := processor.Client.Get(URL) if err != nil { // Skip non existing URLs - return nil + if statusCode := err.(*common.Error).HTTPReturnedStatusCode; statusCode == http.StatusNotFound { + clientConfig.skipProcessorMetricsURL[URL] = true + return nil + } + + return fmt.Errorf("processor.Client.Get(%v) failed: %+w", URL, err) } var processorMetrics struct { @@ -741,6 +754,8 @@ func NewRedfishReceiver(name string, config json.RawMessage) (Receiver, error) { !(configJSON.DisableThermalMetrics || clientConfigJSON.DisableThermalMetrics) + clientConfig.skipProcessorMetricsURL = make(map[string]bool) + // Is metrics excluded globally or per client clientConfig.isExcluded = make(map[string]bool) for _, key := range clientConfigJSON.ExcludeMetrics {