From 421c4b3ab1b988a82aecdb5128c7ef6f8cd5ee29 Mon Sep 17 00:00:00 2001 From: Colin Redmond Date: Wed, 3 Apr 2024 22:26:11 -0700 Subject: [PATCH] feat: apply the gestalt config to the metric recorders. --- .../org/github/gestalt/config/builder/GestaltBuilder.java | 5 +++++ .../org/github/gestalt/config/metrics/MetricsManager.java | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/gestalt-core/src/main/java/org/github/gestalt/config/builder/GestaltBuilder.java b/gestalt-core/src/main/java/org/github/gestalt/config/builder/GestaltBuilder.java index 59f21c84f..6b4853d2a 100644 --- a/gestalt-core/src/main/java/org/github/gestalt/config/builder/GestaltBuilder.java +++ b/gestalt-core/src/main/java/org/github/gestalt/config/builder/GestaltBuilder.java @@ -211,6 +211,10 @@ private void configurePathMappers() { pathMappers.forEach(it -> it.applyConfig(gestaltConfig)); } + private void configureMetricsRecorders() { + metricsRecorders.forEach(it -> it.applyConfig(gestaltConfig)); + } + /** * Add a single source to the builder. * @@ -1073,6 +1077,7 @@ public Gestalt build() throws GestaltConfigurationException { configureConfigLoaders(); configurePostProcessors(); configurePathMappers(); + configureMetricsRecorders(); // create a new GestaltCoreReloadStrategy to listen for Gestalt Core Reloads. CoreReloadListenersContainer coreReloadListenersContainer = new CoreReloadListenersContainer(); diff --git a/gestalt-core/src/main/java/org/github/gestalt/config/metrics/MetricsManager.java b/gestalt-core/src/main/java/org/github/gestalt/config/metrics/MetricsManager.java index 8063bd7d4..e4267e2ad 100644 --- a/gestalt-core/src/main/java/org/github/gestalt/config/metrics/MetricsManager.java +++ b/gestalt-core/src/main/java/org/github/gestalt/config/metrics/MetricsManager.java @@ -41,7 +41,9 @@ public MetricsMarker startGetConfig(String path, TypeCapture klass, Tags } public void finalizeGetConfig(MetricsMarker markers, Tags tags) { - metricsRecorders.forEach((key, value) -> value.finalizeMetric(markers.getMetricsRecord(key), tags)); + if(markers != null) { + metricsRecorders.forEach((key, value) -> value.finalizeMetric(markers.getMetricsRecord(key), tags)); + } } public MetricsMarker startMetric(String metric, Tags tags) { @@ -53,7 +55,9 @@ public MetricsMarker startMetric(String metric, Tags tags) { } public void finalizeMetric(MetricsMarker markers, Tags tags) { - metricsRecorders.forEach((key, value) -> value.finalizeMetric(markers.getMetricsRecord(key), tags)); + if(markers != null) { + metricsRecorders.forEach((key, value) -> value.finalizeMetric(markers.getMetricsRecord(key), tags)); + } } /**