use of com.navercorp.pinpoint.common.trace.ServiceType in project pinpoint by naver.
the class NodeSerializer method serialize.
@Override
public void serialize(Node node, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException {
jgen.writeStartObject();
// jgen.writeStringField("id", node.getNodeName());
// necessary for go.js
jgen.writeStringField("key", node.getNodeName());
// for go.js
jgen.writeStringField("applicationName", node.getApplicationTextName());
// necessary for go.js
jgen.writeStringField("category", node.getServiceType().toString());
jgen.writeStringField("serviceType", node.getServiceType().toString());
final ServiceType serviceType = node.getApplication().getServiceType();
// if (serviceType.isUser()) {
// jgen.writeStringField("fig", "Ellipse");
// } else if(serviceType.isWas()) {
// jgen.writeStringField("fig", "RoundedRectangle");
// } else {
// jgen.writeStringField("fig", "Rectangle");
// }
jgen.writeStringField("serviceTypeCode", Short.toString(serviceType.getCode()));
// jgen.writeStringField("terminal", Boolean.toString(serviceType.isTerminal()));
// for go.js
jgen.writeBooleanField("isWas", serviceType.isWas());
jgen.writeBooleanField("isQueue", serviceType.isQueue());
jgen.writeBooleanField("isAuthorized", node.isAuthorized());
writeHistogram(jgen, node);
if (node.getServiceType().isUnknown()) {
writeEmptyObject(jgen, "serverList");
jgen.writeNumberField("instanceCount", 0);
} else {
final ServerInstanceList serverInstanceList = node.getServerInstanceList();
if (serverInstanceList != null) {
jgen.writeObjectField("serverList", serverInstanceList);
jgen.writeNumberField("instanceCount", serverInstanceList.getInstanceCount());
} else {
writeEmptyObject(jgen, "serverList");
jgen.writeNumberField("instanceCount", 0);
}
}
jgen.writeEndObject();
}
use of com.navercorp.pinpoint.common.trace.ServiceType in project pinpoint by naver.
the class LinkFilterTest method fromToFilterAgentTest.
@Test
public void fromToFilterAgentTest() {
final ServiceType tomcat = serviceTypeRegistryService.findServiceTypeByName("TOMCAT");
final short tomcatServiceType = tomcat.getCode();
FilterDescriptor descriptor = new FilterDescriptor();
descriptor.setFromApplicationName("APP_A");
descriptor.setFromServiceType(tomcat.getName());
descriptor.setFromAgentId("AGENT_A");
descriptor.setToApplicationName("APP_B");
descriptor.setToServiceType(tomcat.getName());
descriptor.setToAgentId("AGENT_B");
FilterHint hint = new FilterHint(Collections.<RpcHint>emptyList());
LinkFilter linkFilter = new LinkFilter(descriptor, hint, serviceTypeRegistryService);
logger.debug(linkFilter.toString());
SpanBo fromSpanBo = new SpanBo();
fromSpanBo.setApplicationId("APP_A");
fromSpanBo.setServiceType(tomcatServiceType);
fromSpanBo.setAgentId("AGENT_A");
fromSpanBo.setSpanId(100);
SpanBo toSpanBO = new SpanBo();
toSpanBO.setApplicationId("APP_B");
toSpanBO.setServiceType(tomcatServiceType);
toSpanBO.setAgentId("AGENT_B");
toSpanBO.setParentSpanId(100);
SpanBo spanBoC = new SpanBo();
spanBoC.setApplicationId("APP_C");
spanBoC.setServiceType(tomcatServiceType);
spanBoC.setAgentId("AGENT_C");
Assert.assertTrue(linkFilter.include(Arrays.asList(fromSpanBo, toSpanBO)));
Assert.assertFalse(linkFilter.include(Arrays.asList(fromSpanBo, spanBoC)));
}
use of com.navercorp.pinpoint.common.trace.ServiceType in project pinpoint by naver.
the class LinkFilterTest method fromToFilterTest.
@Test
public void fromToFilterTest() {
ServiceType tomcat = serviceTypeRegistryService.findServiceTypeByName("TOMCAT");
final short tomcatServiceType = tomcat.getCode();
FilterDescriptor descriptor = new FilterDescriptor();
descriptor.setFromApplicationName("APP_A");
descriptor.setFromServiceType(tomcat.getName());
// descriptor.setFromAgentId("AGENT_A");
descriptor.setToApplicationName("APP_B");
descriptor.setToServiceType(tomcat.getName());
// descriptor.setToAgentId("AGENT_B");
FilterHint hint = new FilterHint(Collections.<RpcHint>emptyList());
LinkFilter linkFilter = new LinkFilter(descriptor, hint, serviceTypeRegistryService);
logger.debug(linkFilter.toString());
SpanBo fromSpanBo = new SpanBo();
fromSpanBo.setApplicationId("APP_A");
fromSpanBo.setServiceType(tomcatServiceType);
fromSpanBo.setAgentId("AGENT_A");
fromSpanBo.setSpanId(100);
SpanBo toSpanBO = new SpanBo();
toSpanBO.setApplicationId("APP_B");
toSpanBO.setServiceType(tomcatServiceType);
toSpanBO.setAgentId("AGENT_B");
toSpanBO.setParentSpanId(100);
SpanBo spanBoC = new SpanBo();
spanBoC.setApplicationId("APP_C");
spanBoC.setServiceType(tomcatServiceType);
spanBoC.setAgentId("AGENT_C");
Assert.assertTrue(linkFilter.include(Arrays.asList(fromSpanBo, toSpanBO)));
Assert.assertFalse(linkFilter.include(Arrays.asList(fromSpanBo, spanBoC)));
}
use of com.navercorp.pinpoint.common.trace.ServiceType in project pinpoint by naver.
the class ServerInstanceListTest method createAgentInfo.
public static AgentInfo createAgentInfo(String agentId, String hostName) {
AgentInfoBo.Builder agentInfoBuilder = new AgentInfoBo.Builder();
agentInfoBuilder.setAgentId(agentId);
ServiceType serviceType = ServiceType.TEST_STAND_ALONE;
agentInfoBuilder.setServiceTypeCode(serviceType.getCode());
agentInfoBuilder.setHostName(hostName);
return new AgentInfo(agentInfoBuilder.build());
}
use of com.navercorp.pinpoint.common.trace.ServiceType in project pinpoint by naver.
the class SpanChunkHandler method handleSimple.
@Override
public void handleSimple(TBase<?, ?> tbase) {
try {
final SpanChunkBo spanChunkBo = newSpanChunkBo(tbase);
traceDao.insertSpanChunk(spanChunkBo);
final ServiceType applicationServiceType = getApplicationServiceType(spanChunkBo);
List<SpanEventBo> spanEventList = spanChunkBo.getSpanEventBoList();
if (spanEventList != null) {
if (logger.isDebugEnabled()) {
logger.debug("SpanChunk Size:{}", spanEventList.size());
}
// TODO need to batch update later.
for (SpanEventBo spanEvent : spanEventList) {
final ServiceType spanEventType = registry.findServiceType(spanEvent.getServiceType());
if (!spanEventType.isRecordStatistics()) {
continue;
}
// if terminal update statistics
final int elapsed = spanEvent.getEndElapsed();
final boolean hasException = spanEvent.hasException();
/*
* save information to draw a server map based on statistics
*/
// save the information of caller (the spanevent that span called)
statisticsHandler.updateCaller(spanChunkBo.getApplicationId(), applicationServiceType, spanChunkBo.getAgentId(), spanEvent.getDestinationId(), spanEventType, spanEvent.getEndPoint(), elapsed, hasException);
// save the information of callee (the span that called spanevent)
statisticsHandler.updateCallee(spanEvent.getDestinationId(), spanEventType, spanChunkBo.getApplicationId(), applicationServiceType, spanChunkBo.getEndPoint(), elapsed, hasException);
}
}
} catch (Exception e) {
logger.warn("SpanChunk handle error Caused:{}", e.getMessage(), e);
}
}
Aggregations