提交 9906e684 编写于 作者: P peng-yongsheng

When entry span layer is MQ:

1. Use peer id in entry span to find the instance id and application id.
2. Make the instance id and application id to be the front instance id and front application id of the reference metric.
3. Do not create the application mapping metric.
上级 87c0f73e
...@@ -34,6 +34,7 @@ import org.apache.skywalking.apm.collector.core.module.ModuleManager; ...@@ -34,6 +34,7 @@ import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.core.util.Const; import org.apache.skywalking.apm.collector.core.util.Const;
import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils;
import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMapping; import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMapping;
import org.apache.skywalking.apm.network.proto.SpanLayer;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -54,6 +55,7 @@ public class ApplicationMappingSpanListener implements FirstSpanListener, EntryS ...@@ -54,6 +55,7 @@ public class ApplicationMappingSpanListener implements FirstSpanListener, EntryS
@Override public void parseEntry(SpanDecorator spanDecorator, int applicationId, int instanceId, String segmentId) { @Override public void parseEntry(SpanDecorator spanDecorator, int applicationId, int instanceId, String segmentId) {
logger.debug("application mapping listener parse reference"); logger.debug("application mapping listener parse reference");
if (!spanDecorator.getSpanLayer().equals(SpanLayer.MQ)) {
if (spanDecorator.getRefsCount() > 0) { if (spanDecorator.getRefsCount() > 0) {
for (int i = 0; i < spanDecorator.getRefsCount(); i++) { for (int i = 0; i < spanDecorator.getRefsCount(); i++) {
ApplicationMapping applicationMapping = new ApplicationMapping(); ApplicationMapping applicationMapping = new ApplicationMapping();
...@@ -69,6 +71,7 @@ public class ApplicationMappingSpanListener implements FirstSpanListener, EntryS ...@@ -69,6 +71,7 @@ public class ApplicationMappingSpanListener implements FirstSpanListener, EntryS
} }
} }
} }
}
@Override @Override
public void parseFirst(SpanDecorator spanDecorator, int applicationId, int instanceId, public void parseFirst(SpanDecorator spanDecorator, int applicationId, int instanceId,
......
...@@ -20,7 +20,6 @@ package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.serv ...@@ -20,7 +20,6 @@ package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.serv
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import org.apache.skywalking.apm.collector.storage.table.MetricSource;
import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricGraphIdDefine; import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricGraphIdDefine;
import org.apache.skywalking.apm.collector.analysis.segment.parser.define.decorator.ReferenceDecorator; import org.apache.skywalking.apm.collector.analysis.segment.parser.define.decorator.ReferenceDecorator;
import org.apache.skywalking.apm.collector.analysis.segment.parser.define.decorator.SpanDecorator; import org.apache.skywalking.apm.collector.analysis.segment.parser.define.decorator.SpanDecorator;
...@@ -38,6 +37,7 @@ import org.apache.skywalking.apm.collector.core.module.ModuleManager; ...@@ -38,6 +37,7 @@ import org.apache.skywalking.apm.collector.core.module.ModuleManager;
import org.apache.skywalking.apm.collector.core.util.Const; import org.apache.skywalking.apm.collector.core.util.Const;
import org.apache.skywalking.apm.collector.core.util.ObjectUtils; import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils;
import org.apache.skywalking.apm.collector.storage.table.MetricSource;
import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetric; import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetric;
import org.apache.skywalking.apm.network.proto.SpanLayer; import org.apache.skywalking.apm.network.proto.SpanLayer;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -78,8 +78,17 @@ public class ServiceReferenceMetricSpanListener implements FirstSpanListener, En ...@@ -78,8 +78,17 @@ public class ServiceReferenceMetricSpanListener implements FirstSpanListener, En
ReferenceDecorator reference = spanDecorator.getRefs(i); ReferenceDecorator reference = spanDecorator.getRefs(i);
ServiceReferenceMetric serviceReferenceMetric = new ServiceReferenceMetric(); ServiceReferenceMetric serviceReferenceMetric = new ServiceReferenceMetric();
serviceReferenceMetric.setFrontServiceId(reference.getParentServiceId()); serviceReferenceMetric.setFrontServiceId(reference.getParentServiceId());
if (spanDecorator.getSpanLayer().equals(SpanLayer.MQ)) {
int peerId = spanDecorator.getPeerId();
int applicationIdByPeerId = applicationCacheService.getApplicationIdByAddressId(peerId);
int instanceIdByPeerId = instanceCacheService.getInstanceIdByAddressId(applicationIdByPeerId, peerId);
serviceReferenceMetric.setFrontInstanceId(instanceIdByPeerId);
serviceReferenceMetric.setFrontApplicationId(applicationIdByPeerId);
} else {
serviceReferenceMetric.setFrontInstanceId(reference.getParentApplicationInstanceId()); serviceReferenceMetric.setFrontInstanceId(reference.getParentApplicationInstanceId());
serviceReferenceMetric.setFrontApplicationId(instanceCacheService.getApplicationId(reference.getParentApplicationInstanceId())); serviceReferenceMetric.setFrontApplicationId(instanceCacheService.getApplicationId(reference.getParentApplicationInstanceId()));
}
serviceReferenceMetric.setBehindServiceId(spanDecorator.getOperationNameId()); serviceReferenceMetric.setBehindServiceId(spanDecorator.getOperationNameId());
serviceReferenceMetric.setBehindInstanceId(instanceId); serviceReferenceMetric.setBehindInstanceId(instanceId);
serviceReferenceMetric.setBehindApplicationId(applicationId); serviceReferenceMetric.setBehindApplicationId(applicationId);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册