wu-sheng closed pull request #1755: Fixed the bugs
URL: https://github.com/apache/incubator-skywalking/pull/1755
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/segment/SegmentRecord.java
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/segment/SegmentRecord.java
index 1249ac8e0..d5a842a5e 100644
---
a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/segment/SegmentRecord.java
+++
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/manual/segment/SegmentRecord.java
@@ -70,6 +70,7 @@
map.put(TRACE_ID, storageData.getTraceId());
map.put(SERVICE_ID, storageData.getServiceId());
map.put(ENDPOINT_NAME, storageData.getEndpointName());
+ map.put(ENDPOINT_ID, storageData.getEndpointId());
map.put(START_TIME, storageData.getStartTime());
map.put(END_TIME, storageData.getEndTime());
map.put(LATENCY, storageData.getLatency());
@@ -89,6 +90,7 @@
record.setTraceId((String)dbMap.get(TRACE_ID));
record.setServiceId(((Number)dbMap.get(SERVICE_ID)).intValue());
record.setEndpointName((String)dbMap.get(ENDPOINT_NAME));
+ record.setEndpointId(((Number)dbMap.get(ENDPOINT_ID)).intValue());
record.setStartTime(((Number)dbMap.get(START_TIME)).longValue());
record.setEndTime(((Number)dbMap.get(END_TIME)).longValue());
record.setLatency(((Number)dbMap.get(LATENCY)).intValue());
diff --git
a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/MetricQueryService.java
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/MetricQueryService.java
index 572581c35..1b10baf32 100644
---
a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/MetricQueryService.java
+++
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/MetricQueryService.java
@@ -21,6 +21,7 @@
import java.io.IOException;
import java.text.ParseException;
import java.util.*;
+import org.apache.skywalking.apm.util.StringUtil;
import org.apache.skywalking.oap.server.core.Const;
import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator;
import org.apache.skywalking.oap.server.core.query.entity.*;
@@ -68,7 +69,11 @@ public IntValues getLinearIntValues(final String indName,
final String id, final
final long endTB) throws IOException, ParseException {
List<DurationPoint> durationPoints =
DurationUtils.INSTANCE.getDurationPoints(step, startTB, endTB);
List<String> ids = new ArrayList<>();
- durationPoints.forEach(durationPoint ->
ids.add(durationPoint.getPoint() + Const.ID_SPLIT + id));
+ if (StringUtil.isEmpty(id)) {
+ durationPoints.forEach(durationPoint ->
ids.add(String.valueOf(durationPoint.getPoint())));
+ } else {
+ durationPoints.forEach(durationPoint ->
ids.add(durationPoint.getPoint() + Const.ID_SPLIT + id));
+ }
return getMetricQueryDAO().getLinearIntValues(indName, step, ids,
ValueColumnIds.INSTANCE.getValueCName(indName));
}
diff --git
a/oap-server/server-library/library-util/src/test/java/org/apache/skywalking/oap/server/library/util/TimestampUtils.java
b/oap-server/server-library/library-util/src/test/java/org/apache/skywalking/oap/server/library/util/TimestampUtils.java
new file mode 100644
index 000000000..050971284
--- /dev/null
+++
b/oap-server/server-library/library-util/src/test/java/org/apache/skywalking/oap/server/library/util/TimestampUtils.java
@@ -0,0 +1,37 @@
+/*
+ * 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.oap.server.library.util;
+
+import java.sql.Timestamp;
+import java.text.SimpleDateFormat;
+import org.slf4j.*;
+
+/**
+ * @author peng-yongsheng
+ */
+public class TimestampUtils {
+
+ private static final Logger logger =
LoggerFactory.getLogger(TimestampUtils.class);
+
+ public static void main(String[] args) {
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ Timestamp timestamp = new Timestamp(1483200061001L);
+ logger.info("time: {}", format.format(timestamp));
+ }
+}
diff --git
a/oap-server/server-library/library-util/src/test/resources/log4j2.xml
b/oap-server/server-library/library-util/src/test/resources/log4j2.xml
new file mode 100644
index 000000000..6eb5b3fb9
--- /dev/null
+++ b/oap-server/server-library/library-util/src/test/resources/log4j2.xml
@@ -0,0 +1,31 @@
+<?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="DEBUG">
+ <Appenders>
+ <Console name="Console" target="SYSTEM_OUT">
+ <PatternLayout charset="UTF-8" pattern="%d - %c -%-4r [%t] %-5p %x
- %m%n"/>
+ </Console>
+ </Appenders>
+ <Loggers>
+ <Root level="DEBUG">
+ <AppenderRef ref="Console"/>
+ </Root>
+ </Loggers>
+</Configuration>
diff --git
a/oap-server/server-receiver-plugin/skywalking-register-receiver-plugin/src/test/java/org/apache/skywalking/oap/server/receiver/register/provider/handler/v5/InstanceHeartBeatTestCase.java
b/oap-server/server-receiver-plugin/skywalking-register-receiver-plugin/src/test/java/org/apache/skywalking/oap/server/receiver/register/provider/handler/v5/InstanceHeartBeatTestCase.java
index 4f31c0a62..45365a709 100644
---
a/oap-server/server-receiver-plugin/skywalking-register-receiver-plugin/src/test/java/org/apache/skywalking/oap/server/receiver/register/provider/handler/v5/InstanceHeartBeatTestCase.java
+++
b/oap-server/server-receiver-plugin/skywalking-register-receiver-plugin/src/test/java/org/apache/skywalking/oap/server/receiver/register/provider/handler/v5/InstanceHeartBeatTestCase.java
@@ -35,5 +35,8 @@ public static void main(String[] args) {
builder.setApplicationInstanceId(2);
builder.setHeartbeatTime(System.currentTimeMillis() + 5 * 1000 * 60);
Downstream heartbeat = stub.heartbeat(builder.build());
+
+ builder.setApplicationInstanceId(3);
+ heartbeat = stub.heartbeat(builder.build());
}
}
diff --git
a/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/listener/endpoint/MultiScopesSpanListener.java
b/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/listener/endpoint/MultiScopesSpanListener.java
index c64305e4f..dd7797c56 100644
---
a/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/listener/endpoint/MultiScopesSpanListener.java
+++
b/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/listener/endpoint/MultiScopesSpanListener.java
@@ -137,7 +137,7 @@ private void setPublicAttrs(SourceBuilder sourceBuilder,
SpanDecorator spanDecor
long latency = spanDecorator.getEndTime() -
spanDecorator.getStartTime();
sourceBuilder.setLatency((int)latency);
sourceBuilder.setResponseCode(Const.NONE);
- sourceBuilder.setStatus(spanDecorator.getIsError());
+ sourceBuilder.setStatus(!spanDecorator.getIsError());
switch (spanDecorator.getSpanLayer()) {
case Http:
diff --git
a/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/listener/segment/SegmentSpanListener.java
b/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/listener/segment/SegmentSpanListener.java
index bb5f06a6f..49c92b2dd 100644
---
a/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/listener/segment/SegmentSpanListener.java
+++
b/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/listener/segment/SegmentSpanListener.java
@@ -54,7 +54,6 @@ private SegmentSpanListener(ModuleManager moduleManager) {
public void parseFirst(SpanDecorator spanDecorator, SegmentCoreInfo
segmentCoreInfo) {
long timeBucket =
TimeBucketUtils.INSTANCE.getSecondTimeBucket(segmentCoreInfo.getStartTime());
- segment.setSegmentId(segmentCoreInfo.getSegmentId());
segment.setSegmentId(segmentCoreInfo.getSegmentId());
segment.setServiceId(segmentCoreInfo.getApplicationId());
segment.setLatency((int)(segmentCoreInfo.getEndTime() -
segmentCoreInfo.getStartTime()));
diff --git
a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/TraceQueryEsDAO.java
b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/TraceQueryEsDAO.java
index 17a0703d9..04952d7fe 100644
---
a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/TraceQueryEsDAO.java
+++
b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/TraceQueryEsDAO.java
@@ -109,6 +109,7 @@ public TraceBrief queryBasicTraces(long startSecondTB, long
endSecondTB, long mi
basicTrace.getEndpointNames().add((String)searchHit.getSourceAsMap().get(SegmentRecord.ENDPOINT_NAME));
basicTrace.setDuration(((Number)searchHit.getSourceAsMap().get(SegmentRecord.LATENCY)).intValue());
basicTrace.setError(BooleanUtils.valueToBoolean(((Number)searchHit.getSourceAsMap().get(SegmentRecord.IS_ERROR)).intValue()));
+
basicTrace.getTraceIds().add((String)searchHit.getSourceAsMap().get(SegmentRecord.TRACE_ID));
traceBrief.getTraces().add(basicTrace);
}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services