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

Delay initialization of Prometheus Plugin to fix startup issues in certain environments #648

Closed
wants to merge 2 commits into from

Conversation

Waschndolos
Copy link

Fixes #647

Changes proposed

Changing Initialization logic

@@ -67,5 +67,9 @@
cachedMetrics.set(metrics);
}

@Override
public void initialize() {

Check warning

Code scanning / Pmd (reported by Codacy)

Document empty method body Warning test

Document empty method body
@jonesbusy jonesbusy mentioned this pull request Mar 28, 2024
3 tasks
@jonesbusy
Copy link

On 2.5.1 I don't have issue with metrics collection

2024-03-28T05:00:33.493Z [DEBUG] [Thread=Metrics.afterExtensionsAugmented] - org.jenkinsci.plugins.prometheus.JobCollector # Collecting metrics for prometheus 

On 2.5.2 I see all the time and it's preventing the plugin to load

Caused by: java.lang.IllegalArgumentException: Failed to register Collector of type JenkinsStatusCollector: default_jenkins_version_info is already in use by another Collector of type JenkinsStatusCollector
        at io.prometheus.client.CollectorRegistry.register(CollectorRegistry.java:57)

Using the hpi 2.5.3-SNAPSHOT by rebuilding this PR I get now after a controller restart. The first initialization work

2024-03-28T05:02:48.905Z [INFO] [Thread=pool-182-thread-2] - jenkins.InitReactorRunner # Started initialization 
2024-03-28T05:02:48.908Z [DEBUG] [Thread=Initializers.initializePrometheusMetrics] - org.jenkinsci.plugins.prometheus.init.Initializers # Initializing Prometheus Plugin 
2024-03-28T05:02:48.908Z [ERROR] [Thread=Initializers.initializePrometheusMetrics] - org.jenkinsci.plugins.prometheus.init.Initializers # Unable to load Prometheus Plugin. Collecting Metrics won't work 
java.lang.IllegalStateException: Found no instances of org.jenkinsci.plugins.prometheus.service.PrometheusMetrics registered (possible annotation processor issue); try using `mvn clean test -Dtest=…` rather than an IDE test runner
        at hudson.ExtensionList.lookupSingleton(ExtensionList.java:454)

But doesn't prevent the plugin to load.

Cannot we keep the behavior of 2.5.1 that was working all the time ?

Thanks

@Waschndolos
Copy link
Author

Closing. Will provide new attempt with reverting commits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prometheus Plugin Update prevents Jenkins from startup
2 participants