Search in sources :

Example 1 with PrometheusMetricsProcessor

use of io.questdb.cutlass.http.processors.PrometheusMetricsProcessor in project questdb by bluestreak01.

the class HttpMinTestBuilder method run.

public void run(HttpQueryTestBuilder.HttpClientCode code) throws Exception {
    final int[] workerAffinity = new int[1];
    Arrays.fill(workerAffinity, -1);
    assertMemoryLeak(() -> {
        final String baseDir = temp.getRoot().getAbsolutePath();
        final DefaultHttpServerConfiguration httpConfiguration = new HttpServerConfigurationBuilder().withBaseDir(temp.getRoot().getAbsolutePath()).build();
        final WorkerPool workerPool = new WorkerPool(new WorkerPoolConfiguration() {

            @Override
            public int[] getWorkerAffinity() {
                return workerAffinity;
            }

            @Override
            public int getWorkerCount() {
                return workerAffinity.length;
            }

            @Override
            public boolean haltOnError() {
                return false;
            }
        });
        DefaultCairoConfiguration cairoConfiguration = new DefaultCairoConfiguration(baseDir);
        try (CairoEngine engine = new CairoEngine(cairoConfiguration);
            HttpServer httpServer = new HttpServer(httpConfiguration, workerPool, false)) {
            httpServer.bind(new HttpRequestProcessorFactory() {

                @Override
                public HttpRequestProcessor newInstance() {
                    return new PrometheusMetricsProcessor(metrics);
                }

                @Override
                public String getUrl() {
                    return "/metrics";
                }
            });
            QueryCache.configure(httpConfiguration);
            workerPool.start(LOG);
            try {
                code.run(engine);
            } finally {
                workerPool.halt();
            }
        }
    });
}
Also used : WorkerPool(io.questdb.mp.WorkerPool) DefaultCairoConfiguration(io.questdb.cairo.DefaultCairoConfiguration) PrometheusMetricsProcessor(io.questdb.cutlass.http.processors.PrometheusMetricsProcessor) CairoEngine(io.questdb.cairo.CairoEngine) WorkerPoolConfiguration(io.questdb.mp.WorkerPoolConfiguration)

Aggregations

CairoEngine (io.questdb.cairo.CairoEngine)1 DefaultCairoConfiguration (io.questdb.cairo.DefaultCairoConfiguration)1 PrometheusMetricsProcessor (io.questdb.cutlass.http.processors.PrometheusMetricsProcessor)1 WorkerPool (io.questdb.mp.WorkerPool)1 WorkerPoolConfiguration (io.questdb.mp.WorkerPoolConfiguration)1