./gradlew installDistmvn package appassembler:assembleTo build Spring Servlet example
cd spring/servlet
mvn package appassembler:assemble./build/install/opencensus-examples/bin/TagContextExample./target/appassembler/bin/TagContextExample./build/install/opencensus-examples/bin/ZPagesTester./target/appassembler/bin/ZPagesTesterAvailable pages:
- For tracing page go to localhost:8080/tracez.
- For tracing config page go to localhost:8080/traceconfigz.
- For RPC stats page go to localhost:8080/rpcz.
- For stats and measures on all registered views go to localhost:8080/statsz.
./build/install/opencensus-examples/bin/QuickStart./target/appassembler/bin/QuickStartPlease note all the arguments are optional. If you do not specify these arguments, default values will be used:
- host and serverPort will be "localhost:50051"
- user will be "world"
- cloudProjectId will be null (which means no stats/spans will be exported to Stackdriver)
- server zPagePort will be 3000
- client zPagePort will be 3001
- Prometheus port will be 9090
However, if you want to specify any of these arguements, please make sure they are in order.
./build/install/opencensus-examples/bin/HelloWorldServer serverPort cloudProjectId zPagePort prometheusPort
./build/install/opencensus-examples/bin/HelloWorldClient user host serverPort cloudProjectId zPagePort./target/appassembler/bin/HelloWorldServer serverPort cloudProjectId zPagePort prometheusPort
./target/appassembler/bin/HelloWorldClient user host serverPort cloudProjectId zPagePortSee the full tutorial on OpenCensus website.
First run:
./build/install/opencensus-examples/bin/Repl./target/appassembler/bin/ReplThen start the Prometheus process:
cd src/main/java/io/opencensus/examples/quickstart/
prometheus --config.file=prometheus.yamlStats will be shown on Prometheus UI on http://localhost:9090.
See the full tutorial on OpenCensus website.
./build/install/opencensus-examples/bin/StackdriverQuickstart./target/appassembler/bin/StackdriverQuickstart
HttpJettyServer is a web service using Jetty Server on top of http-servlet.
HttpJettyClient is a web client using Jetty Client that sends request to HttpettyServer.
Both HttpJettyServer and HttpJettyClient are instrumented with OpenCensus.
Traces from both client and server can be viewed in their respective logs on console. Stats are available from Prometheus server running at
- http://localhost:9091/metrics - for client stats
- http://localhost:9090/metrics - for server stats
./build/install/opencensus-examples/bin/HttpJettyServer
./build/install/opencensus-examples/bin/HttpJettyClient./target/appassembler/bin/HttpJettyServer
./target/appassembler/bin/HttpJettyClient./build/install/opencensus-examples/bin/OcAgentExportersQuickStart agentEndpoint # default is localhost:56678./target/appassembler/bin/OcAgentExportersQuickStart agentEndpoint # default is localhost:56678You also need to install and start OpenCensus-Agent in order to receive the traces and metrics. For more information on setting up Agent, see tutorial.
SpringServletApplication is a web service application using Spring framework. The application
is instrumented with opencensus simply by incuding opencensus-contrib-spring-starter package.
The instrumentation enables tracing on incoming and outgoing http requests. On receiving GET
request, the server originates multiple GET requests to itself using AsyncRestTemplate on different
endpoint.
Send a http GET request using curl to see the traces on console.
curl http://localhost:8080
Stats are available from Prometheus server running at
- http://localhost:9090/metrics - for server and client stats
cd spring/servlet
./gradlew bootRuncd spring/servlet
./target/appassembler/bin/SpringServletApplication