From 7312f9809409904c9a35de7b99f049c232984ac3 Mon Sep 17 00:00:00 2001 From: Simon Stewart Date: Wed, 14 Nov 2018 07:53:39 +0000 Subject: [PATCH] Ensure that the tracing library does not touch the old grid code --- .../src/org/openqa/selenium/remote/BUCK | 5 ----- .../org/openqa/selenium/remote/tracing/BUCK | 22 +++++++++++++++++++ .../org/openqa/selenium/remote/tracing/BUCK | 2 ++ .../org/openqa/selenium/grid/commands/BUCK | 3 ++- .../openqa/selenium/grid/commands/Hub.java | 6 +++-- .../selenium/grid/commands/Standalone.java | 7 ++++-- .../org/openqa/selenium/grid/distributor/BUCK | 2 +- .../selenium/grid/distributor/httpd/BUCK | 3 ++- .../distributor/httpd/DistributorServer.java | 3 ++- .../selenium/grid/distributor/local/BUCK | 4 ++-- .../selenium/grid/distributor/remote/BUCK | 4 ++-- .../src/org/openqa/selenium/grid/node/BUCK | 1 + .../org/openqa/selenium/grid/node/httpd/BUCK | 1 + .../selenium/grid/node/httpd/NodeServer.java | 11 +++++----- .../org/openqa/selenium/grid/node/local/BUCK | 3 ++- .../org/openqa/selenium/grid/node/remote/BUCK | 3 ++- .../openqa/selenium/grid/router/httpd/BUCK | 3 ++- .../grid/router/httpd/RouterServer.java | 3 ++- .../selenium/grid/server/BaseServer.java | 7 ++---- .../grid/server/CommandHandlerServlet.java | 21 +++++------------- .../org/openqa/selenium/grid/sessionmap/BUCK | 5 +++-- .../selenium/grid/sessionmap/httpd/BUCK | 3 ++- .../sessionmap/httpd/SessionMapServer.java | 7 +++++- .../remote/server/SeleniumServer.java | 5 +---- .../org/openqa/selenium/grid/distributor/BUCK | 4 ++-- .../test/org/openqa/selenium/grid/node/BUCK | 3 ++- .../test/org/openqa/selenium/grid/router/BUCK | 3 ++- .../selenium/grid/router/EndToEndTest.java | 3 +-- .../selenium/grid/server/BaseServerTest.java | 10 ++++----- .../server/CommandHandlerServletTest.java | 4 ---- third_party/java/contrib/BUCK | 2 +- third_party/java/opencensus/BUCK | 2 +- third_party/java/opentracing/BUCK | 7 +++--- 33 files changed, 97 insertions(+), 75 deletions(-) create mode 100644 java/client/src/org/openqa/selenium/remote/tracing/BUCK diff --git a/java/client/src/org/openqa/selenium/remote/BUCK b/java/client/src/org/openqa/selenium/remote/BUCK index e8865f1b35c19..61e11dfefc6e7 100644 --- a/java/client/src/org/openqa/selenium/remote/BUCK +++ b/java/client/src/org/openqa/selenium/remote/BUCK @@ -122,7 +122,6 @@ java_library(name = 'remote-lib', 'mobile/RemoteNetworkConnection.java', ] + glob([ 'service/*.java', - 'tracing/*.java', ]), resources = [ ':get-attribute', @@ -134,14 +133,10 @@ java_library(name = 'remote-lib', '//java/client/src/org/openqa/selenium/json:json', '//java/client/src/org/openqa/selenium/remote/session:session', '//third_party/java/okhttp3:okhttp', - '//third_party/java/opencensus:opencensus-api', - '//third_party/java/opentracing:opentracing-api', ], deps = [ ':http-session-id', '//java/client/src/org/openqa/selenium:selenium', - '//third_party/java/contrib:opentracing-tracerresolver', - '//third_party/java/opentracing:opentracing-noop', '//third_party/java/guava:guava', ], ) diff --git a/java/client/src/org/openqa/selenium/remote/tracing/BUCK b/java/client/src/org/openqa/selenium/remote/tracing/BUCK new file mode 100644 index 0000000000000..e3df330618d78 --- /dev/null +++ b/java/client/src/org/openqa/selenium/remote/tracing/BUCK @@ -0,0 +1,22 @@ + +java_library( + name = "tracing", + srcs = glob(["*.java"]), + exported_deps = [ + # Required for the "register" API + "//third_party/java/opencensus:opencensus-api", + "//third_party/java/opentracing:opentracing-api", + ], + deps = [ + "//java/client/src/org/openqa/selenium/remote:remote", + '//third_party/java/contrib:opentracing-tracerresolver', + "//third_party/java/guava:guava", + "//third_party/java/opentracing:opentracing-noop", + "//third_party/java/opentracing:opentracing-util", + ], + visibility = [ + "//java/client/test/org/openqa/selenium/remote/tracing:", + "//java/server/src/org/openqa/selenium/grid/...", + "//java/server/test/org/openqa/selenium/grid/...", + ], +) diff --git a/java/client/test/org/openqa/selenium/remote/tracing/BUCK b/java/client/test/org/openqa/selenium/remote/tracing/BUCK index 15560b305e035..5d043fee3ad7a 100644 --- a/java/client/test/org/openqa/selenium/remote/tracing/BUCK +++ b/java/client/test/org/openqa/selenium/remote/tracing/BUCK @@ -7,6 +7,8 @@ java_test( srcs = glob(["*.java"]), deps = [ "//java/client/src/org/openqa/selenium/remote:remote", + "//java/client/src/org/openqa/selenium/remote/tracing:tracing", + "//java/client/test/org/openqa/selenium/remote/tracing/simple:simple", "//java/client/test/org/openqa/selenium/environment:environment", "//java/client/test/org/openqa/selenium/remote/tracing/simple:simple", "//third_party/java/assertj:assertj", diff --git a/java/server/src/org/openqa/selenium/grid/commands/BUCK b/java/server/src/org/openqa/selenium/grid/commands/BUCK index d0e190923b4e0..0b8cc454e6b37 100644 --- a/java/server/src/org/openqa/selenium/grid/commands/BUCK +++ b/java/server/src/org/openqa/selenium/grid/commands/BUCK @@ -14,6 +14,7 @@ java_library( 'com.google.auto.service.processor.AutoServiceProcessor', ], deps = [ + "//java/client/src/org/openqa/selenium/remote/tracing:tracing", "//java/server/src/org/openqa/selenium/cli:cli", "//java/server/src/org/openqa/selenium/grid/config:config", "//java/server/src/org/openqa/selenium/grid/distributor:distributor", @@ -31,4 +32,4 @@ java_library( "//java/server/src/org/openqa/selenium/grid:", "//java/server/src/org/openqa/selenium/grid:" ], -) \ No newline at end of file +) diff --git a/java/server/src/org/openqa/selenium/grid/commands/Hub.java b/java/server/src/org/openqa/selenium/grid/commands/Hub.java index 9bc83e2ed261c..773a3fdf07a88 100644 --- a/java/server/src/org/openqa/selenium/grid/commands/Hub.java +++ b/java/server/src/org/openqa/selenium/grid/commands/Hub.java @@ -88,14 +88,16 @@ public Executable configure(String... args) { new EnvConfig(), new ConcatenatingConfig("selenium", '.', System.getProperties())); - DistributedTracer tracer = DistributedTracer.getInstance(); + DistributedTracer tracer = DistributedTracer.builder() + .registerDetectedTracers() + .build(); + DistributedTracer.setInstance(tracer); SessionMap sessions = new LocalSessionMap(); Distributor distributor = new LocalDistributor(tracer); Router router = new Router(sessions, distributor); Server server = new BaseServer<>( - tracer, new BaseServerOptions(config)); server.addRoute(Routes.matching(router).using(router).decorateWith(W3CCommandHandler.class)); server.start(); diff --git a/java/server/src/org/openqa/selenium/grid/commands/Standalone.java b/java/server/src/org/openqa/selenium/grid/commands/Standalone.java index 6e3c7c21925c3..2a135bec9fcbb 100644 --- a/java/server/src/org/openqa/selenium/grid/commands/Standalone.java +++ b/java/server/src/org/openqa/selenium/grid/commands/Standalone.java @@ -94,7 +94,10 @@ public Executable configure(String... args) { new EnvConfig(), new ConcatenatingConfig("selenium", '.', System.getProperties())); - DistributedTracer tracer = DistributedTracer.getInstance(); + DistributedTracer tracer = DistributedTracer.builder() + .registerDetectedTracers() + .build(); + DistributedTracer.setInstance(tracer); SessionMap sessions = new LocalSessionMap(); Distributor distributor = new LocalDistributor(tracer); @@ -122,7 +125,7 @@ public Executable configure(String... args) { distributor.add(node.build()); - Server server = new BaseServer<>(tracer, new BaseServerOptions(config)); + Server server = new BaseServer<>(new BaseServerOptions(config)); server.addRoute(Routes.matching(router).using(router).decorateWith(W3CCommandHandler.class)); server.start(); }; diff --git a/java/server/src/org/openqa/selenium/grid/distributor/BUCK b/java/server/src/org/openqa/selenium/grid/distributor/BUCK index 63e406fff24d1..78e9f1a955ed4 100644 --- a/java/server/src/org/openqa/selenium/grid/distributor/BUCK +++ b/java/server/src/org/openqa/selenium/grid/distributor/BUCK @@ -7,7 +7,7 @@ java_library( "//java/server/src/org/openqa/selenium/grid/node:node", ], deps = [ - "//java/client/src/org/openqa/selenium/remote:remote", + "//java/client/src/org/openqa/selenium/remote/tracing:tracing", "//java/server/src/org/openqa/selenium/grid/config:config", "//java/server/src/org/openqa/selenium/grid/node/remote:remote", "//java/server/src/org/openqa/selenium/grid/server:server", diff --git a/java/server/src/org/openqa/selenium/grid/distributor/httpd/BUCK b/java/server/src/org/openqa/selenium/grid/distributor/httpd/BUCK index a6f7d6bf0a70e..ef16fc20cd71e 100644 --- a/java/server/src/org/openqa/selenium/grid/distributor/httpd/BUCK +++ b/java/server/src/org/openqa/selenium/grid/distributor/httpd/BUCK @@ -3,6 +3,7 @@ java_library( name = "httpd", srcs = glob(["*.java"]), deps = [ + "//java/client/src/org/openqa/selenium/remote/tracing:tracing", "//java/server/src/org/openqa/selenium/cli:cli", "//java/server/src/org/openqa/selenium/grid/config:config", "//java/server/src/org/openqa/selenium/grid/distributor:distributor", @@ -25,4 +26,4 @@ java_library( visibility = [ "//java/server/src/org/openqa/selenium/grid:" ], -) \ No newline at end of file +) diff --git a/java/server/src/org/openqa/selenium/grid/distributor/httpd/DistributorServer.java b/java/server/src/org/openqa/selenium/grid/distributor/httpd/DistributorServer.java index 5c1fa46a0068b..14934be46e446 100644 --- a/java/server/src/org/openqa/selenium/grid/distributor/httpd/DistributorServer.java +++ b/java/server/src/org/openqa/selenium/grid/distributor/httpd/DistributorServer.java @@ -87,12 +87,13 @@ public Executable configure(String... args) { DistributedTracer tracer = DistributedTracer.builder() .registerDetectedTracers() .build(); + DistributedTracer.setInstance(tracer); Distributor distributor = new LocalDistributor(tracer); BaseServerOptions serverOptions = new BaseServerOptions(config); - Server server = new BaseServer<>(tracer, serverOptions); + Server server = new BaseServer<>(serverOptions); server.addRoute( Routes.matching(distributor) .using(distributor) diff --git a/java/server/src/org/openqa/selenium/grid/distributor/local/BUCK b/java/server/src/org/openqa/selenium/grid/distributor/local/BUCK index e9010f1122d23..9f254090092cc 100644 --- a/java/server/src/org/openqa/selenium/grid/distributor/local/BUCK +++ b/java/server/src/org/openqa/selenium/grid/distributor/local/BUCK @@ -6,7 +6,7 @@ java_library( "//java/server/src/org/openqa/selenium/grid/distributor:distributor", ], deps = [ - "//java/client/src/org/openqa/selenium/remote:remote", + "//java/client/src/org/openqa/selenium/remote/tracing:tracing", "//java/server/src/org/openqa/selenium/grid/web:web", "//java/server/src/org/openqa/selenium/grid/node:node", "//java/server/src/org/openqa/selenium/grid/node/remote:remote", @@ -16,4 +16,4 @@ java_library( "//java/server/src/org/openqa/selenium/grid/...", "//java/server/test/org/openqa/selenium/grid/...", ] -) \ No newline at end of file +) diff --git a/java/server/src/org/openqa/selenium/grid/distributor/remote/BUCK b/java/server/src/org/openqa/selenium/grid/distributor/remote/BUCK index 563f447655a0c..b123f6f2f92b3 100644 --- a/java/server/src/org/openqa/selenium/grid/distributor/remote/BUCK +++ b/java/server/src/org/openqa/selenium/grid/distributor/remote/BUCK @@ -6,11 +6,11 @@ java_library( "//java/server/src/org/openqa/selenium/grid/distributor:distributor", ], deps = [ - "//java/client/src/org/openqa/selenium/remote:remote", + "//java/client/src/org/openqa/selenium/remote/tracing:tracing", "//java/server/src/org/openqa/selenium/grid/web:web", ], visibility = [ "//java/server/src/org/openqa/selenium/grid/...", "//java/server/test/org/openqa/selenium/grid/...", ] -) \ No newline at end of file +) diff --git a/java/server/src/org/openqa/selenium/grid/node/BUCK b/java/server/src/org/openqa/selenium/grid/node/BUCK index ea23572c1e349..166a4bcac7354 100644 --- a/java/server/src/org/openqa/selenium/grid/node/BUCK +++ b/java/server/src/org/openqa/selenium/grid/node/BUCK @@ -8,6 +8,7 @@ java_library( "//java/server/src/org/openqa/selenium/grid/data:data", ], deps = [ + "//java/client/src/org/openqa/selenium/remote/tracing:tracing", "//java/server/src/org/openqa/selenium/grid/server:server", "//java/server/src/org/openqa/selenium/grid/sessionmap:sessionmap", "//java/server/src/org/openqa/selenium/grid/web:web", diff --git a/java/server/src/org/openqa/selenium/grid/node/httpd/BUCK b/java/server/src/org/openqa/selenium/grid/node/httpd/BUCK index f76dbb12f8518..c266668c04f6b 100644 --- a/java/server/src/org/openqa/selenium/grid/node/httpd/BUCK +++ b/java/server/src/org/openqa/selenium/grid/node/httpd/BUCK @@ -14,6 +14,7 @@ java_library( 'com.google.auto.service.processor.AutoServiceProcessor', ], deps = [ + "//java/client/src/org/openqa/selenium/remote/tracing:tracing", "//java/server/src/org/openqa/selenium/cli:cli", "//java/server/src/org/openqa/selenium/concurrent:concurrent", "//java/server/src/org/openqa/selenium/grid/config:config", diff --git a/java/server/src/org/openqa/selenium/grid/node/httpd/NodeServer.java b/java/server/src/org/openqa/selenium/grid/node/httpd/NodeServer.java index dc9b87e6829b1..7db2b3eed63b9 100644 --- a/java/server/src/org/openqa/selenium/grid/node/httpd/NodeServer.java +++ b/java/server/src/org/openqa/selenium/grid/node/httpd/NodeServer.java @@ -101,6 +101,11 @@ public Executable configure(String... args) { new EnvConfig(), new ConcatenatingConfig("node", '.', System.getProperties())); + DistributedTracer tracer = DistributedTracer.builder() + .registerDetectedTracers() + .build(); + DistributedTracer.setInstance(tracer); + SessionMapOptions sessionsOptions = new SessionMapOptions(config); URL sessionMapUrl = sessionsOptions.getSessionMapUri().toURL(); SessionMap sessions = new RemoteSessionMap( @@ -108,10 +113,6 @@ public Executable configure(String... args) { BaseServerOptions serverOptions = new BaseServerOptions(config); - DistributedTracer tracer = DistributedTracer.builder() - .registerDetectedTracers() - .build(); - LocalNode.Builder builder = LocalNode.builder( tracer, serverOptions.getExternalUri(), @@ -125,7 +126,7 @@ public Executable configure(String... args) { tracer, HttpClient.Factory.createDefault().createClient(distributorUrl)); - Server server = new BaseServer<>(tracer, serverOptions); + Server server = new BaseServer<>(serverOptions); server.addRoute(Routes.matching(node).using(node).decorateWith(W3CCommandHandler.class)); server.start(); diff --git a/java/server/src/org/openqa/selenium/grid/node/local/BUCK b/java/server/src/org/openqa/selenium/grid/node/local/BUCK index e5b7f77604ba2..f73ed4b0d91ad 100644 --- a/java/server/src/org/openqa/selenium/grid/node/local/BUCK +++ b/java/server/src/org/openqa/selenium/grid/node/local/BUCK @@ -3,6 +3,7 @@ java_library( name = "local", srcs = glob(["*.java"]), deps = [ + "//java/client/src/org/openqa/selenium/remote/tracing:tracing", "//java/server/src/org/openqa/selenium/grid/config:config", "//java/server/src/org/openqa/selenium/grid/node:node", "//java/server/src/org/openqa/selenium/grid/sessionmap:sessionmap", @@ -14,4 +15,4 @@ java_library( "//java/server/src/org/openqa/selenium/grid/...", "//java/server/test/org/openqa/selenium/grid/...", ], -) \ No newline at end of file +) diff --git a/java/server/src/org/openqa/selenium/grid/node/remote/BUCK b/java/server/src/org/openqa/selenium/grid/node/remote/BUCK index 96590c7f98670..555177eef4eb4 100644 --- a/java/server/src/org/openqa/selenium/grid/node/remote/BUCK +++ b/java/server/src/org/openqa/selenium/grid/node/remote/BUCK @@ -3,6 +3,7 @@ java_library( name = "remote", srcs = glob(["*.java"]), deps = [ + "//java/client/src/org/openqa/selenium/remote/tracing:tracing", "//java/server/src/org/openqa/selenium/grid/data:data", "//java/server/src/org/openqa/selenium/grid/node:node", "//java/server/src/org/openqa/selenium/grid/web:web", @@ -12,4 +13,4 @@ java_library( "//java/server/src/org/openqa/selenium/grid/...", "//java/server/test/org/openqa/selenium/grid/...", ], -) \ No newline at end of file +) diff --git a/java/server/src/org/openqa/selenium/grid/router/httpd/BUCK b/java/server/src/org/openqa/selenium/grid/router/httpd/BUCK index 9b881f70241b6..c44de6ed588e8 100644 --- a/java/server/src/org/openqa/selenium/grid/router/httpd/BUCK +++ b/java/server/src/org/openqa/selenium/grid/router/httpd/BUCK @@ -14,6 +14,7 @@ java_library( 'com.google.auto.service.processor.AutoServiceProcessor', ], deps = [ + "//java/client/src/org/openqa/selenium/remote/tracing:tracing", "//java/server/src/org/openqa/selenium/cli:cli", "//java/server/src/org/openqa/selenium/grid/config:config", "//java/server/src/org/openqa/selenium/grid/distributor:distributor", @@ -29,4 +30,4 @@ java_library( visibility = [ "//java/server/src/org/openqa/selenium/grid:" ], -) \ No newline at end of file +) diff --git a/java/server/src/org/openqa/selenium/grid/router/httpd/RouterServer.java b/java/server/src/org/openqa/selenium/grid/router/httpd/RouterServer.java index 4409958a1ddf9..1a0af60896fc0 100644 --- a/java/server/src/org/openqa/selenium/grid/router/httpd/RouterServer.java +++ b/java/server/src/org/openqa/selenium/grid/router/httpd/RouterServer.java @@ -98,6 +98,7 @@ public Executable configure(String... args) { DistributedTracer tracer = DistributedTracer.builder() .registerDetectedTracers() .build(); + DistributedTracer.setInstance(tracer); SessionMapOptions sessionsOptions = new SessionMapOptions(config); URL sessionMapUrl = sessionsOptions.getSessionMapUri().toURL(); @@ -114,7 +115,7 @@ public Executable configure(String... args) { Router router = new Router(sessions, distributor); - Server server = new BaseServer<>(tracer, serverOptions); + Server server = new BaseServer<>(serverOptions); server.addRoute(Routes.matching(router).using(router).decorateWith(W3CCommandHandler.class)); server.start(); }; diff --git a/java/server/src/org/openqa/selenium/grid/server/BaseServer.java b/java/server/src/org/openqa/selenium/grid/server/BaseServer.java index 82bc2eafc7d39..af5dcfe514b53 100644 --- a/java/server/src/org/openqa/selenium/grid/server/BaseServer.java +++ b/java/server/src/org/openqa/selenium/grid/server/BaseServer.java @@ -32,7 +32,6 @@ import org.openqa.selenium.net.NetworkUtils; import org.openqa.selenium.net.PortProber; import org.openqa.selenium.remote.http.HttpRequest; -import org.openqa.selenium.remote.tracing.DistributedTracer; import org.seleniumhq.jetty9.security.ConstraintMapping; import org.seleniumhq.jetty9.security.ConstraintSecurityHandler; import org.seleniumhq.jetty9.server.Connector; @@ -71,10 +70,8 @@ public class BaseServer implements Server { private final ServletContextHandler servletContextHandler; private final Injector injector; private final URL url; - private final DistributedTracer tracer; - public BaseServer(DistributedTracer tracer, BaseServerOptions options) { - this.tracer = Objects.requireNonNull(tracer); + public BaseServer(BaseServerOptions options) { int port = options.getPort() == 0 ? PortProber.findFreePort() : options.getPort(); String host = options.getHostname().orElseGet(() -> { @@ -200,7 +197,7 @@ public T start() { .decorateWith(W3CCommandHandler.class) .build(); - addServlet(new CommandHandlerServlet(tracer, routes), "/*"); + addServlet(new CommandHandlerServlet(routes), "/*"); server.start(); diff --git a/java/server/src/org/openqa/selenium/grid/server/CommandHandlerServlet.java b/java/server/src/org/openqa/selenium/grid/server/CommandHandlerServlet.java index eb65d2053f5bc..83e49a319f6e9 100644 --- a/java/server/src/org/openqa/selenium/grid/server/CommandHandlerServlet.java +++ b/java/server/src/org/openqa/selenium/grid/server/CommandHandlerServlet.java @@ -26,9 +26,6 @@ import org.openqa.selenium.json.Json; import org.openqa.selenium.remote.http.HttpRequest; import org.openqa.selenium.remote.http.HttpResponse; -import org.openqa.selenium.remote.tracing.DistributedTracer; -import org.openqa.selenium.remote.tracing.HttpTracing; -import org.openqa.selenium.remote.tracing.Span; import java.io.IOException; import java.util.Objects; @@ -42,10 +39,8 @@ class CommandHandlerServlet extends HttpServlet { private final Routes routes; private final Injector injector; - private final DistributedTracer tracer; - public CommandHandlerServlet(DistributedTracer tracer, Routes routes) { - this.tracer = Objects.requireNonNull(tracer); + public CommandHandlerServlet(Routes routes) { Objects.requireNonNull(routes); this.routes = combine(routes) .fallbackTo( @@ -62,15 +57,11 @@ protected void service(HttpServletRequest req, HttpServletResponse resp) throws HttpRequest request = new ServletRequestWrappingHttpRequest(req); HttpResponse response = new ServletResponseWrappingHttpResponse(resp); -// log(String.format("(%s) %s", request.getMethod(), request.getUri())); - - try (Span span = HttpTracing.extract(tracer, "selenium.httpservlet", request)) { - Optional possibleMatch = routes.match(injector, request); - if (possibleMatch.isPresent()) { - possibleMatch.get().execute(request, response); - } else { - throw new IllegalStateException("It should not be possible to get here"); - } + Optional possibleMatch = routes.match(injector, request); + if (possibleMatch.isPresent()) { + possibleMatch.get().execute(request, response); + } else { + throw new IllegalStateException("It should not be possible to get here"); } } } diff --git a/java/server/src/org/openqa/selenium/grid/sessionmap/BUCK b/java/server/src/org/openqa/selenium/grid/sessionmap/BUCK index d36a1bdc0c06f..b4ca1ad32b115 100644 --- a/java/server/src/org/openqa/selenium/grid/sessionmap/BUCK +++ b/java/server/src/org/openqa/selenium/grid/sessionmap/BUCK @@ -3,7 +3,8 @@ java_library( name = "sessionmap", srcs = glob(["*.java"]), deps = [ - "//java/client/src/org/openqa/selenium/remote:remote", +# "//java/client/src/org/openqa/selenium/remote:remote", + "//java/client/src/org/openqa/selenium/remote/tracing:tracing", "//java/server/src/org/openqa/selenium/grid/config:config", "//java/server/src/org/openqa/selenium/grid/data:data", "//java/server/src/org/openqa/selenium/grid/web:web", @@ -14,4 +15,4 @@ java_library( "//java/server/src/org/openqa/selenium/grid/...", "//java/server/test/org/openqa/selenium/grid/...", ] -) \ No newline at end of file +) diff --git a/java/server/src/org/openqa/selenium/grid/sessionmap/httpd/BUCK b/java/server/src/org/openqa/selenium/grid/sessionmap/httpd/BUCK index 4ad6b63ff48cd..4b3d21c4f7176 100644 --- a/java/server/src/org/openqa/selenium/grid/sessionmap/httpd/BUCK +++ b/java/server/src/org/openqa/selenium/grid/sessionmap/httpd/BUCK @@ -3,6 +3,7 @@ java_library( name = "httpd", srcs = glob(["*.java"]), deps = [ + "//java/client/src/org/openqa/selenium/remote/tracing:tracing", "//java/server/src/org/openqa/selenium/cli:cli", "//java/server/src/org/openqa/selenium/grid/config:config", "//java/server/src/org/openqa/selenium/grid/server:server", @@ -25,4 +26,4 @@ java_library( visibility = [ "//java/server/src/org/openqa/selenium/grid:" ], -) \ No newline at end of file +) diff --git a/java/server/src/org/openqa/selenium/grid/sessionmap/httpd/SessionMapServer.java b/java/server/src/org/openqa/selenium/grid/sessionmap/httpd/SessionMapServer.java index 9ef059af2a77a..a1e5882318534 100644 --- a/java/server/src/org/openqa/selenium/grid/sessionmap/httpd/SessionMapServer.java +++ b/java/server/src/org/openqa/selenium/grid/sessionmap/httpd/SessionMapServer.java @@ -84,11 +84,16 @@ public Executable configure(String... args) { new EnvConfig(), new ConcatenatingConfig("sessions", '.', System.getProperties())); + DistributedTracer tracer = DistributedTracer.builder() + .registerDetectedTracers() + .build(); + DistributedTracer.setInstance(tracer); + SessionMap sessions = new LocalSessionMap(); BaseServerOptions serverOptions = new BaseServerOptions(config); - Server server = new BaseServer<>(DistributedTracer.getInstance(), serverOptions); + Server server = new BaseServer<>(serverOptions); server.addRoute(matching(sessions).using(sessions).decorateWith(W3CCommandHandler.class)); server.start(); }; diff --git a/java/server/src/org/openqa/selenium/remote/server/SeleniumServer.java b/java/server/src/org/openqa/selenium/remote/server/SeleniumServer.java index cda185d8c28f7..661d329f03763 100644 --- a/java/server/src/org/openqa/selenium/remote/server/SeleniumServer.java +++ b/java/server/src/org/openqa/selenium/remote/server/SeleniumServer.java @@ -38,7 +38,6 @@ import org.openqa.selenium.json.Json; import org.openqa.selenium.remote.server.jmx.JMXHelper; import org.openqa.selenium.remote.server.jmx.ManagedService; -import org.openqa.selenium.remote.tracing.DistributedTracer; import java.util.Map; import java.util.logging.Logger; @@ -63,9 +62,7 @@ public class SeleniumServer extends BaseServer implements GridNodeServer { private ActiveSessions allSessions; public SeleniumServer(StandaloneConfiguration configuration) { - super( - DistributedTracer.getInstance(), - new BaseServerOptions(new AnnotatedConfig(configuration))); + super(new BaseServerOptions(new AnnotatedConfig(configuration))); this.configuration = configuration; objectName = new JMXHelper().register(this).getObjectName(); diff --git a/java/server/test/org/openqa/selenium/grid/distributor/BUCK b/java/server/test/org/openqa/selenium/grid/distributor/BUCK index 096d2d1533a2d..9e4c5e1ce418d 100644 --- a/java/server/test/org/openqa/selenium/grid/distributor/BUCK +++ b/java/server/test/org/openqa/selenium/grid/distributor/BUCK @@ -3,7 +3,7 @@ java_test( name = "distributor", srcs = glob(["*.java"]), deps = [ - "//java/client/src/org/openqa/selenium/remote:remote", + "//java/client/src/org/openqa/selenium/remote/tracing:tracing", "//java/server/src/org/openqa/selenium/grid/distributor:distributor", "//java/server/src/org/openqa/selenium/grid/distributor/local:local", "//java/server/src/org/openqa/selenium/grid/distributor/remote:remote", @@ -16,4 +16,4 @@ java_test( "//third_party/java/assertj:assertj", "//third_party/java/junit:junit", ] -) \ No newline at end of file +) diff --git a/java/server/test/org/openqa/selenium/grid/node/BUCK b/java/server/test/org/openqa/selenium/grid/node/BUCK index 498190e168a90..72be0d96d2d66 100644 --- a/java/server/test/org/openqa/selenium/grid/node/BUCK +++ b/java/server/test/org/openqa/selenium/grid/node/BUCK @@ -6,6 +6,7 @@ java_test( "small", ], deps = [ + "//java/client/src/org/openqa/selenium/remote/tracing:tracing", "//java/server/src/org/openqa/selenium/grid/node:node", "//java/server/src/org/openqa/selenium/grid/node/local:local", "//java/server/src/org/openqa/selenium/grid/node/remote:remote", @@ -17,4 +18,4 @@ java_test( "//third_party/java/guava:guava", "//third_party/java/junit:junit", ], -) \ No newline at end of file +) diff --git a/java/server/test/org/openqa/selenium/grid/router/BUCK b/java/server/test/org/openqa/selenium/grid/router/BUCK index 2634dbeeb8ffb..a88fb81c7bff8 100644 --- a/java/server/test/org/openqa/selenium/grid/router/BUCK +++ b/java/server/test/org/openqa/selenium/grid/router/BUCK @@ -3,6 +3,7 @@ java_test( name = "router", srcs = glob(["*.java"]), deps = [ + "//java/client/src/org/openqa/selenium/remote/tracing:tracing", "//java/server/src/org/openqa/selenium/grid/config:config", "//java/server/src/org/openqa/selenium/grid/distributor:distributor", "//java/server/src/org/openqa/selenium/grid/distributor/local:local", @@ -20,4 +21,4 @@ java_test( "//third_party/java/guava:guava", "//third_party/java/junit:junit", ] -) \ No newline at end of file +) diff --git a/java/server/test/org/openqa/selenium/grid/router/EndToEndTest.java b/java/server/test/org/openqa/selenium/grid/router/EndToEndTest.java index 4cfcfbb49dcb3..e56935984f28c 100644 --- a/java/server/test/org/openqa/selenium/grid/router/EndToEndTest.java +++ b/java/server/test/org/openqa/selenium/grid/router/EndToEndTest.java @@ -106,7 +106,6 @@ public void withServers() throws URISyntaxException { .add(driverCaps, createFactory(nodeUri)) .build(); Server nodeServer = new BaseServer<>( - DistributedTracer.builder().build(), new BaseServerOptions( new MapConfig(ImmutableMap.of("server", ImmutableMap.of("port", port))))); nodeServer.addRoute(Routes.matching(localNode).using(localNode)); @@ -128,7 +127,7 @@ private HttpClient getClient(Server server) { private Server createServer() { int port = PortProber.findFreePort(); - return new BaseServer<>(DistributedTracer.builder().build(), new BaseServerOptions( + return new BaseServer<>(new BaseServerOptions( new MapConfig(ImmutableMap.of("server", ImmutableMap.of("port", port))))); } diff --git a/java/server/test/org/openqa/selenium/grid/server/BaseServerTest.java b/java/server/test/org/openqa/selenium/grid/server/BaseServerTest.java index 5b1723a4a12e3..fbb46755be6a0 100644 --- a/java/server/test/org/openqa/selenium/grid/server/BaseServerTest.java +++ b/java/server/test/org/openqa/selenium/grid/server/BaseServerTest.java @@ -32,7 +32,6 @@ import org.openqa.selenium.remote.http.HttpClient; import org.openqa.selenium.remote.http.HttpRequest; import org.openqa.selenium.remote.http.HttpResponse; -import org.openqa.selenium.remote.tracing.DistributedTracer; import java.io.IOException; import java.net.URL; @@ -40,11 +39,10 @@ public class BaseServerTest { private BaseServerOptions emptyOptions = new BaseServerOptions(new MapConfig(ImmutableMap.of())); - private DistributedTracer tracer = DistributedTracer.builder().build(); @Test public void baseServerStartsAndDoesNothing() throws IOException { - Server server = new BaseServer<>(tracer, emptyOptions).start(); + Server server = new BaseServer<>(emptyOptions).start(); URL url = server.getUrl(); HttpClient client = HttpClient.Factory.createDefault().createClient(url); @@ -59,7 +57,7 @@ public void baseServerStartsAndDoesNothing() throws IOException { @Test public void shouldAllowAHandlerToBeRegistered() throws IOException { - Server server = new BaseServer<>(tracer, emptyOptions); + Server server = new BaseServer<>(emptyOptions); server.addRoute(get("/cheese").using((req, res) -> res.setContent("cheddar".getBytes(UTF_8)))); server.start(); @@ -72,7 +70,7 @@ public void shouldAllowAHandlerToBeRegistered() throws IOException { @Test public void ifTwoHandlersRespondToTheSameRequestTheLastOneAddedWillBeUsed() throws IOException { - Server server = new BaseServer<>(tracer, emptyOptions); + Server server = new BaseServer<>(emptyOptions); server.addRoute(get("/status").using((req, res) -> res.setContent("one".getBytes(UTF_8)))); server.addRoute(get("/status").using((req, res) -> res.setContent("two".getBytes(UTF_8)))); @@ -87,7 +85,7 @@ public void ifTwoHandlersRespondToTheSameRequestTheLastOneAddedWillBeUsed() thro @Test public void addHandlersOnceServerIsStartedIsAnError() { - Server server = new BaseServer<>(tracer, emptyOptions); + Server server = new BaseServer<>(emptyOptions); server.start(); Assertions.assertThatExceptionOfType(IllegalStateException.class).isThrownBy( diff --git a/java/server/test/org/openqa/selenium/grid/server/CommandHandlerServletTest.java b/java/server/test/org/openqa/selenium/grid/server/CommandHandlerServletTest.java index f56631561f54a..8ca03c850d370 100644 --- a/java/server/test/org/openqa/selenium/grid/server/CommandHandlerServletTest.java +++ b/java/server/test/org/openqa/selenium/grid/server/CommandHandlerServletTest.java @@ -33,7 +33,6 @@ import org.openqa.selenium.remote.ErrorHandler; import org.openqa.selenium.remote.Response; import org.openqa.selenium.remote.http.HttpRequest; -import org.openqa.selenium.remote.tracing.DistributedTracer; import org.openqa.testing.FakeHttpServletRequest; import org.openqa.testing.FakeHttpServletResponse; import org.openqa.testing.UrlInfo; @@ -73,7 +72,6 @@ public void shouldReturnValueFromHandlerIfUrlMatches() throws IOException { String cheerfulGreeting = "Hello, world!"; CommandHandlerServlet servlet = new CommandHandlerServlet( - DistributedTracer.builder().build(), Routes.matching(req -> true).using((req, res) -> res.setContent(cheerfulGreeting.getBytes(UTF_8))).build()); HttpServletRequest request = requestConverter.apply(new HttpRequest(GET, "/hello-world")); @@ -88,7 +86,6 @@ public void shouldReturnValueFromHandlerIfUrlMatches() throws IOException { @Test public void shouldCorrectlyReturnAnUnknownCommandExceptionForUnmappableUrls() throws IOException { CommandHandlerServlet servlet = new CommandHandlerServlet( - DistributedTracer.builder().build(), Routes.matching(req -> false).using((req, res) -> {}).decorateWith(W3CCommandHandler.class).build()); HttpServletRequest request = requestConverter.apply(new HttpRequest(GET, "/missing")); @@ -105,7 +102,6 @@ public void exceptionsThrownByHandlersAreConvertedToAProperPayload() throws IOEx Injector injector = Injector.builder().register(new Json()).build(); CommandHandlerServlet servlet = new CommandHandlerServlet( - DistributedTracer.builder().build(), Routes.matching(req -> true).using((req, res) -> { throw new UnableToSetCookieException("Yowza"); }).decorateWith(W3CCommandHandler.class).build()); diff --git a/third_party/java/contrib/BUCK b/third_party/java/contrib/BUCK index 6afacefc97fc6..5de70e3c3d4ca 100644 --- a/third_party/java/contrib/BUCK +++ b/third_party/java/contrib/BUCK @@ -32,6 +32,6 @@ prebuilt_jar( '//third_party/java/opentracing:opentracing-util' ], visibility = [ - '//java/client/src/org/openqa/selenium/remote:', + '//java/client/src/org/openqa/selenium/remote/tracing:', ], ) diff --git a/third_party/java/opencensus/BUCK b/third_party/java/opencensus/BUCK index 8f8b60df16a20..ef7ff3002f080 100644 --- a/third_party/java/opencensus/BUCK +++ b/third_party/java/opencensus/BUCK @@ -7,7 +7,7 @@ prebuilt_jar( '//third_party/java/grpc:grpc-context' ], visibility = [ - '//java/client/src/org/openqa/selenium/remote:', + '//java/client/src/org/openqa/selenium/remote/tracing:', ], ) diff --git a/third_party/java/opentracing/BUCK b/third_party/java/opentracing/BUCK index 95309f8bb6835..921ddcf6c8ea2 100644 --- a/third_party/java/opentracing/BUCK +++ b/third_party/java/opentracing/BUCK @@ -5,7 +5,7 @@ prebuilt_jar( source_jar = 'opentracing-api-0.31.0-sources.jar', visibility = [ '//third_party/java/contrib:', - '//java/client/src/org/openqa/selenium/remote:', + '//java/client/src/org/openqa/selenium/remote/tracing:', ], ) @@ -18,9 +18,9 @@ prebuilt_jar( ':opentracing-api' ], visibility = [ + '//java/client/src/org/openqa/selenium/remote/tracing:', '//third_party/java/contrib:opentracing-concurrent', '//third_party/java/contrib:opentracing-okhttp3', - '//java/client/src/org/openqa/selenium/remote:', ], ) @@ -34,7 +34,8 @@ prebuilt_jar( ':opentracing-noop' ], visibility = [ - '//third_party/java/contrib:opentracing-tracerresolver', + '//java/client/src/org/openqa/selenium/remote/tracing:', '//java/client/test/org/openqa/selenium/remote/tracing/simple:', + '//third_party/java/contrib:opentracing-tracerresolver', ], )