Search in sources :

Example 1 with Header

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();
}
Also used : AgentStatBo(com.navercorp.pinpoint.common.server.bo.stat.AgentStatBo) Header(com.navercorp.pinpoint.grpc.Header)

Example 2 with Header

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);
    }
}
Also used : Header(com.navercorp.pinpoint.grpc.Header) SpanChunkBo(com.navercorp.pinpoint.common.server.bo.SpanChunkBo)

Example 3 with Header

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();
    }
}
Also used : Header(com.navercorp.pinpoint.grpc.Header) SqlMetaDataBo(com.navercorp.pinpoint.common.server.bo.SqlMetaDataBo)

Example 4 with Header

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);
    }
}
Also used : PCmdMessage(com.navercorp.pinpoint.grpc.trace.PCmdMessage) ZookeeperClusterService(com.navercorp.pinpoint.collector.cluster.zookeeper.ZookeeperClusterService) ZookeeperProfilerClusterManager(com.navercorp.pinpoint.collector.cluster.zookeeper.ZookeeperProfilerClusterManager) Header(com.navercorp.pinpoint.grpc.Header) DefaultTransportMetadata(com.navercorp.pinpoint.grpc.server.DefaultTransportMetadata) TransportMetadata(com.navercorp.pinpoint.grpc.server.TransportMetadata) InetSocketAddress(java.net.InetSocketAddress) GrpcCommandService(com.navercorp.pinpoint.collector.receiver.grpc.service.command.GrpcCommandService) Test(org.junit.Test)

Example 5 with Header

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());
    }
}
Also used : PCmdMessage(com.navercorp.pinpoint.grpc.trace.PCmdMessage) ZookeeperClusterService(com.navercorp.pinpoint.collector.cluster.zookeeper.ZookeeperClusterService) ZookeeperProfilerClusterManager(com.navercorp.pinpoint.collector.cluster.zookeeper.ZookeeperProfilerClusterManager) Header(com.navercorp.pinpoint.grpc.Header) DefaultTransportMetadata(com.navercorp.pinpoint.grpc.server.DefaultTransportMetadata) TransportMetadata(com.navercorp.pinpoint.grpc.server.TransportMetadata) PCmdRequest(com.navercorp.pinpoint.grpc.trace.PCmdRequest) InetSocketAddress(java.net.InetSocketAddress) GrpcCommandService(com.navercorp.pinpoint.collector.receiver.grpc.service.command.GrpcCommandService) Test(org.junit.Test)

Aggregations

Header (com.navercorp.pinpoint.grpc.Header)28 Test (org.junit.Test)10 SpanChunkBo (com.navercorp.pinpoint.common.server.bo.SpanChunkBo)5 TransportMetadata (com.navercorp.pinpoint.grpc.server.TransportMetadata)5 SpanEventBo (com.navercorp.pinpoint.common.server.bo.SpanEventBo)4 PSpanChunk (com.navercorp.pinpoint.grpc.trace.PSpanChunk)4 InetSocketAddress (java.net.InetSocketAddress)4 ZookeeperClusterService (com.navercorp.pinpoint.collector.cluster.zookeeper.ZookeeperClusterService)3 ZookeeperProfilerClusterManager (com.navercorp.pinpoint.collector.cluster.zookeeper.ZookeeperProfilerClusterManager)3 GrpcCommandService (com.navercorp.pinpoint.collector.receiver.grpc.service.command.GrpcCommandService)3 DefaultTransportMetadata (com.navercorp.pinpoint.grpc.server.DefaultTransportMetadata)3 PCmdMessage (com.navercorp.pinpoint.grpc.trace.PCmdMessage)3 Metadata (io.grpc.Metadata)3 AgentProperty (com.navercorp.pinpoint.collector.service.async.AgentProperty)2 DefaultAgentProperty (com.navercorp.pinpoint.collector.service.async.DefaultAgentProperty)2 AgentInfoBo (com.navercorp.pinpoint.common.server.bo.AgentInfoBo)2 AgentEventBo (com.navercorp.pinpoint.common.server.bo.event.AgentEventBo)2 AgentStatBo (com.navercorp.pinpoint.common.server.bo.stat.AgentStatBo)2 Context (io.grpc.Context)2 GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)1