diff --git a/google-cloud-bigtable-stats/src/main/java/com/google/cloud/bigtable/stats/BuiltinMetricsRecorder.java b/google-cloud-bigtable-stats/src/main/java/com/google/cloud/bigtable/stats/BuiltinMetricsRecorder.java index 51a0feb5cb..a66da11d0b 100644 --- a/google-cloud-bigtable-stats/src/main/java/com/google/cloud/bigtable/stats/BuiltinMetricsRecorder.java +++ b/google-cloud-bigtable-stats/src/main/java/com/google/cloud/bigtable/stats/BuiltinMetricsRecorder.java @@ -125,9 +125,22 @@ public void recordRetryCount(int attemptCount) { operationLevelNoStreaming.put(BuiltinMeasureConstants.RETRY_COUNT, attemptCount); } - public void recordApplicationLatency(long applicationLatency) { - operationLevelWithStreaming.put( - BuiltinMeasureConstants.APPLICATION_LATENCIES, applicationLatency); + public void recordApplicationLatency( + long applicationLatency, String tableId, String zone, String cluster) { + MeasureMap measures = + statsRecorder + .newMeasureMap() + .put(BuiltinMeasureConstants.APPLICATION_LATENCIES, applicationLatency); + + TagContextBuilder tagCtx = newTagContextBuilder(tableId, zone, cluster); + if (operationType == OperationType.ServerStreaming + && spanName.getMethodName().equals("ReadRows")) { + tagCtx.putLocal(BuiltinMeasureConstants.STREAMING, TagValue.create("true")); + } else { + tagCtx.putLocal(BuiltinMeasureConstants.STREAMING, TagValue.create("false")); + } + + measures.record(tagCtx.build()); } public void recordFirstResponseLatency(long firstResponseLatency) { diff --git a/google-cloud-bigtable-stats/src/test/java/com/google/cloud/bigtable/stats/BuiltinMetricsRecorderTest.java b/google-cloud-bigtable-stats/src/test/java/com/google/cloud/bigtable/stats/BuiltinMetricsRecorderTest.java index 8f0c2688bf..ce0cb0e011 100644 --- a/google-cloud-bigtable-stats/src/test/java/com/google/cloud/bigtable/stats/BuiltinMetricsRecorderTest.java +++ b/google-cloud-bigtable-stats/src/test/java/com/google/cloud/bigtable/stats/BuiltinMetricsRecorderTest.java @@ -67,7 +67,7 @@ public void testStreamingOperation() throws InterruptedException { tracer.recordOperationLatencies(operationLatency); tracer.recordRetryCount(attemptCount); tracer.recordAttemptLatency(attemptLatency); - tracer.recordApplicationLatency(applicationLatency); + tracer.recordApplicationLatency(applicationLatency, TABLE_ID, ZONE, CLUSTER); tracer.recordGfeLatencies(serverLatency); tracer.recordGfeMissingHeaders(connectivityErrorCount); tracer.recordFirstResponseLatency(firstResponseLatency); @@ -261,7 +261,7 @@ public void testUnaryOperations() throws InterruptedException { tracer.recordOperationLatencies(operationLatency); tracer.recordRetryCount(attemptCount); tracer.recordAttemptLatency(attemptLatency); - tracer.recordApplicationLatency(applicationLatency); + tracer.recordApplicationLatency(applicationLatency, TABLE_ID, ZONE, CLUSTER); tracer.recordGfeLatencies(serverLatency); tracer.recordGfeMissingHeaders(connectivityErrorCount); tracer.recordFirstResponseLatency(firstResponseLatency);