Skip non existing processor metrics URLs

This commit is contained in:
Holger Obermaier 2022-08-17 15:11:21 +02:00
parent 0dd430e7e9
commit a8beec29cc

View File

@ -30,6 +30,8 @@ type RedfishReceiverClientConfig struct {
doProcessorMetrics bool
doThermalMetrics bool
skipProcessorMetricsURL map[string]bool
gofish gofish.ClientConfig
}
@ -314,14 +316,25 @@ 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
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 {
common.Entity
ODataType string `json:"@odata.type"`
@ -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 {