void get(String path) throws IOException { client.newCall(new Request.Builder().url(baseUrl() + path).build()).execute().body().close(); } }
@Benchmark public void tracedExtraServer_get() throws Exception { get("/tracedextra"); }
@Override protected int initServer() throws Exception { return PORT = super.initServer(); }
@TearDown(Level.Trial) @Override public void close() throws Exception { server.stop(); super.close(); }
protected int initServer() throws Exception { DeploymentInfo servletBuilder = Servlets.deployment() .setClassLoader(getClass().getClassLoader()) .setContextPath("/") .setDeploymentName("test.war"); init(servletBuilder); DeploymentManager manager = Servlets.defaultContainer().addDeployment(servletBuilder); manager.deploy(); server = Undertow.builder() .addHttpListener(0, "127.0.0.1") .setHandler(manager.start()).build(); server.start(); return ((InetSocketAddress) server.getListenerInfo().get(0).getAddress()).getPort(); }
@Benchmark public void tracedCorrelatedServer_get() throws Exception { get("/tracedcorrelated"); }
@Benchmark public void tracedServer_get_resumeTrace() throws Exception { client.newCall(new Request.Builder().url(baseUrl() + "/traced") .header("X-B3-TraceId", "216a2aea45d08fc9") .header("X-B3-SpanId", "5b4185666d50f68b") .header("X-B3-Sampled", "1") .build()) .execute().body().close(); }
@Setup(Level.Trial) public void init() throws Exception { baseUrl = "http://127.0.0.1:" + initServer(); client = new OkHttpClient(); }
@Benchmark public void server_get() throws Exception { get("/nottraced"); }
@Benchmark public void traced128Server_get_resumeTrace() throws Exception { client.newCall(new Request.Builder().url(baseUrl() + "/traced128") .header("X-B3-TraceId", "5759e988b62e8f6a216a2aea45d08fc9") .header("X-B3-SpanId", "5b4185666d50f68b") .header("X-B3-Sampled", "1") .build()) .execute().body().close(); }
@Benchmark public void onlySampledLocalServer_get() throws Exception { get("/onlysampledlocal"); }
@Benchmark public void tracedExtraServer_get_request_id() throws Exception { client.newCall(new Request.Builder().url(baseUrl() + "/tracedextra") .header("x-vcap-request-id", "216a2aea45d08fc9") .build()) .execute().body().close(); }
@Benchmark public void tracedServer_get() throws Exception { get("/traced"); }
@Benchmark public void unsampledServer_get() throws Exception { get("/unsampled"); }
@Benchmark public void traced128Server_get() throws Exception { get("/traced128"); }