Selenium Grid ships with support for distributed tracing, backed by
the OpenTracing APIs. This allows admins and devops engineers to trace
the flow of control through the Grid for each and every command.

To enable this support, you must first provide a "Tracer"
implementation that should be used. We use OpenTracing's own
TracerResolver to find the Tracer to use, so if your chosen tracing
library supports this mechanism to (and most do!) you should be good
to go. If you are using the standalone selenium jar, updating the
classpath to contain your tracer can be done using the `--ext` flag to
selenium. As a worked example, using Jaeger as the tracing library and
running on macOS or Linux:

```
  java -jar selenium.jar \
       --ext $(coursier fetch -p io.jaegertracing:jaeger-client:1.0.0) \
       standalone
```

This example uses a tool called "coursier" to generate a full
classpath, but you can also write this manually. When started this
way, the selenium server will inform you that it has found a tracer on
stdout.

However, just making the tracer available is seldom enough. You must
also configure it to send diagnostics back. In the case of Jaeger,
this can be done via system properties. Modifying our example:

```
  java -DJAEGER_SERVICE_NAME="selenium-standalone" \
       -DJAEGER_AGENT_HOST=localhost \
       -DJAEGER_AGENT_PORT=6831 \
       -DJAEGER_SAMPLER_TYPE=const \
       -DJAEGER_SAMPLER_PARAM=1 \
       -jar selenium.jar \
       --ext $(coursier fetch -p io.jaegertracing:jaeger-client:1.0.0) \
       standalone
```

There are other popular tracing libraries that are supported by
OpenTracing, so please check their documentation for more information
on how to configure them.

You will also need to be running a tracing server somewhere. In the
case of Jaeger, you can do this using docker to fire up something
locally:

```
  docker run --rm -it  -e COLLECTOR_ZIPKIN_HTTP_PORT=9411 \
    -p 5775:5775/udp \
    -p 6831:6831/udp \
    -p 6832:6832/udp \
    -p 5778:5778 \
    -p 16686:16686 \
    -p 14268:14268 \
    -p 9411:9411 \
    jaegertracing/all-in-one:1.14
```

Now run some tests, and then point a browser at
http://localhost:16686/ to view the outputs.

More information can be found at:

* OpenTracing: https://opentracing.io
* TracerResolver: https://github.com/opentracing-contrib/java-tracerresolver
* Jaeger: https://www.jaegertracing.io
* Coursier: https://get-coursier.io
