未验证 提交 c9bb3411 编写于 作者: wu-sheng's avatar wu-sheng 提交者: GitHub

Merge pull request #883 from peng-yongsheng/fixed/855

Fixed/855
...@@ -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,18 +55,20 @@ public class ApplicationMappingSpanListener implements FirstSpanListener, EntryS ...@@ -54,18 +55,20 @@ 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.getRefsCount() > 0) { if (!spanDecorator.getSpanLayer().equals(SpanLayer.MQ)) {
for (int i = 0; i < spanDecorator.getRefsCount(); i++) { if (spanDecorator.getRefsCount() > 0) {
ApplicationMapping applicationMapping = new ApplicationMapping(); for (int i = 0; i < spanDecorator.getRefsCount(); i++) {
applicationMapping.setApplicationId(applicationId); ApplicationMapping applicationMapping = new ApplicationMapping();
applicationMapping.setApplicationId(applicationId);
int addressId = spanDecorator.getRefs(i).getNetworkAddressId(); int addressId = spanDecorator.getRefs(i).getNetworkAddressId();
int mappingApplicationId = applicationCacheService.getApplicationIdByAddressId(addressId); int mappingApplicationId = applicationCacheService.getApplicationIdByAddressId(addressId);
applicationMapping.setMappingApplicationId(mappingApplicationId); applicationMapping.setMappingApplicationId(mappingApplicationId);
String metricId = String.valueOf(applicationId) + Const.ID_SPLIT + String.valueOf(applicationMapping.getMappingApplicationId()); String metricId = String.valueOf(applicationId) + Const.ID_SPLIT + String.valueOf(applicationMapping.getMappingApplicationId());
applicationMapping.setMetricId(metricId); applicationMapping.setMetricId(metricId);
applicationMappings.add(applicationMapping); applicationMappings.add(applicationMapping);
}
} }
} }
} }
......
...@@ -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());
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.setBehindServiceId(spanDecorator.getOperationNameId());
serviceReferenceMetric.setBehindInstanceId(instanceId); serviceReferenceMetric.setBehindInstanceId(instanceId);
serviceReferenceMetric.setBehindApplicationId(applicationId); serviceReferenceMetric.setBehindApplicationId(applicationId);
......
...@@ -28,7 +28,7 @@ public enum PaginationUtils { ...@@ -28,7 +28,7 @@ public enum PaginationUtils {
public Page exchange(Pagination paging) { public Page exchange(Pagination paging) {
int limit = paging.getPageSize(); int limit = paging.getPageSize();
int from = paging.getPageSize() * (paging.getPageNum() - 1); int from = paging.getPageSize() * ((paging.getPageNum() == 0 ? 1 : paging.getPageNum()) - 1);
return new Page(from, limit); return new Page(from, limit);
} }
......
...@@ -37,6 +37,13 @@ public class PaginationUtilsTestCase { ...@@ -37,6 +37,13 @@ public class PaginationUtilsTestCase {
Assert.assertEquals(0, page.getFrom()); Assert.assertEquals(0, page.getFrom());
Assert.assertEquals(10, page.getLimit()); Assert.assertEquals(10, page.getLimit());
pagination = new Pagination();
pagination.setPageSize(10);
page = PaginationUtils.INSTANCE.exchange(pagination);
Assert.assertEquals(0, page.getFrom());
Assert.assertEquals(10, page.getLimit());
pagination = new Pagination(); pagination = new Pagination();
pagination.setPageSize(10); pagination.setPageSize(10);
pagination.setPageNum(2); pagination.setPageNum(2);
......
...@@ -6,6 +6,7 @@ type TraceBrief { ...@@ -6,6 +6,7 @@ type TraceBrief {
# Trace basic info # Trace basic info
type BasicTrace { type BasicTrace {
segmentId: String!
operationName: String! operationName: String!
duration: Int! duration: Int!
start: String! start: String!
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册