Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
peng-yongsheng committed Oct 11, 2018
1 parent 7c192b1 commit 93aba53
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public static class Builder implements StorageBuilder<SegmentRecord> {
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());
Expand All @@ -89,6 +90,7 @@ public static class Builder implements StorageBuilder<SegmentRecord> {
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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand Down Expand Up @@ -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));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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));
}
}
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 93aba53

Please sign in to comment.