johrstrom / jmeter-prometheus-plugin

A Prometheus Listener for Apache JMeter that exposes results in an http API
Apache License 2.0
166 stars 110 forks source link

IllegalArgumentException thrown when test starts #45

Closed johrstrom closed 5 years ago

johrstrom commented 5 years ago

Two errors get thrown when running the example (and likely during other testplans too). This doesn't affect the actual running of the test, but is a bug none the less. It seems there's a threading issue.

019-02-21 09:36:26,099 DEBUG [StandardJMeterEngine] c.g.j.l.PrometheusListener(200): added jsr223_rsize_as_hist to list of collectors 2019-02-21 09:36:26,105 DEBUG [StandardJMeterEngine] c.g.j.c.JMeterCollectorRegistry(85): created and registered [collector.help: default help string, collector.metric_name: jsr223_animals_total, collector.type: COUNTER, collector.labels: [color, size, mammal], collector.quantiles_or_buckets: , ] 2019-02-21 09:36:26,106 DEBUG [StandardJMeterEngine] c.g.j.c.CollectorElement(80): added jsr223_animals_total to list of collectors 2019-02-21 09:36:26,106 DEBUG [StandardJMeterEngine] c.g.j.c.PrometheusMetricsConfig(50): Test started, adding 1 collectors to variables 2019-02-21 09:36:26,106 DEBUG [StandardJMeterEngine] c.g.j.c.PrometheusMetricsConfig(55): Added ([collector.help: default help string, collector.metric_name: jsr223_animals_total, collector.type: COUNTER, collec tor.labels: [color, size, mammal], collector.quantiles_or_buckets: , ],io.prometheus.client.Counter@9bbcae2) to variables. 2019-02-21 09:36:26,107 TRACE [StandardJMeterEngine] c.g.j.c.JMeterCollectorRegistry(78): jsr223_rt_as_hist found already registered. 2019-02-21 09:36:26,107 DEBUG [StandardJMeterEngine] c.g.j.l.PrometheusListener(200): added jsr223_rt_as_hist to list of collectors 2019-02-21 09:36:26,111 ERROR [StandardJMeterEngine] c.g.j.l.PrometheusListener(208): Didn't create new collector because of error, java.lang.IllegalArgumentException: Collector already registered that provides name: jsr223_rt_as_summary_count at io.prometheus.client.CollectorRegistry.register(CollectorRegistry.java:54) ~[jmeter-prometheus-plugin-0.2.0-rc3.jar:?] at com.github.johrstrom.collector.JMeterCollectorRegistry.getOrCreateAndRegister(JMeterCollectorRegistry.java:82) ~[jmeter-prometheus-plugin-0.2.0-rc3.jar:?] at com.github.johrstrom.listener.PrometheusListener.makeNewCollectors(PrometheusListener.java:171) [jmeter-prometheus-plugin-0.2.0-rc3.jar:?] at com.github.johrstrom.listener.PrometheusListener.testStarted(PrometheusListener.java:136) [jmeter-prometheus-plugin-0.2.0-rc3.jar:?] at org.apache.jmeter.engine.StandardJMeterEngine.notifyTestListenersOfStart(StandardJMeterEngine.java:215) [ApacheJMeter_core.jar:4.0 r1823414] at org.apache.jmeter.engine.StandardJMeterEngine.run(StandardJMeterEngine.java:384) [ApacheJMeter_core.jar:4.0 r1823414] at java.lang.Thread.run(Thread.java:844) [?:?] 2019-02-21 09:36:26,122 TRACE [StandardJMeterEngine] c.g.j.c.JMeterCollectorRegistry(78): jsr223_rt_as_hist found already registered. 2019-02-21 09:36:26,122 DEBUG [StandardJMeterEngine] c.g.j.l.PrometheusListener(200): added jsr223_rt_as_hist to list of collectors 2019-02-21 09:36:26,122 ERROR [StandardJMeterEngine] c.g.j.l.PrometheusListener(208): Didn't create new collector because of error, java.lang.IllegalArgumentException: Collector already registered that provides name: jsr223_rt_as_summary_count at io.prometheus.client.CollectorRegistry.register(CollectorRegistry.java:54) ~[jmeter-prometheus-plugin-0.2.0-rc3.jar:?] at com.github.johrstrom.collector.JMeterCollectorRegistry.getOrCreateAndRegister(JMeterCollectorRegistry.java:82) ~[jmeter-prometheus-plugin-0.2.0-rc3.jar:?] at com.github.johrstrom.listener.PrometheusListener.makeNewCollectors(PrometheusListener.java:171) [jmeter-prometheus-plugin-0.2.0-rc3.jar:?] at com.github.johrstrom.listener.PrometheusListener.testStarted(PrometheusListener.java:136) [jmeter-prometheus-plugin-0.2.0-rc3.jar:?] at org.apache.jmeter.engine.StandardJMeterEngine.notifyTestListenersOfStart(StandardJMeterEngine.java:215) [ApacheJMeter_core.jar:4.0 r1823414] at org.apache.jmeter.engine.StandardJMeterEngine.run(StandardJMeterEngine.java:384) [ApacheJMeter_core.jar:4.0 r1823414] at java.lang.Thread.run(Thread.java:844) [?:?] 2019-02-21 09:36:26,128 INFO [StandardJMeterEngine] o.a.j.g.u.JMeterMenuBar(551): setRunning(true, local) 2019-02-21 09:36:26,317 INFO [StandardJMeterEngine] o.a.j.e.StandardJMeterEngine(453): Starting ThreadGroup: 1 : listener tg 2019-02-21 09:36:26,317 INFO [StandardJMeterEngine] o.a.j.e.StandardJMeterEngine(513): Starting 40 threads for group listener tg.

johrstrom commented 5 years ago

This happens because a metric is defined in two separate places (for skipping certain samplers), but with different labels. This issue specifically I found in the example given in this repo and just fixed.

I'll keep this ticket open to maybe detect when that occurs and send a reasonable message to the user about what the issue is.

johrstrom commented 5 years ago

I fixed this by simply syncing on the server to start and stop it.