Skip to content

Commit bacf18d

Browse files
authored
census: Avoid deprecated measure constants
Many of the deprecated constants are just aliases for non-deprecated constants, so just swap which one we use.
1 parent 42e6814 commit bacf18d

File tree

5 files changed

+75
-112
lines changed

5 files changed

+75
-112
lines changed

census/src/main/java/io/grpc/census/CensusStatsModule.java

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -369,13 +369,11 @@ void recordFinishedAttempt() {
369369
// TODO(songya): remove the deprecated measure constants once they are completed removed.
370370
.put(DeprecatedCensusConstants.RPC_CLIENT_FINISHED_COUNT, 1)
371371
// The latency is double value
372-
.put(
373-
DeprecatedCensusConstants.RPC_CLIENT_ROUNDTRIP_LATENCY,
374-
roundtripNanos / NANOS_PER_MILLI)
375-
.put(DeprecatedCensusConstants.RPC_CLIENT_REQUEST_COUNT, outboundMessageCount)
376-
.put(DeprecatedCensusConstants.RPC_CLIENT_RESPONSE_COUNT, inboundMessageCount)
377-
.put(DeprecatedCensusConstants.RPC_CLIENT_REQUEST_BYTES, outboundWireSize)
378-
.put(DeprecatedCensusConstants.RPC_CLIENT_RESPONSE_BYTES, inboundWireSize)
372+
.put(RpcMeasureConstants.GRPC_CLIENT_ROUNDTRIP_LATENCY, roundtripNanos / NANOS_PER_MILLI)
373+
.put(RpcMeasureConstants.GRPC_CLIENT_SENT_MESSAGES_PER_RPC, outboundMessageCount)
374+
.put(RpcMeasureConstants.GRPC_CLIENT_RECEIVED_MESSAGES_PER_RPC, inboundMessageCount)
375+
.put(RpcMeasureConstants.GRPC_CLIENT_SENT_BYTES_PER_RPC, outboundWireSize)
376+
.put(RpcMeasureConstants.GRPC_CLIENT_RECEIVED_BYTES_PER_RPC, inboundWireSize)
379377
.put(
380378
DeprecatedCensusConstants.RPC_CLIENT_UNCOMPRESSED_REQUEST_BYTES,
381379
outboundUncompressedSize)
@@ -443,7 +441,7 @@ static final class CallAttemptsTracerFactory extends
443441
if (module.recordStartedRpcs) {
444442
// Record here in case newClientStreamTracer() would never be called.
445443
module.statsRecorder.newMeasureMap()
446-
.put(DeprecatedCensusConstants.RPC_CLIENT_STARTED_COUNT, 1)
444+
.put(RpcMeasureConstants.GRPC_CLIENT_STARTED_RPCS, 1)
447445
.record(startCtx);
448446
}
449447
}
@@ -462,7 +460,7 @@ public ClientStreamTracer newClientStreamTracer(StreamInfo info, Metadata metada
462460
}
463461
if (module.recordStartedRpcs && attemptsPerCall.get() > 0) {
464462
module.statsRecorder.newMeasureMap()
465-
.put(DeprecatedCensusConstants.RPC_CLIENT_STARTED_COUNT, 1)
463+
.put(RpcMeasureConstants.GRPC_CLIENT_STARTED_RPCS, 1)
466464
.record(startCtx);
467465
}
468466
if (info.isTransparentRetry()) {
@@ -628,7 +626,7 @@ private static final class ServerTracer extends ServerStreamTracer {
628626
this.stopwatch = module.stopwatchSupplier.get().start();
629627
if (module.recordStartedRpcs) {
630628
module.statsRecorder.newMeasureMap()
631-
.put(DeprecatedCensusConstants.RPC_SERVER_STARTED_COUNT, 1)
629+
.put(RpcMeasureConstants.GRPC_SERVER_STARTED_RPCS, 1)
632630
.record(parentCtx);
633631
}
634632
}
@@ -728,13 +726,11 @@ public void streamClosed(Status status) {
728726
// TODO(songya): remove the deprecated measure constants once they are completed removed.
729727
.put(DeprecatedCensusConstants.RPC_SERVER_FINISHED_COUNT, 1)
730728
// The latency is double value
731-
.put(
732-
DeprecatedCensusConstants.RPC_SERVER_SERVER_LATENCY,
733-
elapsedTimeNanos / NANOS_PER_MILLI)
734-
.put(DeprecatedCensusConstants.RPC_SERVER_RESPONSE_COUNT, outboundMessageCount)
735-
.put(DeprecatedCensusConstants.RPC_SERVER_REQUEST_COUNT, inboundMessageCount)
736-
.put(DeprecatedCensusConstants.RPC_SERVER_RESPONSE_BYTES, outboundWireSize)
737-
.put(DeprecatedCensusConstants.RPC_SERVER_REQUEST_BYTES, inboundWireSize)
729+
.put(RpcMeasureConstants.GRPC_SERVER_SERVER_LATENCY, elapsedTimeNanos / NANOS_PER_MILLI)
730+
.put(RpcMeasureConstants.GRPC_SERVER_SENT_MESSAGES_PER_RPC, outboundMessageCount)
731+
.put(RpcMeasureConstants.GRPC_SERVER_RECEIVED_MESSAGES_PER_RPC, inboundMessageCount)
732+
.put(RpcMeasureConstants.GRPC_SERVER_SENT_BYTES_PER_RPC, outboundWireSize)
733+
.put(RpcMeasureConstants.GRPC_SERVER_RECEIVED_BYTES_PER_RPC, inboundWireSize)
738734
.put(
739735
DeprecatedCensusConstants.RPC_SERVER_UNCOMPRESSED_RESPONSE_BYTES,
740736
outboundUncompressedSize)

census/src/main/java/io/grpc/census/internal/DeprecatedCensusConstants.java

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,49 +27,23 @@
2727
public final class DeprecatedCensusConstants {
2828
public static final MeasureLong RPC_CLIENT_ERROR_COUNT =
2929
RpcMeasureConstants.RPC_CLIENT_ERROR_COUNT;
30-
public static final MeasureDouble RPC_CLIENT_REQUEST_BYTES =
31-
RpcMeasureConstants.RPC_CLIENT_REQUEST_BYTES;
32-
public static final MeasureDouble RPC_CLIENT_RESPONSE_BYTES =
33-
RpcMeasureConstants.RPC_CLIENT_RESPONSE_BYTES;
34-
public static final MeasureDouble RPC_CLIENT_ROUNDTRIP_LATENCY =
35-
RpcMeasureConstants.RPC_CLIENT_ROUNDTRIP_LATENCY;
36-
public static final MeasureDouble RPC_CLIENT_SERVER_ELAPSED_TIME =
37-
RpcMeasureConstants.RPC_CLIENT_SERVER_ELAPSED_TIME;
3830
public static final MeasureDouble RPC_CLIENT_UNCOMPRESSED_REQUEST_BYTES =
3931
RpcMeasureConstants.RPC_CLIENT_UNCOMPRESSED_REQUEST_BYTES;
4032
public static final MeasureDouble RPC_CLIENT_UNCOMPRESSED_RESPONSE_BYTES =
4133
RpcMeasureConstants.RPC_CLIENT_UNCOMPRESSED_RESPONSE_BYTES;
42-
public static final MeasureLong RPC_CLIENT_STARTED_COUNT =
43-
RpcMeasureConstants.RPC_CLIENT_STARTED_COUNT;
4434
public static final MeasureLong RPC_CLIENT_FINISHED_COUNT =
4535
RpcMeasureConstants.RPC_CLIENT_FINISHED_COUNT;
46-
public static final MeasureLong RPC_CLIENT_REQUEST_COUNT =
47-
RpcMeasureConstants.RPC_CLIENT_REQUEST_COUNT;
48-
public static final MeasureLong RPC_CLIENT_RESPONSE_COUNT =
49-
RpcMeasureConstants.RPC_CLIENT_RESPONSE_COUNT;
5036

5137
public static final MeasureLong RPC_SERVER_ERROR_COUNT =
5238
RpcMeasureConstants.RPC_SERVER_ERROR_COUNT;
53-
public static final MeasureDouble RPC_SERVER_REQUEST_BYTES =
54-
RpcMeasureConstants.RPC_SERVER_REQUEST_BYTES;
55-
public static final MeasureDouble RPC_SERVER_RESPONSE_BYTES =
56-
RpcMeasureConstants.RPC_SERVER_RESPONSE_BYTES;
5739
public static final MeasureDouble RPC_SERVER_SERVER_ELAPSED_TIME =
5840
RpcMeasureConstants.RPC_SERVER_SERVER_ELAPSED_TIME;
59-
public static final MeasureDouble RPC_SERVER_SERVER_LATENCY =
60-
RpcMeasureConstants.RPC_SERVER_SERVER_LATENCY;
6141
public static final MeasureDouble RPC_SERVER_UNCOMPRESSED_REQUEST_BYTES =
6242
RpcMeasureConstants.RPC_SERVER_UNCOMPRESSED_REQUEST_BYTES;
6343
public static final MeasureDouble RPC_SERVER_UNCOMPRESSED_RESPONSE_BYTES =
6444
RpcMeasureConstants.RPC_SERVER_UNCOMPRESSED_RESPONSE_BYTES;
65-
public static final MeasureLong RPC_SERVER_STARTED_COUNT =
66-
RpcMeasureConstants.RPC_SERVER_STARTED_COUNT;
6745
public static final MeasureLong RPC_SERVER_FINISHED_COUNT =
6846
RpcMeasureConstants.RPC_SERVER_FINISHED_COUNT;
69-
public static final MeasureLong RPC_SERVER_REQUEST_COUNT =
70-
RpcMeasureConstants.RPC_SERVER_REQUEST_COUNT;
71-
public static final MeasureLong RPC_SERVER_RESPONSE_COUNT =
72-
RpcMeasureConstants.RPC_SERVER_RESPONSE_COUNT;
7347

7448
private DeprecatedCensusConstants() {}
7549
}

0 commit comments

Comments
 (0)