Class ZPageHandlers

java.lang.Object
io.opencensus.contrib.zpages.ZPageHandlers

@ThreadSafe public final class ZPageHandlers extends Object
A collection of HTML pages to display stats and trace data and allow library configuration control.

Example usage with private HttpServer:


 public class Main {
   public static void main(String[] args) throws Exception {
     ZPageHandlers.startHttpServerAndRegisterAll(8000);
     ... // do work
   }
 }
 

Example usage with shared HttpServer:


 public class Main {
   public static void main(String[] args) throws Exception {
     HttpServer server = HttpServer.create(new InetSocketAddress(8000), 10);
     ZPageHandlers.registerAllToHttpServer(server);
     server.start();
     ... // do work
   }
 }
 
Since:
0.6
  • Field Details

    • BACKLOG

      private static final int BACKLOG
      See Also:
    • STOP_DELAY

      private static final int STOP_DELAY
      See Also:
    • logger

      private static final Logger logger
    • tracezZPageHandler

      private static final ZPageHandler tracezZPageHandler
    • traceConfigzZPageHandler

      private static final ZPageHandler traceConfigzZPageHandler
    • rpczZpageHandler

      private static final ZPageHandler rpczZpageHandler
    • statszZPageHandler

      private static final ZPageHandler statszZPageHandler
    • monitor

      private static final Object monitor
    • isRunningSpanStoreInitialized

      private static volatile boolean isRunningSpanStoreInitialized
    • server

      @Nullable private static com.sun.net.httpserver.HttpServer server
  • Constructor Details

    • ZPageHandlers

      private ZPageHandlers()
  • Method Details

    • getTracezZPageHandler

      public static ZPageHandler getTracezZPageHandler()
      Returns a ZPageHandler for tracing debug. The page displays information about all active spans and all sampled spans based on latency and errors.

      It prints a summary table which contains one row for each span name and data about number of active and sampled spans.

      If no sampled spans based on latency and error codes are available for a given name, make sure that the span name is registered to the SampledSpanStore.

      When this method is called for the first time, RunningSpanStore will be enabled automatically. Subsequent calls won't update RunningSpanStore again.

      Returns:
      a ZPageHandler for tracing debug.
      Since:
      0.6
    • getTraceConfigzZPageHandler

      public static ZPageHandler getTraceConfigzZPageHandler()
      Returns a ZPageHandler for tracing config. The page displays information about all active configuration and allow changing the active configuration.
      Returns:
      a ZPageHandler for tracing config.
      Since:
      0.6
    • getRpczZpageHandler

      public static ZPageHandler getRpczZpageHandler()
      Returns a ZPageHandler for gRPC stats.

      It prints a summary table which contains rows for each gRPC method.

      Returns:
      a ZPageHandler for gRPC stats.
      Since:
      0.12.0
    • getStatszZPageHandler

      public static ZPageHandler getStatszZPageHandler()
      Returns a ZPageHandler for all registered Views and Measures.

      Only Cumulative views are exported. Views are grouped by directories.

      Returns:
      a ZPageHandler for all registered Views and Measures.
      Since:
      0.12.0
    • registerAllToHttpServer

      public static void registerAllToHttpServer(com.sun.net.httpserver.HttpServer server)
      Registers all pages to the given HttpServer.
      Parameters:
      server - the server that exports the tracez page.
      Since:
      0.6
    • startHttpServerAndRegisterAll

      public static void startHttpServerAndRegisterAll(int port) throws IOException
      Starts an HttpServer and registers all pages to it. When the JVM shuts down the server is stopped.

      Users must call this function only once per process.

      Parameters:
      port - the port used to bind the HttpServer.
      Throws:
      IllegalStateException - if the server is already started.
      IOException - if the server cannot bind to the requested address.
      Since:
      0.6
    • stop

      private static void stop()
    • enableRunningSpanStore

      private static void enableRunningSpanStore()