Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing startup issues on certain installations #684

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,35 @@ public class DefaultPrometheusMetrics implements PrometheusMetrics {
private final AtomicReference<String> cachedMetrics;

private DefaultPrometheusMetrics() {
CollectorRegistry collectorRegistry = CollectorRegistry.defaultRegistry;
this.collectorRegistry = CollectorRegistry.defaultRegistry;
DefaultExports.initialize();
this.collectorRegistry = collectorRegistry;
this.cachedMetrics = new AtomicReference<>("");
}

public static synchronized DefaultPrometheusMetrics get() {
if(INSTANCE == null) {
if (INSTANCE == null) {
INSTANCE = new DefaultPrometheusMetrics();
}
return INSTANCE;
}

@Restricted(NoExternalUse.class)
private void registerCollector(@NonNull Collector collector) {
private synchronized void registerCollector(@NonNull Collector collector) {
collectorRegistry.register(collector);
logger.debug(String.format("Collector %s registered", collector.getClass().getName()));
logger.debug("Collector {} registered", collector.getClass().getName());
}

@Restricted(NoExternalUse.class)
private synchronized void cleanUpCollector() {
this.collectorRegistry.clear();
}

// Issue #683
@Restricted(NoExternalUse.class)
@Initializer(after = InitMilestone.PLUGINS_STARTED, before = InitMilestone.EXTENSIONS_AUGMENTED)
public static void cleanupCollectorRegistry() {
DefaultPrometheusMetrics instance = get();
instance.cleanUpCollector();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a debug log here ? I want to monitor the logs during execution/restart

}

@Restricted(NoExternalUse.class)
Expand Down
Loading