Search in sources :

Example 6 with Header

use of com.navercorp.pinpoint.grpc.Header in project pinpoint by naver.

the class CollectorGrpcSpanFactoryTest method buildSpanChunkBo_first_depth_zero.

@Test
public void buildSpanChunkBo_first_depth_zero() {
    final PSpanChunk chunk = newSpanChunk_first_depth_zero();
    final Header header = newHeader();
    SpanChunkBo spanChunkBo = factory.buildSpanChunkBo(chunk, header);
    List<SpanEventBo> spanEventBoList = spanChunkBo.getSpanEventBoList();
    SpanEventBo spanEventBo0 = spanEventBoList.get(0);
    SpanEventBo spanEventBo1 = spanEventBoList.get(1);
    Assert.assertEquals(0, spanEventBo0.getDepth());
    Assert.assertEquals(1, spanEventBo1.getDepth());
}
Also used : Header(com.navercorp.pinpoint.grpc.Header) SpanChunkBo(com.navercorp.pinpoint.common.server.bo.SpanChunkBo) PSpanChunk(com.navercorp.pinpoint.grpc.trace.PSpanChunk) SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo) Test(org.junit.Test)

Example 7 with Header

use of com.navercorp.pinpoint.grpc.Header in project pinpoint by naver.

the class CollectorGrpcSpanFactoryTest method buildSpanChunkBo_compact_depth_NPE.

@Test
public void buildSpanChunkBo_compact_depth_NPE() {
    final PSpanChunk chunk = newSpanChunk_compact_depth_error();
    final Header header = newHeader();
    SpanChunkBo spanChunkBo = factory.buildSpanChunkBo(chunk, header);
    List<SpanEventBo> spanEventBoList = spanChunkBo.getSpanEventBoList();
    SpanEventBo spanEventBo0 = spanEventBoList.get(0);
    Assert.assertEquals(1, spanEventBo0.getDepth());
}
Also used : Header(com.navercorp.pinpoint.grpc.Header) SpanChunkBo(com.navercorp.pinpoint.common.server.bo.SpanChunkBo) PSpanChunk(com.navercorp.pinpoint.grpc.trace.PSpanChunk) SpanEventBo(com.navercorp.pinpoint.common.server.bo.SpanEventBo) Test(org.junit.Test)

Example 8 with Header

use of com.navercorp.pinpoint.grpc.Header in project pinpoint by naver.

the class AgentLifecycleListener method connect.

@Override
public void connect(PingSession lifecycle) {
    logger.info("connect:{}", lifecycle);
    final Header header = lifecycle.getHeader();
    try {
        final AgentInfoBo agentInfoBo = agentInfoService.getAgentInfo(header.getAgentId(), header.getAgentStartTime());
        if (null != agentInfoBo) {
            lifecycle.setServiceType(agentInfoBo.getServiceTypeCode());
        }
    } catch (Exception e) {
        logger.warn("Failed to handle. ping session={}", lifecycle, e);
    }
    lifecycleService.updateState(lifecycle, ManagedAgentLifeCycle.RUNNING);
}
Also used : AgentInfoBo(com.navercorp.pinpoint.common.server.bo.AgentInfoBo) Header(com.navercorp.pinpoint.grpc.Header)

Example 9 with Header

use of com.navercorp.pinpoint.grpc.Header in project pinpoint by naver.

the class DefaultServerRequestFactory method newServerRequest.

@Override
public <T> ServerRequest<T> newServerRequest(Message<T> message) throws StatusException {
    final Context current = Context.current();
    final Header header = ServerContext.getAgentInfo(current);
    if (header == null) {
        throw Status.INTERNAL.withDescription("Not found request header").asException();
    }
    final TransportMetadata transportMetadata = ServerContext.getTransportMetadata(current);
    if (transportMetadata == null) {
        throw Status.INTERNAL.withDescription("Not found transportMetadata").asException();
    }
    InetSocketAddress inetSocketAddress = transportMetadata.getRemoteAddress();
    ServerRequest<T> request = new DefaultServerRequest<>(message, inetSocketAddress.getHostString(), inetSocketAddress.getPort());
    return request;
}
Also used : ServerContext(com.navercorp.pinpoint.grpc.server.ServerContext) Context(io.grpc.Context) Header(com.navercorp.pinpoint.grpc.Header) TransportMetadata(com.navercorp.pinpoint.grpc.server.TransportMetadata) InetSocketAddress(java.net.InetSocketAddress) DefaultServerRequest(com.navercorp.pinpoint.io.request.DefaultServerRequest)

Example 10 with Header

use of com.navercorp.pinpoint.grpc.Header in project pinpoint by naver.

the class AgentHeaderReaderTest method extract_no_agentName.

@Test
public void extract_no_agentName() {
    Metadata metadata = newMetadata();
    metadata.remove(Header.AGENT_NAME_KEY, AGENT_NAME);
    final Header header = reader.extract(metadata);
    Assert.assertNull(header.getAgentName());
}
Also used : Header(com.navercorp.pinpoint.grpc.Header) Metadata(io.grpc.Metadata) 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