use of io.opencensus.proto.agent.trace.v1.CurrentLibraryConfig in project instrumentation-java by census-instrumentation.
the class OcAgentTraceServiceConfigRpcHandler method sendCurrentConfig.
// Follow up after applying the updated library config.
private synchronized void sendCurrentConfig() {
// Bouncing back CurrentLibraryConfig to Agent.
io.opencensus.proto.trace.v1.TraceConfig currentTraceConfigProto = TraceProtoUtils.getCurrentTraceConfig(traceConfig);
CurrentLibraryConfig currentLibraryConfig = CurrentLibraryConfig.newBuilder().setConfig(currentTraceConfigProto).build();
sendCurrentConfig(currentLibraryConfig);
}
use of io.opencensus.proto.agent.trace.v1.CurrentLibraryConfig in project instrumentation-java by census-instrumentation.
the class FakeOcAgentTraceServiceGrpcImplTest method config.
@Test
public void config() {
FakeOcAgentTraceServiceGrpcImpl traceServiceGrpc = new FakeOcAgentTraceServiceGrpcImpl();
StreamObserver<CurrentLibraryConfig> currentConfigObsever = traceServiceGrpc.config(updatedConfigObserver);
CurrentLibraryConfig currentLibraryConfig = CurrentLibraryConfig.getDefaultInstance();
currentConfigObsever.onNext(currentLibraryConfig);
assertThat(traceServiceGrpc.getCurrentLibraryConfigs()).containsExactly(currentLibraryConfig);
assertThat(updatedLibraryConfigs).containsExactly(traceServiceGrpc.getUpdatedLibraryConfig());
updatedLibraryConfigs.clear();
}
use of io.opencensus.proto.agent.trace.v1.CurrentLibraryConfig in project instrumentation-java by census-instrumentation.
the class OcAgentTraceServiceConfigRpcHandler method sendInitialMessage.
// Sends the initial config message with Node to Agent.
// Once the initial config message is sent, the current thread will be blocked watching for
// subsequent updated library configs, unless the stream is interrupted.
synchronized void sendInitialMessage(Node node) {
io.opencensus.proto.trace.v1.TraceConfig currentTraceConfigProto = TraceProtoUtils.getCurrentTraceConfig(traceConfig);
// First config must have Node set.
CurrentLibraryConfig firstConfig = CurrentLibraryConfig.newBuilder().setNode(node).setConfig(currentTraceConfigProto).build();
sendCurrentConfig(firstConfig);
}
use of io.opencensus.proto.agent.trace.v1.CurrentLibraryConfig in project instrumentation-java by census-instrumentation.
the class FakeOcAgentTraceServiceGrpcImplTest method config_WithNeverSampler.
@Test
public void config_WithNeverSampler() {
FakeOcAgentTraceServiceGrpcImpl traceServiceGrpc = new FakeOcAgentTraceServiceGrpcImpl();
traceServiceGrpc.setUpdatedLibraryConfig(neverSampledLibraryConfig);
StreamObserver<CurrentLibraryConfig> currentConfigObsever = traceServiceGrpc.config(updatedConfigObserver);
CurrentLibraryConfig currentLibraryConfig = CurrentLibraryConfig.getDefaultInstance();
currentConfigObsever.onNext(currentLibraryConfig);
assertThat(traceServiceGrpc.getCurrentLibraryConfigs()).containsExactly(currentLibraryConfig);
assertThat(updatedLibraryConfigs).containsExactly(neverSampledLibraryConfig);
updatedLibraryConfigs.clear();
}
use of io.opencensus.proto.agent.trace.v1.CurrentLibraryConfig in project instrumentation-java by census-instrumentation.
the class OcAgentTraceServiceRpcHandlersTest method config_CreateAndSend.
@Test
public void config_CreateAndSend() throws InterruptedException {
CountDownLatch countDownLatch = new CountDownLatch(1);
traceServiceGrpc.setCountDownLatch(countDownLatch);
// Config RPC handler needs to be running in another thread.
Runnable configRunnable = new Runnable() {
@Override
public void run() {
TraceServiceStub stub = getStub(serverName);
OcAgentTraceServiceConfigRpcHandler configRpcHandler = OcAgentTraceServiceConfigRpcHandler.create(stub, mockTraceConfig);
// connection should succeed
assertThat(configRpcHandler.isCompleted()).isFalse();
// this will block this thread
configRpcHandler.sendInitialMessage(NODE);
}
};
Thread configThread = new Thread(configRunnable);
configThread.setDaemon(true);
configThread.setName("TestConfigRpcHandlerThread");
configThread.start();
// Wait until fake agent received the first message.
countDownLatch.await();
traceServiceGrpc.closeConfigStream();
// Verify fake Agent (server) received the expected CurrentLibraryConfig.
CurrentLibraryConfig expectedCurrentConfig = CurrentLibraryConfig.newBuilder().setNode(NODE).setConfig(TRACE_CONFIG_DEFAULT_PROTO).build();
assertThat(traceServiceGrpc.getCurrentLibraryConfigs()).containsExactly(expectedCurrentConfig);
// Verify ConfigRpcHandler (client) received the expected UpdatedLibraryConfig.
TraceParams expectedParams = TraceProtoUtils.getUpdatedTraceParams(traceServiceGrpc.getUpdatedLibraryConfig(), mockTraceConfig);
verify(mockTraceConfig, times(1)).updateActiveTraceParams(expectedParams);
}
Aggregations