use of com.navercorp.pinpoint.grpc.Header in project pinpoint by naver.
the class GrpcAgentStatMapper method map.
public AgentStatBo map(PAgentStat agentStat) {
if (agentStat == null) {
return null;
}
final Header agentInfo = ServerContext.getAgentInfo();
final String agentId = agentInfo.getAgentId();
final long startTimestamp = agentInfo.getAgentStartTime();
final AgentStatBo.Builder builder = AgentStatBo.newBuilder(agentId, startTimestamp);
this.map(agentStat, builder);
return builder.build();
}
use of com.navercorp.pinpoint.grpc.Header in project pinpoint by naver.
the class GrpcSpanChunkHandler method handleSpanChunk.
private void handleSpanChunk(PSpanChunk spanChunk) {
if (isDebug) {
logger.debug("Handle PSpanChunk={}", createSimpleSpanChunkLog(spanChunk));
}
try {
final Header agentInfo = ServerContext.getAgentInfo();
final SpanChunkBo spanChunkBo = spanFactory.buildSpanChunkBo(spanChunk, agentInfo);
this.traceService.insertSpanChunk(spanChunkBo);
} catch (Exception e) {
logger.warn("Failed to handle spanChunk={}", MessageFormatUtils.debugLog(spanChunk), e);
}
}
use of com.navercorp.pinpoint.grpc.Header in project pinpoint by naver.
the class GrpcSqlMetaDataHandler method handleSqlMetaData.
private PResult handleSqlMetaData(PSqlMetaData sqlMetaData) {
if (isDebug) {
logger.debug("Handle PSqlMetaData={}", MessageFormatUtils.debugLog(sqlMetaData));
}
try {
final Header agentInfo = ServerContext.getAgentInfo();
final String agentId = agentInfo.getAgentId();
final long agentStartTime = agentInfo.getAgentStartTime();
final SqlMetaDataBo sqlMetaDataBo = new SqlMetaDataBo(agentId, agentStartTime, sqlMetaData.getSqlId(), sqlMetaData.getSql());
sqlMetaDataService.insert(sqlMetaDataBo);
return PResult.newBuilder().setSuccess(true).build();
} catch (Exception e) {
logger.warn("Failed to handle sqlMetaData={}", MessageFormatUtils.debugLog(sqlMetaData), e);
// Avoid detailed error messages.
return PResult.newBuilder().setSuccess(false).setMessage("Internal Server Error").build();
}
}
use of com.navercorp.pinpoint.grpc.Header in project pinpoint by naver.
the class GrpcCommandServiceTest method oldVersionHandshakeTest.
@Test
public void oldVersionHandshakeTest() throws IOException, PinpointZookeeperException {
ZookeeperProfilerClusterManager manager = creteMemoryClusterManager();
ZookeeperClusterService mockClusterService = Mockito.mock(ZookeeperClusterService.class);
Mockito.when(mockClusterService.getProfilerClusterManager()).thenReturn(manager);
try (GrpcCommandService commandService = new GrpcCommandService(mockClusterService)) {
TransportMetadata transportMetaData = createTransportMetaData(new InetSocketAddress("127.0.0.1", 61613), 10);
attachContext(transportMetaData);
attachContext(new Header("test", "agentId", "agentName", "applicationName", ServiceType.UNDEFINED.getCode(), System.currentTimeMillis(), Header.SOCKET_ID_NOT_EXIST, null));
StreamObserver<PCmdMessage> handleMessageObserver = commandService.handleCommand(new TempServerCallStreamObserver<>());
handleMessageObserver.onNext(createHandshakeMessage());
awaitility().await("oldVersionHandshakeTest").until(manager::getClusterData, hasSize(1));
assertHandleMessage(commandService, transportMetaData);
}
}
use of com.navercorp.pinpoint.grpc.Header in project pinpoint by naver.
the class GrpcCommandServiceTest method oldVersionHandshakeFailTest.
@Test
public void oldVersionHandshakeFailTest() throws IOException, PinpointZookeeperException {
ZookeeperProfilerClusterManager manager = creteMemoryClusterManager();
ZookeeperClusterService mockClusterService = Mockito.mock(ZookeeperClusterService.class);
Mockito.when(mockClusterService.getProfilerClusterManager()).thenReturn(manager);
try (GrpcCommandService commandService = new GrpcCommandService(mockClusterService)) {
TransportMetadata transportMetaData = createTransportMetaData(new InetSocketAddress("127.0.0.1", 61613), 10);
attachContext(transportMetaData);
attachContext(new Header("test", "agentId", "agentName", "applicationName", ServiceType.UNDEFINED.getCode(), System.currentTimeMillis(), Header.SOCKET_ID_NOT_EXIST, getCodeList()));
final TempServerCallStreamObserver<PCmdRequest> requestObserver = new TempServerCallStreamObserver<>();
StreamObserver<PCmdMessage> handleMessageObserver = commandService.handleCommand(requestObserver);
Assert.assertThrows(ConditionTimeoutException.class, () -> {
Awaitility.await("oldVersionHandshakeFailTest").timeout(400, TimeUnit.MILLISECONDS).until(manager::getClusterData, hasSize(1));
});
Assert.assertNotNull(requestObserver.getLatestException());
}
}
Aggregations