diff --git a/probe_metrics_list.go b/probe_metrics_list.go index 7024990..16ed1e7 100644 --- a/probe_metrics_list.go +++ b/probe_metrics_list.go @@ -49,6 +49,7 @@ func probeMetricsListHandler(w http.ResponseWriter, r *http.Request) { } if !loadedFromCache { + w.Header().Add("X-metrics-cached", "false") for _, subscription := range settings.Subscriptions { wg.Add() go func(subscription string) { @@ -115,10 +116,10 @@ func probeMetricsListHandler(w http.ResponseWriter, r *http.Request) { // enable caching if enabled if settings.Cache != nil { - w.Header().Add("X-metrics-cached", (*settings.Cache).String()) metricsList.StoreToCache(cacheKey, *settings.Cache) } } else { + w.Header().Add("X-metrics-cached", "true") prometheusMetricRequests.With(prometheus.Labels{ "subscriptionID": "", "handler": PROBE_METRICS_LIST_URL, diff --git a/probe_metrics_resource.go b/probe_metrics_resource.go index 81a325f..4caa094 100644 --- a/probe_metrics_resource.go +++ b/probe_metrics_resource.go @@ -61,6 +61,7 @@ func probeMetricsResourceHandler(w http.ResponseWriter, r *http.Request) { } if !loadedFromCache { + w.Header().Add("X-metrics-cached", "false") for _, target := range settings.Target { result, err := azureInsightMetrics.FetchMetrics(ctx, subscription, target, settings) @@ -88,10 +89,10 @@ func probeMetricsResourceHandler(w http.ResponseWriter, r *http.Request) { // enable caching if enabled if settings.Cache != nil { - w.Header().Add("X-metrics-cached", (*settings.Cache).String()) metricsList.StoreToCache(cacheKey, *settings.Cache) } } else { + w.Header().Add("X-metrics-cached", "true") prometheusMetricRequests.With(prometheus.Labels{ "subscriptionID": "", "handler": PROBE_METRICS_RESOURCE_URL, diff --git a/probe_metrics_scrape.go b/probe_metrics_scrape.go index 2eaa86c..c3e8445 100644 --- a/probe_metrics_scrape.go +++ b/probe_metrics_scrape.go @@ -62,6 +62,7 @@ func probeMetricsScrapeHandler(w http.ResponseWriter, r *http.Request) { } if !loadedFromCache { + w.Header().Add("X-metrics-cached", "false") for _, subscription := range settings.Subscriptions { wg.Add() go func(subscription string) { @@ -131,17 +132,16 @@ func probeMetricsScrapeHandler(w http.ResponseWriter, r *http.Request) { // enable caching if enabled if settings.Cache != nil { - w.Header().Add("X-metrics-cached", (*settings.Cache).String()) metricsList.StoreToCache(cacheKey, *settings.Cache) } } else { + w.Header().Add("X-metrics-cached", "true") prometheusMetricRequests.With(prometheus.Labels{ "subscriptionID": "", "handler": PROBE_METRICS_SCRAPE_URL, "filter": settings.Filter, "result": "cached", }).Inc() - } metricsList.GaugeSet(metricGauge)