private static void excuteSpannerProber()

in cloudprober/src/main/java/com/google/grpc/cloudprober/Prober.java [83:135]


  private static void excuteSpannerProber() throws InterruptedException {

    StackdriverUtils util = new StackdriverUtils("Spanner");
    ManagedChannel channel = ManagedChannelBuilder.forAddress(SPANNER_TARGET, 443).build();
    GoogleCredentials creds = getCreds(util);
    SpannerGrpc.SpannerBlockingStub stub =
        SpannerGrpc.newBlockingStub(channel).withCallCredentials(MoreCallCredentials.from(creds));

    int failureCount = 0;

    Tracer tracer = getTracer();
    if (tracer == null) {
      return;
    }

    // Get the global TraceConfig
    TraceConfig globalTraceConfig = Tracing.getTraceConfig();

    // Update the global TraceConfig to always trace
    globalTraceConfig.updateActiveTraceParams(
            globalTraceConfig.getActiveTraceParams().toBuilder().setSampler(Samplers.alwaysSample()).build());

    // Start tracing
    HashMap<String, AttributeValue> map = new HashMap<>();
    map.put("endpoint", AttributeValue.stringAttributeValue(SPANNER_TARGET));
    try (Scope scope = tracer.spanBuilder("session_management_java").startScopedSpan()) {
      tracer.getCurrentSpan().addAnnotation("endpoint info available", map);
      doOneProber(() -> SpannerProbes.sessionManagementProber(stub), failureCount, util);
    }
    try (Scope scope = tracer.spanBuilder("execute_sql_java").startScopedSpan()) {
      tracer.getCurrentSpan().addAnnotation("endpoint info available", map);
      doOneProber(() -> SpannerProbes.executeSqlProber(stub), failureCount, util);
    }
    try (Scope scope = tracer.spanBuilder("read_java").startScopedSpan()) {
      tracer.getCurrentSpan().addAnnotation("endpoint info available", map);
      doOneProber(() -> SpannerProbes.readProber(stub), failureCount, util);
    }
    try (Scope scope = tracer.spanBuilder("transaction_java").startScopedSpan()) {
      tracer.getCurrentSpan().addAnnotation("endpoint info available", map);
      doOneProber(() -> SpannerProbes.transactionProber(stub), failureCount, util);
    }
    try (Scope scope = tracer.spanBuilder("partition_java").startScopedSpan()) {
      tracer.getCurrentSpan().addAnnotation("endpoint info available", map);
      doOneProber(() -> SpannerProbes.partitionProber(stub), failureCount, util);
    }
    Tracing.getExportComponent().shutdown();
    channel.shutdown().awaitTermination(5, TimeUnit.SECONDS);

    if (failureCount == 0) {
      util.setSuccess(true);
    }
    util.outputMetrics();
  }