use of io.opencensus.stats.StatsComponent in project grpc-java by grpc.
the class CensusModulesTest method newTagsPopulateOldViews.
@Deprecated
@Test
public void newTagsPopulateOldViews() throws InterruptedException {
StatsComponent localStats = new StatsComponentImpl();
// Test views that contain both of the remap tags: method & status.
localStats.getViewManager().registerView(RpcViewConstants.RPC_CLIENT_ERROR_COUNT_VIEW);
localStats.getViewManager().registerView(RpcViewConstants.GRPC_CLIENT_COMPLETED_RPC_VIEW);
CensusStatsModule localCensusStats = new CensusStatsModule(tagger, tagCtxSerializer, localStats.getStatsRecorder(), fakeClock.getStopwatchSupplier(), false, false, true, false, /* real-time */
true);
CensusStatsModule.CallAttemptsTracerFactory callAttemptsTracerFactory = new CensusStatsModule.CallAttemptsTracerFactory(localCensusStats, tagger.empty(), method.getFullMethodName());
Metadata headers = new Metadata();
ClientStreamTracer tracer = callAttemptsTracerFactory.newClientStreamTracer(STREAM_INFO, headers);
tracer.streamCreated(Attributes.EMPTY, headers);
fakeClock.forwardTime(30, MILLISECONDS);
Status status = Status.PERMISSION_DENIED.withDescription("No you don't");
tracer.streamClosed(status);
callAttemptsTracerFactory.callEnded(status);
// Give OpenCensus a chance to update the views asynchronously.
Thread.sleep(100);
assertWithMessage("Legacy error count view had unexpected count").that(getAggregationValueAsLong(localStats, RpcViewConstants.RPC_CLIENT_ERROR_COUNT_VIEW, ImmutableList.of(TagValue.create("PERMISSION_DENIED"), TagValue.create(method.getFullMethodName())))).isEqualTo(1);
assertWithMessage("New error count view had unexpected count").that(getAggregationValueAsLong(localStats, RpcViewConstants.GRPC_CLIENT_COMPLETED_RPC_VIEW, ImmutableList.of(TagValue.create(method.getFullMethodName()), TagValue.create("PERMISSION_DENIED")))).isEqualTo(1);
}
Aggregations