/** * Registers all views. * * <p>This is equivalent with calling {@link #registerAllCumulativeViews()} and {@link * #registerAllIntervalViews()}. * * <p>It is recommended to call this method before doing any RPC call to avoid missing stats. * * @since 0.11.0 */ public static void registerAllViews() { registerAllViews(Stats.getViewManager()); }
/** * Registers all views. * * <p>This is equivalent with calling {@link #registerAllCumulativeViews()} and {@link * #registerAllIntervalViews()}. * * <p>It is recommended to call this method before doing any RPC call to avoid missing stats. * * @since 0.11.0 * @deprecated in favor of {@link #registerAllGrpcViews()}. */ @Deprecated public static void registerAllViews() { registerAllViews(Stats.getViewManager()); }
@Test public void registerAll() { FakeViewManager fakeViewManager = new FakeViewManager(); RpcViews.registerAllViews(fakeViewManager); assertThat(fakeViewManager.getRegisteredViews()) .containsExactlyElementsIn( ImmutableSet.builder() .addAll(RpcViews.RPC_CUMULATIVE_VIEWS_SET) .addAll(RpcViews.RPC_INTERVAL_VIEWS_SET) .build()); }
public static void main(String[] args) throws IOException, InterruptedException { // Consult system properties to get project/instance String projectId = requiredProperty("bigtable.projectID"); String instanceId = requiredProperty("bigtable.instanceID"); // Force tracing for every request for demo purposes. Use the default settings // in most cases. Tracing.getTraceConfig().updateActiveTraceParams( TraceParams.DEFAULT.toBuilder().setSampler(Samplers.probabilitySampler(1)).build()); StackdriverTraceExporter.createAndRegister( StackdriverTraceConfiguration.builder() .setProjectId(projectId) .build()); // Enable stats exporter to Stackdriver with a 5 second export time. // Production settings may vary. StackdriverStatsExporter.createAndRegister( StackdriverStatsConfiguration.builder() .setProjectId(projectId) .setExportInterval(Duration.create(5, 0)) .build()); RpcViews.registerAllViews(); // HBase Bigtable specific setup for zpages HBaseTracingUtilities.setupTracingConfig(); // Start a web server on port 8080 for tracing data ZPageHandlers.startHttpServerAndRegisterAll(8080); doHelloWorld(projectId, instanceId); System.out.println("Sleeping for 1 minute so that you can view http://localhost:8080/tracez"); // Sleep for 1 minute. Thread.sleep(TimeUnit.MINUTES.toMillis(1)); }