Skip to content

Commit

Permalink
Extract a few common tag valalues.
Browse files Browse the repository at this point in the history
  • Loading branch information
songy23 committed May 24, 2018
1 parent b7fbc10 commit ea3d425
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions core/src/main/java/io/grpc/internal/CensusStatsModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,11 @@ static final class ClientCallTracer extends ClientStreamTracer.Factory {
this.module = module;
this.fullMethodName = checkNotNull(fullMethodName, "fullMethodName");
this.parentCtx = checkNotNull(parentCtx);
TagValue methodTag = TagValue.create(fullMethodName);
this.startCtx =
module.tagger.toBuilder(parentCtx)
.put(RpcMeasureConstants.RPC_METHOD, TagValue.create(fullMethodName))
.put(RpcMeasureConstants.GRPC_CLIENT_METHOD, TagValue.create(fullMethodName))
.put(RpcMeasureConstants.RPC_METHOD, methodTag)
.put(RpcMeasureConstants.GRPC_CLIENT_METHOD, methodTag)
.build();
this.stopwatch = module.stopwatchSupplier.get().start();
this.recordFinishedRpcs = recordFinishedRpcs;
Expand Down Expand Up @@ -419,14 +420,13 @@ void callEnded(Status status) {
if (!status.isOk()) {
measureMap.put(RpcMeasureConstants.RPC_CLIENT_ERROR_COUNT, 1);
}
TagValue statusTag = TagValue.create(status.getCode().toString());
measureMap.record(
module
.tagger
.toBuilder(startCtx)
.put(RpcMeasureConstants.RPC_STATUS, TagValue.create(status.getCode().toString()))
.put(
RpcMeasureConstants.GRPC_CLIENT_STATUS,
TagValue.create(status.getCode().toString()))
.put(RpcMeasureConstants.RPC_STATUS, statusTag)
.put(RpcMeasureConstants.GRPC_CLIENT_STATUS, statusTag)
.build());
}
}
Expand Down Expand Up @@ -629,14 +629,13 @@ public void streamClosed(Status status) {
if (!status.isOk()) {
measureMap.put(RpcMeasureConstants.RPC_SERVER_ERROR_COUNT, 1);
}
TagValue statusTag = TagValue.create(status.getCode().toString());
measureMap.record(
module
.tagger
.toBuilder(parentCtx)
.put(RpcMeasureConstants.RPC_STATUS, TagValue.create(status.getCode().toString()))
.put(
RpcMeasureConstants.GRPC_SERVER_STATUS,
TagValue.create(status.getCode().toString()))
.put(RpcMeasureConstants.RPC_STATUS, statusTag)
.put(RpcMeasureConstants.GRPC_SERVER_STATUS, statusTag)
.build());
}

Expand Down Expand Up @@ -665,11 +664,12 @@ public ServerStreamTracer newServerStreamTracer(String fullMethodName, Metadata
if (parentCtx == null) {
parentCtx = tagger.empty();
}
TagValue methodTag = TagValue.create(fullMethodName);
parentCtx =
tagger
.toBuilder(parentCtx)
.put(RpcMeasureConstants.RPC_METHOD, TagValue.create(fullMethodName))
.put(RpcMeasureConstants.GRPC_SERVER_METHOD, TagValue.create(fullMethodName))
.put(RpcMeasureConstants.RPC_METHOD, methodTag)
.put(RpcMeasureConstants.GRPC_SERVER_METHOD, methodTag)
.build();
return new ServerTracer(
CensusStatsModule.this,
Expand Down

0 comments on commit ea3d425

Please sign in to comment.