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

pom.xml #75

Open BLOPESLO opened 4 years ago

BLOPESLO commented 4 years ago

Hi, I execute the jmeter with Selenium in Java Class, is it possible to use this plugin integrated with this solution? what is the class/method to run the plugin and how is it configured?

Thanks

GiovanniPaoloGibilisco commented 4 years ago

Hi, I've never tried this setup before. I would point you to the PrometheusListener.java class and in particular, to the testStarted() function which is invoked by Jmeter when running the test. This function initializes the configuration and starts the exporter.

Most of the configuration actually sits inside the test script so it should not be fine. Hope this helps.

johrstrom commented 4 years ago

Yea I also don't know how to do this, but a tip would be to use it like you would any other Listener. If you currently use, say a simple data writer, then it would use the same interface(s) as that.

If you're invoking the test to execute through jmeter, then simply having it defined and attached to the thread group would be enough (I think?).

BLOPESLO commented 4 years ago

Hi, I am using the following code:

PrometheusListener teste=new PrometheusListener();
    teste.setProperty("prometheus.delay", "10");
    teste.setProperty("prometheus.ip", "ip server");
    teste.setProperty("prometheus.save.threads", "true");
    teste.addTestElement(testPlan);
    teste.testStarted();

    // Create TestPlan hash tree
    ListedHashTree testPlanHashTree = new ListedHashTree();
    testPlanHashTree.add(testPlan);

    // Add ThreadGroup to TestPlan hash tree
    testPlanHashTree.add(testPlan, headerManager);
    testPlanHashTree.add(testPlan, cacheManager);
    testPlanHashTree.add(testPlan, cookieManager);
    testPlanHashTree.add(testPlan, dnsManager);
    testPlanHashTree.add(testPlan, arguments);
    testPlanHashTree.add(testPlan, authManager);
    testPlanHashTree.add(testPlan, threadGroups);
    testPlanHashTree.add(teste);

Do you think it must be something like that?

Thanks