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.
This commit is contained in:
parent
87c0f73e10
commit
9906e68451
|
|
@ -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.TimeBucketUtils;
|
||||
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.LoggerFactory;
|
||||
|
||||
|
|
@ -54,18 +55,20 @@ public class ApplicationMappingSpanListener implements FirstSpanListener, EntryS
|
|||
|
||||
@Override public void parseEntry(SpanDecorator spanDecorator, int applicationId, int instanceId, String segmentId) {
|
||||
logger.debug("application mapping listener parse reference");
|
||||
if (spanDecorator.getRefsCount() > 0) {
|
||||
for (int i = 0; i < spanDecorator.getRefsCount(); i++) {
|
||||
ApplicationMapping applicationMapping = new ApplicationMapping();
|
||||
applicationMapping.setApplicationId(applicationId);
|
||||
if (!spanDecorator.getSpanLayer().equals(SpanLayer.MQ)) {
|
||||
if (spanDecorator.getRefsCount() > 0) {
|
||||
for (int i = 0; i < spanDecorator.getRefsCount(); i++) {
|
||||
ApplicationMapping applicationMapping = new ApplicationMapping();
|
||||
applicationMapping.setApplicationId(applicationId);
|
||||
|
||||
int addressId = spanDecorator.getRefs(i).getNetworkAddressId();
|
||||
int mappingApplicationId = applicationCacheService.getApplicationIdByAddressId(addressId);
|
||||
applicationMapping.setMappingApplicationId(mappingApplicationId);
|
||||
int addressId = spanDecorator.getRefs(i).getNetworkAddressId();
|
||||
int mappingApplicationId = applicationCacheService.getApplicationIdByAddressId(addressId);
|
||||
applicationMapping.setMappingApplicationId(mappingApplicationId);
|
||||
|
||||
String metricId = String.valueOf(applicationId) + Const.ID_SPLIT + String.valueOf(applicationMapping.getMappingApplicationId());
|
||||
applicationMapping.setMetricId(metricId);
|
||||
applicationMappings.add(applicationMapping);
|
||||
String metricId = String.valueOf(applicationId) + Const.ID_SPLIT + String.valueOf(applicationMapping.getMappingApplicationId());
|
||||
applicationMapping.setMetricId(metricId);
|
||||
applicationMappings.add(applicationMapping);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.serv
|
|||
|
||||
import java.util.LinkedList;
|
||||
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.segment.parser.define.decorator.ReferenceDecorator;
|
||||
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;
|
|||
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.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.network.proto.SpanLayer;
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -78,8 +78,17 @@ public class ServiceReferenceMetricSpanListener implements FirstSpanListener, En
|
|||
ReferenceDecorator reference = spanDecorator.getRefs(i);
|
||||
ServiceReferenceMetric serviceReferenceMetric = new ServiceReferenceMetric();
|
||||
serviceReferenceMetric.setFrontServiceId(reference.getParentServiceId());
|
||||
serviceReferenceMetric.setFrontInstanceId(reference.getParentApplicationInstanceId());
|
||||
serviceReferenceMetric.setFrontApplicationId(instanceCacheService.getApplicationId(reference.getParentApplicationInstanceId()));
|
||||
|
||||
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.setFrontApplicationId(instanceCacheService.getApplicationId(reference.getParentApplicationInstanceId()));
|
||||
}
|
||||
serviceReferenceMetric.setBehindServiceId(spanDecorator.getOperationNameId());
|
||||
serviceReferenceMetric.setBehindInstanceId(instanceId);
|
||||
serviceReferenceMetric.setBehindApplicationId(applicationId);
|
||||
|
|
|
|||
Loading…
Reference in New Issue