package brave.http;

import com.google.inject.Module;
import com.google.inject.util.Modules;
import ratpack.guice.Guice;
import ratpack.test.embed.EmbeddedApp;
import ratpack.zipkin.ServerTracingModule;

import java.net.URI;

public class ITServerTracingModule extends ITHttpServer {
  private EmbeddedApp app;
  @Override
  protected void init() throws Exception {
    Module tracingModule = Modules
        .override(new ServerTracingModule())
        .with(binder -> binder.bind(HttpTracing.class).toInstance(httpTracing));
    app = EmbeddedApp
        .of(server ->
            server.registry(Guice.registry(binding -> binding.module(tracingModule)))
                  .handlers(chain -> chain
                      .get("/foo", ctx -> ctx.getResponse().send("bar"))
                      .get("/badrequest", ctx -> ctx.getResponse().status(400).send())
                      .get("/child", ctx -> {
                        HttpTracing httpTracing = ctx.get(HttpTracing.class);
                        httpTracing.tracing().tracer().nextSpan().name("child").start().finish();
                        ctx.getResponse().send("happy");
                      })
                      .all(ctx -> ctx.getResponse().status(500).send()))
        );
  }

  @Override
  protected String url(final String path) {
    URI uri = app.getAddress();
    return String
        .format("%s://%s:%d/%s", uri.getScheme(), "127.0.0.1", uri.getPort(), path);
  }

}

@@ -114,16 +114,44 @@
 .Guice;%0A
+import ratpack.http.Status;%0A
 import r
@@ -1185,16 +1185,92 @@
      %7D)%0A
+                      .get(%22/extra%22, ctx -%3E ctx.getResponse().send(%22joey%22))%0A
         

Fix ITServerTracingModule