Skip to content

Commit

Permalink
census: Avoid deprecated measure constants
Browse files Browse the repository at this point in the history
Many of the deprecated constants are just aliases for non-deprecated
constants, so just swap which one we use.
  • Loading branch information
ejona86 committed Sep 12, 2022
1 parent 42e6814 commit bacf18d
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 112 deletions.
30 changes: 13 additions & 17 deletions census/src/main/java/io/grpc/census/CensusStatsModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -369,13 +369,11 @@ void recordFinishedAttempt() {
// TODO(songya): remove the deprecated measure constants once they are completed removed.
.put(DeprecatedCensusConstants.RPC_CLIENT_FINISHED_COUNT, 1)
// The latency is double value
.put(
DeprecatedCensusConstants.RPC_CLIENT_ROUNDTRIP_LATENCY,
roundtripNanos / NANOS_PER_MILLI)
.put(DeprecatedCensusConstants.RPC_CLIENT_REQUEST_COUNT, outboundMessageCount)
.put(DeprecatedCensusConstants.RPC_CLIENT_RESPONSE_COUNT, inboundMessageCount)
.put(DeprecatedCensusConstants.RPC_CLIENT_REQUEST_BYTES, outboundWireSize)
.put(DeprecatedCensusConstants.RPC_CLIENT_RESPONSE_BYTES, inboundWireSize)
.put(RpcMeasureConstants.GRPC_CLIENT_ROUNDTRIP_LATENCY, roundtripNanos / NANOS_PER_MILLI)
.put(RpcMeasureConstants.GRPC_CLIENT_SENT_MESSAGES_PER_RPC, outboundMessageCount)
.put(RpcMeasureConstants.GRPC_CLIENT_RECEIVED_MESSAGES_PER_RPC, inboundMessageCount)
.put(RpcMeasureConstants.GRPC_CLIENT_SENT_BYTES_PER_RPC, outboundWireSize)
.put(RpcMeasureConstants.GRPC_CLIENT_RECEIVED_BYTES_PER_RPC, inboundWireSize)
.put(
DeprecatedCensusConstants.RPC_CLIENT_UNCOMPRESSED_REQUEST_BYTES,
outboundUncompressedSize)
Expand Down Expand Up @@ -443,7 +441,7 @@ static final class CallAttemptsTracerFactory extends
if (module.recordStartedRpcs) {
// Record here in case newClientStreamTracer() would never be called.
module.statsRecorder.newMeasureMap()
.put(DeprecatedCensusConstants.RPC_CLIENT_STARTED_COUNT, 1)
.put(RpcMeasureConstants.GRPC_CLIENT_STARTED_RPCS, 1)
.record(startCtx);
}
}
Expand All @@ -462,7 +460,7 @@ public ClientStreamTracer newClientStreamTracer(StreamInfo info, Metadata metada
}
if (module.recordStartedRpcs && attemptsPerCall.get() > 0) {
module.statsRecorder.newMeasureMap()
.put(DeprecatedCensusConstants.RPC_CLIENT_STARTED_COUNT, 1)
.put(RpcMeasureConstants.GRPC_CLIENT_STARTED_RPCS, 1)
.record(startCtx);
}
if (info.isTransparentRetry()) {
Expand Down Expand Up @@ -628,7 +626,7 @@ private static final class ServerTracer extends ServerStreamTracer {
this.stopwatch = module.stopwatchSupplier.get().start();
if (module.recordStartedRpcs) {
module.statsRecorder.newMeasureMap()
.put(DeprecatedCensusConstants.RPC_SERVER_STARTED_COUNT, 1)
.put(RpcMeasureConstants.GRPC_SERVER_STARTED_RPCS, 1)
.record(parentCtx);
}
}
Expand Down Expand Up @@ -728,13 +726,11 @@ public void streamClosed(Status status) {
// TODO(songya): remove the deprecated measure constants once they are completed removed.
.put(DeprecatedCensusConstants.RPC_SERVER_FINISHED_COUNT, 1)
// The latency is double value
.put(
DeprecatedCensusConstants.RPC_SERVER_SERVER_LATENCY,
elapsedTimeNanos / NANOS_PER_MILLI)
.put(DeprecatedCensusConstants.RPC_SERVER_RESPONSE_COUNT, outboundMessageCount)
.put(DeprecatedCensusConstants.RPC_SERVER_REQUEST_COUNT, inboundMessageCount)
.put(DeprecatedCensusConstants.RPC_SERVER_RESPONSE_BYTES, outboundWireSize)
.put(DeprecatedCensusConstants.RPC_SERVER_REQUEST_BYTES, inboundWireSize)
.put(RpcMeasureConstants.GRPC_SERVER_SERVER_LATENCY, elapsedTimeNanos / NANOS_PER_MILLI)
.put(RpcMeasureConstants.GRPC_SERVER_SENT_MESSAGES_PER_RPC, outboundMessageCount)
.put(RpcMeasureConstants.GRPC_SERVER_RECEIVED_MESSAGES_PER_RPC, inboundMessageCount)
.put(RpcMeasureConstants.GRPC_SERVER_SENT_BYTES_PER_RPC, outboundWireSize)
.put(RpcMeasureConstants.GRPC_SERVER_RECEIVED_BYTES_PER_RPC, inboundWireSize)
.put(
DeprecatedCensusConstants.RPC_SERVER_UNCOMPRESSED_RESPONSE_BYTES,
outboundUncompressedSize)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,49 +27,23 @@
public final class DeprecatedCensusConstants {
public static final MeasureLong RPC_CLIENT_ERROR_COUNT =
RpcMeasureConstants.RPC_CLIENT_ERROR_COUNT;
public static final MeasureDouble RPC_CLIENT_REQUEST_BYTES =
RpcMeasureConstants.RPC_CLIENT_REQUEST_BYTES;
public static final MeasureDouble RPC_CLIENT_RESPONSE_BYTES =
RpcMeasureConstants.RPC_CLIENT_RESPONSE_BYTES;
public static final MeasureDouble RPC_CLIENT_ROUNDTRIP_LATENCY =
RpcMeasureConstants.RPC_CLIENT_ROUNDTRIP_LATENCY;
public static final MeasureDouble RPC_CLIENT_SERVER_ELAPSED_TIME =
RpcMeasureConstants.RPC_CLIENT_SERVER_ELAPSED_TIME;
public static final MeasureDouble RPC_CLIENT_UNCOMPRESSED_REQUEST_BYTES =
RpcMeasureConstants.RPC_CLIENT_UNCOMPRESSED_REQUEST_BYTES;
public static final MeasureDouble RPC_CLIENT_UNCOMPRESSED_RESPONSE_BYTES =
RpcMeasureConstants.RPC_CLIENT_UNCOMPRESSED_RESPONSE_BYTES;
public static final MeasureLong RPC_CLIENT_STARTED_COUNT =
RpcMeasureConstants.RPC_CLIENT_STARTED_COUNT;
public static final MeasureLong RPC_CLIENT_FINISHED_COUNT =
RpcMeasureConstants.RPC_CLIENT_FINISHED_COUNT;
public static final MeasureLong RPC_CLIENT_REQUEST_COUNT =
RpcMeasureConstants.RPC_CLIENT_REQUEST_COUNT;
public static final MeasureLong RPC_CLIENT_RESPONSE_COUNT =
RpcMeasureConstants.RPC_CLIENT_RESPONSE_COUNT;

public static final MeasureLong RPC_SERVER_ERROR_COUNT =
RpcMeasureConstants.RPC_SERVER_ERROR_COUNT;
public static final MeasureDouble RPC_SERVER_REQUEST_BYTES =
RpcMeasureConstants.RPC_SERVER_REQUEST_BYTES;
public static final MeasureDouble RPC_SERVER_RESPONSE_BYTES =
RpcMeasureConstants.RPC_SERVER_RESPONSE_BYTES;
public static final MeasureDouble RPC_SERVER_SERVER_ELAPSED_TIME =
RpcMeasureConstants.RPC_SERVER_SERVER_ELAPSED_TIME;
public static final MeasureDouble RPC_SERVER_SERVER_LATENCY =
RpcMeasureConstants.RPC_SERVER_SERVER_LATENCY;
public static final MeasureDouble RPC_SERVER_UNCOMPRESSED_REQUEST_BYTES =
RpcMeasureConstants.RPC_SERVER_UNCOMPRESSED_REQUEST_BYTES;
public static final MeasureDouble RPC_SERVER_UNCOMPRESSED_RESPONSE_BYTES =
RpcMeasureConstants.RPC_SERVER_UNCOMPRESSED_RESPONSE_BYTES;
public static final MeasureLong RPC_SERVER_STARTED_COUNT =
RpcMeasureConstants.RPC_SERVER_STARTED_COUNT;
public static final MeasureLong RPC_SERVER_FINISHED_COUNT =
RpcMeasureConstants.RPC_SERVER_FINISHED_COUNT;
public static final MeasureLong RPC_SERVER_REQUEST_COUNT =
RpcMeasureConstants.RPC_SERVER_REQUEST_COUNT;
public static final MeasureLong RPC_SERVER_RESPONSE_COUNT =
RpcMeasureConstants.RPC_SERVER_RESPONSE_COUNT;

private DeprecatedCensusConstants() {}
}

0 comments on commit bacf18d

Please sign in to comment.