opentelemetry-java/sdk_extensions/zpages
John Watson 485cc52c6f
SpanContext hides the TraceId/SpanId implementations (#1594)
*  This is a combination of 2 commits.
 This is the 1st commit message:

WIP on converting to String-based SpanContext

don't hand out the byte arrays publicly, but require making copies

make sure to hand out fresh invalid byte arrays.

Use strings for span and trace ids.

Switch over to CharSequence instead of String for the ids

Fix a couple of places that were casting to String

Add some simple wrappers for the generated longs to save converting until the last moment to the character-based representation.

introduce a reusable threadlocal char buffer for generating random ids.

update for changes from upstream

Change the SpanContext to store the ids as Strings internally
Change the id access methods on SpanContext to be clearly labeled as the base16 representations
Add a new create method that allows specifying offsets for traceId and spanId CharSequences

Provide an option for creating a SpanContext from longs or Strings, optionally.

fix a typo

update from upstream

 The commit message #2 will be skipped:

 don't hand out the byte arrays publicly, but require making copies

* WIP on converting to String-based SpanContext

* Update the SpanContext to only store Strings internally for Trace and Span ids.

* remove dead files

* cleanup some CharSequence usages to String

* Update api/src/main/java/io/opentelemetry/trace/BigendianEncoding.java

Co-authored-by: Anuraag Agrawal <anuraaga@gmail.com>

* Update extensions/trace_propagators/src/main/java/io/opentelemetry/extensions/trace/propagation/B3PropagatorInjectorSingleHeader.java

Co-authored-by: Anuraag Agrawal <anuraaga@gmail.com>

* Update api/src/main/java/io/opentelemetry/trace/SpanId.java

Co-authored-by: Anuraag Agrawal <anuraaga@gmail.com>

* Update api/src/main/java/io/opentelemetry/trace/TraceId.java

Co-authored-by: Anuraag Agrawal <anuraaga@gmail.com>

* updates from PR suggestion fubars

* some cleanup from PR feedback

* Switch back to String from CharSequence

* Get rid of the overload with the offsets

* Lots of bits of cleanup from PR feedback.

* more renaming of base16 to hex

Co-authored-by: Anuraag Agrawal <anuraaga@gmail.com>
2020-09-03 10:03:41 -07:00
..
img Added preliminary documentation for the zPages contrib module (#1455) 2020-07-29 21:19:15 +02:00
src SpanContext hides the TraceId/SpanId implementations (#1594) 2020-09-03 10:03:41 -07:00
README.md Update the README and CHANGELOG for 0.8.0 (#1614) 2020-09-01 13:25:33 -07:00
build.gradle Changed TraceConfigz zPage form to use POST request (#1521) 2020-08-12 08:20:29 -07:00

README.md

OpenTelemetry SDK Extension zPages

Javadocs

This module contains code for the OpenTelemetry 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.8.0</version>
      </dependency>
      <dependency>
        <groupId>io.opentelemetry</groupId>
        <artifactId>opentelemetry-sdk</artifactId>
        <version>0.8.0</version>
      </dependency>
      <dependency>
        <groupId>io.opentelemetry</groupId>
        <artifactId>opentelemetry-sdk-extension-zpages</artifactId>
        <version>0.8.0</version>
      </dependency>
</dependencies>

For Gradle, add the following to your dependencies:

implementation 'io.opentelemetry:opentelemetry-api:0.8.0'
implementation 'io.opentelemetry:opentelemetry-sdk:0.8.0'
implementation 'io.opentelemetry:opentelemetry-sdk-extension-zpages:0.8.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

Benchmark Testing

This module contains two sets of benchmark tests: one for adding spans to an instance of TracezSpanBuckets and another for retrieving counts and spans with TracezDataAggregator. You can run the tests yourself with the following commands:

./gradlew -PjmhIncludeSingleClass=TracezSpanBucketsBenchmark clean :opentelemetry-sdk-extension-zpages:jmh
./gradlew -PjmhIncludeSingleClass=TracezDataAggregatorBenchmark clean :opentelemetry-sdk-extension-zpages:jmh