Add application node when the source of reference is not have application metric.
This commit is contained in:
parent
c7dae338f0
commit
da3d993e4d
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.apm.collector.analysis.segment.parser.provider.service;
|
||||
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
import org.apache.skywalking.apm.network.proto.SpanObject;
|
||||
import org.apache.skywalking.apm.network.proto.TraceSegmentObject;
|
||||
import org.apache.skywalking.apm.network.proto.UniqueId;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class SegmentBase64Printer {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(SegmentBase64Printer.class);
|
||||
|
||||
public static void main(String[] args) throws InvalidProtocolBufferException {
|
||||
String segmentBase64 = "CgwKCgIBsv/x1L2vgBsSggEQ////////////ARirnsP1niwg9Z7D9Z4sOhhIMi9KREJJL0Nvbm5lY3Rpb24vY2xvc2VKDGxvY2FsaG9zdDotMVABWAFgBHoOCgdkYi50eXBlEgNzcWx6GQoLZGIuaW5zdGFuY2USCmRhdGFTb3VyY2V6DgoMZGIuc3RhdGVtZW50GP///////////wEgAg==";
|
||||
byte[] binarySegment = Base64.getDecoder().decode(segmentBase64);
|
||||
TraceSegmentObject segmentObject = TraceSegmentObject.parseFrom(binarySegment);
|
||||
|
||||
UniqueId segmentId = segmentObject.getTraceSegmentId();
|
||||
StringBuilder segmentIdBuilder = new StringBuilder();
|
||||
for (int i = 0; i < segmentId.getIdPartsList().size(); i++) {
|
||||
if (i == 0) {
|
||||
segmentIdBuilder.append(segmentId.getIdPartsList().get(i));
|
||||
} else {
|
||||
segmentIdBuilder.append(".").append(segmentId.getIdPartsList().get(i));
|
||||
}
|
||||
}
|
||||
LOGGER.info("SegmentId: {}", segmentIdBuilder.toString());
|
||||
LOGGER.info("ApplicationId: {}", segmentObject.getApplicationId());
|
||||
LOGGER.info("ApplicationInstanceId: {}", segmentObject.getApplicationInstanceId());
|
||||
List<SpanObject> spansList = segmentObject.getSpansList();
|
||||
LOGGER.info("Spans:");
|
||||
spansList.forEach(span -> {
|
||||
LOGGER.info(" Span:");
|
||||
LOGGER.info(" SpanId: {}", span.getSpanId());
|
||||
LOGGER.info(" ParentSpanId: {}", span.getParentSpanId());
|
||||
LOGGER.info(" SpanLayer: {}", span.getSpanLayer());
|
||||
LOGGER.info(" SpanType: {}", span.getSpanType());
|
||||
LOGGER.info(" StartTime: {}", span.getStartTime());
|
||||
LOGGER.info(" EndTime: {}", span.getEndTime());
|
||||
LOGGER.info(" ComponentId: {}", span.getComponentId());
|
||||
LOGGER.info(" Component: {}", span.getComponent());
|
||||
LOGGER.info(" OperationNameId: {}", span.getOperationNameId());
|
||||
LOGGER.info(" OperationName: {}", span.getOperationName());
|
||||
LOGGER.info(" PeerId: {}", span.getPeerId());
|
||||
LOGGER.info(" Peer: {}", span.getPeer());
|
||||
LOGGER.info(" IsError: {}", span.getIsError());
|
||||
|
||||
LOGGER.info(" reference:");
|
||||
span.getRefsList().forEach(reference -> {
|
||||
LOGGER.info(" EntryApplicationInstanceId: {}", reference.getEntryApplicationInstanceId());
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
~ contributor license agreements. See the NOTICE file distributed with
|
||||
~ this work for additional information regarding copyright ownership.
|
||||
~ The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
~ (the "License"); you may not use this file except in compliance with
|
||||
~ the License. You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
~
|
||||
-->
|
||||
|
||||
<Configuration status="info">
|
||||
<Appenders>
|
||||
<Console name="Console" target="SYSTEM_OUT">
|
||||
<PatternLayout charset="UTF-8" pattern="%d - %c -%-4r [%t] %-5p %x - %m%n"/>
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<logger name="org.eclipse.jetty" level="INFO"/>
|
||||
<logger name="org.apache.zookeeper" level="INFO"/>
|
||||
<logger name="org.elasticsearch.common.network.IfConfig" level="INFO"/>
|
||||
<logger name="org.apache.skywalking.apm.collector.agent.grpc.provider.handler.JVMMetricsServiceHandler" level="INFO"/>
|
||||
<logger name="org.apache.skywalking.apm.collector.analysis.worker.timer.PersistenceTimer" level="INFO"/>
|
||||
<logger name="io.grpc.netty" level="INFO"/>
|
||||
<Root level="info">
|
||||
<AppenderRef ref="Console"/>
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
|
|
@ -20,9 +20,11 @@ package org.apache.skywalking.apm.collector.ui.service;
|
|||
|
||||
import java.text.ParseException;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.apache.skywalking.apm.collector.cache.CacheModule;
|
||||
import org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
|
|
@ -133,6 +135,17 @@ class TopologyBuilder {
|
|||
nodes.add(conjecturalNode);
|
||||
}
|
||||
|
||||
Set<Integer> nodeIds = buildNodeIds(nodes);
|
||||
if (!nodeIds.contains(source.getApplicationId())) {
|
||||
ApplicationNode applicationNode = new ApplicationNode();
|
||||
applicationNode.setId(source.getApplicationId());
|
||||
applicationNode.setName(source.getApplicationCode());
|
||||
applicationNode.setType(components.getOrDefault(source.getApplicationId(), Const.UNKNOWN));
|
||||
applicationNode.setApdex(100);
|
||||
applicationNode.setSla(100);
|
||||
nodes.add(applicationNode);
|
||||
}
|
||||
|
||||
Call call = new Call();
|
||||
call.setSource(source.getApplicationId());
|
||||
call.setSourceName(source.getApplicationCode());
|
||||
|
|
@ -198,6 +211,12 @@ class TopologyBuilder {
|
|||
return topology;
|
||||
}
|
||||
|
||||
private Set<Integer> buildNodeIds(List<Node> nodes) {
|
||||
Set<Integer> nodeIds = new HashSet<>();
|
||||
nodes.forEach(node -> nodeIds.add(node.getId()));
|
||||
return nodeIds;
|
||||
}
|
||||
|
||||
private List<IApplicationReferenceMetricUIDAO.ApplicationReferenceMetric> calleeReferenceMetricFilter(
|
||||
List<IApplicationReferenceMetricUIDAO.ApplicationReferenceMetric> calleeReferenceMetric) {
|
||||
List<IApplicationReferenceMetricUIDAO.ApplicationReferenceMetric> filteredMetrics = new LinkedList<>();
|
||||
|
|
|
|||
Loading…
Reference in New Issue