File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed
prometheus-metrics-model/src/main/java/io/prometheus/metrics/model/registry Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -211,7 +211,8 @@ public void register(Collector collector) {
211211 collectorMetadata .put (
212212 collector , new CollectorRegistration (prometheusName , normalizedLabels ));
213213 }
214-
214+ // Catch RuntimeException broadly because collector methods (getPrometheusName, getMetricType,
215+ // etc.) are user-implemented and could throw any RuntimeException. Ensures cleanup on failure.
215216 } catch (RuntimeException e ) {
216217 collectors .remove (collector );
217218 CollectorRegistration reg = collectorMetadata .remove (collector );
@@ -244,6 +245,8 @@ public void register(MultiCollector collector) {
244245 }
245246
246247 multiCollectorMetadata .put (collector , registrations );
248+ // Catch RuntimeException broadly because collector methods (getPrometheusNames, getMetricType,
249+ // etc.) are user-implemented and could throw any RuntimeException. Ensures cleanup on failure.
247250 } catch (RuntimeException e ) {
248251 multiCollectors .remove (collector );
249252 for (MultiCollectorRegistration registration : registrations ) {
You can’t perform that action at this time.
0 commit comments