opentelemetry-java/sdk_extensions/zpages
Anuraag Agrawal 6dffbb8fc4
Migrate tests to JUnit5 (#1489)
* Add JUnit 5 dependency

* Revert unintended
2020-07-31 11:10:27 -07:00
..
img Added preliminary documentation for the zPages contrib module (#1455) 2020-07-29 21:19:15 +02:00
src Migrate tests to JUnit5 (#1489) 2020-07-31 11:10:27 -07:00
README.md Added preliminary documentation for the zPages contrib module (#1455) 2020-07-29 21:19:15 +02:00
build.gradle Implemented TraceConfigZ zPage (#1441) 2020-07-30 11:24:50 -07:00

README.md

OpenTelemetry SDK Contrib - zPages

Javadocs

This module contains code for OpenTelemetry's Java zPages, which are a collection of dynamic HTML web pages that display stats and trace data.

  • Java 7 compatible.

Quickstart

Add the dependencies to your project

For Maven, add the following to your pom.xml:

<dependencies>
  <dependency>
        <groupId>io.opentelemetry</groupId>
        <artifactId>opentelemetry-api</artifactId>
        <version>0.7.0</version>
      </dependency>
      <dependency>
        <groupId>io.opentelemetry</groupId>
        <artifactId>opentelemetry-sdk</artifactId>
        <version>0.7.0</version>
      </dependency>
      <dependency>
        <groupId>io.opentelemetry</groupId>
        <artifactId>opentelemetry-sdk-extension-zpages</artifactId>
        <version>0.7.0</version>
      </dependency>
</dependencies>

For Gradle, add the following to your dependencies:

implementation 'io.opentelemetry:opentelemetry-api:0.7.0'
implementation 'io.opentelemetry:opentelemetry-sdk:0.7.0'
implementation 'io.opentelemetry:opentelemetry-sdk-extension-zpages:0.7.0'

Register the zPages

Note: The package com.sun.net.httpserver is required to use the default zPages setup. Please make sure your version of the JDK includes this package.

To set-up the zPages, simply call ZPageServer.startHttpServerAndRegisterAllPages(int port) in your main function:

public class MyMainClass {
  public static void main(String[] args) throws Exception {
    ZPageServer.startHttpServerAndRegisterAllPages(8080);
    // ... do work
  }
}

Alternatively, you can call ZPageServer.registerAllPagesToHttpServer(HttpServer server) to register the zPages to a shared server:

public class MyMainClass {
  public static void main(String[] args) throws Exception {
    HttpServer server = HttpServer.create(new InetSocketAddress(8000), 10);
    ZPageServer.registerAllPagesToHttpServer(server);
    server.start();
    // ... do work
  }
}

Access the zPages

View all available zPages on the / index page

The index page / lists all available zPages with a link and description.

View trace spans on the /tracez zPage

The /tracez zPage displays information on running spans, sample span latencies, and sample error spans. The data is aggregated into a summary-level table:

tracez-table

You can click on each of the counts in the table cells to access the corresponding span details. For example, here are the details of the ChildSpan latency sample (row 1, col 4):

tracez-details

View and update the tracing configuration on the /traceconfigz zPage

The /traceconfigz zPage displays information about the currently active tracing configuration and provides an interface for users to modify relevant parameters. Here is what the web page looks like:

traceconfigz