File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
prometheus-metrics-model/src/main/java/io/prometheus/metrics/model/registry Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -211,7 +211,9 @@ 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
216+ // failure.
215217 } catch (RuntimeException e ) {
216218 collectors .remove (collector );
217219 CollectorRegistration reg = collectorMetadata .remove (collector );
@@ -244,6 +246,9 @@ public void register(MultiCollector collector) {
244246 }
245247
246248 multiCollectorMetadata .put (collector , registrations );
249+ // Catch RuntimeException broadly because collector methods (getPrometheusNames,
250+ // getMetricType, etc.) are user-implemented and could throw any RuntimeException.
251+ // Ensures cleanup on failure.
247252 } catch (RuntimeException e ) {
248253 multiCollectors .remove (collector );
249254 for (MultiCollectorRegistration registration : registrations ) {
You can’t perform that action at this time.
0 commit comments