Class ZPageServer
java.lang.Object
io.opentelemetry.sdk.extension.zpages.ZPageServer
A collection of HTML pages to display stats and trace data and allow library configuration
control. To use, add the z-pages span processor,
the z-pages dynamic trace config and
the z-pages dynamic sampler to a
SdkTracerProviderBuilder
. Currently all tracers can only be made
visible to a singleton ZPageServer
.
Example usage with private HttpServer
public class Main {
public static void main(String[] args) throws Exception {
OpenTelemetry openTelemetry = OpenTelemetrySdk.builder()
.setTracerProvider(SdkTracerProvider.builder()
.addSpanProcessor(ZPageServer.getSpanProcessor())
.setTraceConfigSupplier(ZPageServer.getTraceConfigSupplier())
.setSampler(ZPageServer.getSampler())
.build();
.build();
ZPageServer.startHttpServerAndRegisterAllPages(8000);
... // do work
}
}
Example usage with shared HttpServer
public class Main {
public static void main(String[] args) throws Exception {
OpenTelemetry openTelemetry = OpenTelemetrySdk.builder()
.setTracerProvider(SdkTracerProvider.builder()
.addSpanProcessor(ZPageServer.getSpanProcessor())
.setTraceConfigSupplier(ZPageServer.getTraceConfigSupplier())
.setSampler(ZPageServer.getSampler())
.build();
.build();
HttpServer server = HttpServer.create(new InetSocketAddress(8000), 10);
ZPageServer.registerAllPagesToHttpServer(server);
server.start();
... // do work
}
}
-
Method Summary
Modifier and TypeMethodDescriptionstatic io.opentelemetry.sdk.trace.SpanProcessor
Returns aSpanProcessor
which will allow processing of spans byZPageServer
.static io.opentelemetry.sdk.trace.samplers.Sampler
Returns aSampler
which can be reconfigured using zpages.static Supplier<io.opentelemetry.sdk.trace.SpanLimits>
Returns a supplier ofSpanLimits
which can be reconfigured using zpages.static void
registerAllPagesToHttpServer
(com.sun.net.httpserver.HttpServer server) Registers all zPages to the givenHttpServer
server
.static void
startHttpServerAndRegisterAllPages
(int port) Starts a privateHttpServer
and registers all zPages to it.
-
Method Details
-
getTracezTraceConfigSupplier
Returns a supplier ofSpanLimits
which can be reconfigured using zpages. -
getTracezSampler
public static io.opentelemetry.sdk.trace.samplers.Sampler getTracezSampler()Returns aSampler
which can be reconfigured using zpages. -
getSpanProcessor
public static io.opentelemetry.sdk.trace.SpanProcessor getSpanProcessor()Returns aSpanProcessor
which will allow processing of spans byZPageServer
. -
registerAllPagesToHttpServer
public static void registerAllPagesToHttpServer(com.sun.net.httpserver.HttpServer server) Registers all zPages to the givenHttpServer
server
.- Parameters:
server
- theHttpServer
for the page to register to.
-
startHttpServerAndRegisterAllPages
Starts a privateHttpServer
and registers all zPages to it. When the JVM shuts down the server is stopped.Users can only call this function once per process.
- Parameters:
port
- the port used to bind theHttpServer
server
- Throws:
IllegalStateException
- if the server is already started.IOException
- if the server cannot bind to the specified port.
-