diff --git a/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/test/java/org/apache/skywalking/apm/collector/agent/grpc/provider/handler/mock/ProviderMock.java b/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/test/java/org/apache/skywalking/apm/collector/agent/grpc/provider/handler/mock/ProviderMock.java index 42dd356fbdeb2b255be9191398cbf84aa0cd7670..ec46bd743be6e80ec80241f03e72f4f1f4d50334 100644 --- a/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/test/java/org/apache/skywalking/apm/collector/agent/grpc/provider/handler/mock/ProviderMock.java +++ b/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/test/java/org/apache/skywalking/apm/collector/agent/grpc/provider/handler/mock/ProviderMock.java @@ -85,7 +85,7 @@ class ProviderMock { span.setStartTime(startTimestamp + 510); span.setEndTime(startTimestamp + 1490); span.setComponentId(ComponentsDefine.MONGODB.getId()); - span.setIsError(false); + span.setIsError(true); if (isPrepare) { span.setOperationName("mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]"); diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/graph/MetricGraphIdDefine.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/graph/MetricGraphIdDefine.java index de3545e30c4bdb0c27e87da595392bcbb145fb2d..b1896f6f5d7a97d89da47f5fef53bf5166bec3b0 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/graph/MetricGraphIdDefine.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/graph/MetricGraphIdDefine.java @@ -32,7 +32,7 @@ public class MetricGraphIdDefine { public static final int APPLICATION_COMPONENT_GRAPH_ID = 406; public static final int APPLICATION_MAPPING_GRAPH_ID = 407; - public static final int SERVICE_MAPPING_GRAPH_ID = 408; + public static final int RESPONSE_TIME_DISTRIBUTION_GRAPH_ID = 408; public static final int GLOBAL_TRACE_GRAPH_ID = 409; public static final int SEGMENT_DURATION_GRAPH_ID = 410; public static final int INSTANCE_MAPPING_GRAPH_ID = 411; diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/graph/MetricWorkerIdDefine.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/graph/MetricWorkerIdDefine.java index 1b78839b019f85a97b9a9aa483fcb6e388036f19..f1b4cf73b6168fa835ed71f501c899315471f683 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/graph/MetricWorkerIdDefine.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/graph/MetricWorkerIdDefine.java @@ -112,6 +112,16 @@ public class MetricWorkerIdDefine { public static final int APPLICATION_COMPONENT_MONTH_PERSISTENCE_WORKER_ID = 4907; public static final int APPLICATION_COMPONENT_MONTH_TRANSFORM_NODE_ID = 4908; + public static final int RESPONSE_TIME_DISTRIBUTION_MINUTE_AGGREGATION_WORKER_ID = 4040; + public static final int RESPONSE_TIME_DISTRIBUTION_MINUTE_REMOTE_WORKER_ID = 4041; + public static final int RESPONSE_TIME_DISTRIBUTION_MINUTE_PERSISTENCE_WORKER_ID = 4042; + public static final int RESPONSE_TIME_DISTRIBUTION_HOUR_PERSISTENCE_WORKER_ID = 4043; + public static final int RESPONSE_TIME_DISTRIBUTION_HOUR_TRANSFORM_NODE_ID = 4044; + public static final int RESPONSE_TIME_DISTRIBUTION_DAY_PERSISTENCE_WORKER_ID = 4045; + public static final int RESPONSE_TIME_DISTRIBUTION_DAY_TRANSFORM_NODE_ID = 4046; + public static final int RESPONSE_TIME_DISTRIBUTION_MONTH_PERSISTENCE_WORKER_ID = 4047; + public static final int RESPONSE_TIME_DISTRIBUTION_MONTH_TRANSFORM_NODE_ID = 4048; + public static final int GLOBAL_TRACE_PERSISTENCE_WORKER_ID = 427; public static final int SEGMENT_DURATION_PERSISTENCE_WORKER_ID = 428; diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/AnalysisMetricModuleProvider.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/AnalysisMetricModuleProvider.java index ce5fa2e503bfa1581a23fe8245243bc4ed6fd1c2..8e33cd3c5d348f19a760d3ba34dea089cd030b58 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/AnalysisMetricModuleProvider.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/AnalysisMetricModuleProvider.java @@ -29,6 +29,8 @@ import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.appli import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.application.refmetric.ApplicationReferenceMetricGraph; import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.global.GlobalTraceGraph; import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.global.GlobalTraceSpanListener; +import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.global.std.ResponseTimeDistributionGraph; +import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.global.std.ResponseTimeDistributionSpanListener; import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.heartbeat.InstanceHeartBeatPersistenceGraph; import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.mapping.InstanceMappingGraph; import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.mapping.InstanceMappingSpanListener; @@ -56,6 +58,7 @@ import org.apache.skywalking.apm.collector.storage.table.application.Application import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMapping; import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMetric; import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetric; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistribution; import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMapping; import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetric; import org.apache.skywalking.apm.collector.storage.table.instance.InstanceReferenceMetric; @@ -118,6 +121,7 @@ public class AnalysisMetricModuleProvider extends ModuleProvider { segmentParserListenerRegister.register(new InstanceMappingSpanListener.Factory()); segmentParserListenerRegister.register(new GlobalTraceSpanListener.Factory()); segmentParserListenerRegister.register(new SegmentDurationSpanListener.Factory()); + segmentParserListenerRegister.register(new ResponseTimeDistributionSpanListener.Factory()); } private void graphCreate(WorkerCreateListener workerCreateListener) { @@ -151,6 +155,9 @@ public class AnalysisMetricModuleProvider extends ModuleProvider { GlobalTraceGraph globalTraceGraph = new GlobalTraceGraph(getManager(), workerCreateListener); globalTraceGraph.create(); + ResponseTimeDistributionGraph responseTimeDistributionGraph = new ResponseTimeDistributionGraph(getManager(), workerCreateListener); + responseTimeDistributionGraph.create(); + SegmentDurationGraph segmentDurationGraph = new SegmentDurationGraph(getManager(), workerCreateListener); segmentDurationGraph.create(); @@ -169,5 +176,6 @@ public class AnalysisMetricModuleProvider extends ModuleProvider { remoteDataRegisterService.register(InstanceReferenceMetric.class, new InstanceReferenceMetric.InstanceCreator()); remoteDataRegisterService.register(ServiceMetric.class, new ServiceMetric.InstanceCreator()); remoteDataRegisterService.register(ServiceReferenceMetric.class, new ServiceReferenceMetric.InstanceCreator()); + remoteDataRegisterService.register(ResponseTimeDistribution.class, new ResponseTimeDistribution.InstanceCreator()); } } diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/std/ResponseTimeDistributionCopy.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/std/ResponseTimeDistributionCopy.java new file mode 100644 index 0000000000000000000000000000000000000000..ad0b4091b06c70fd5a55999ae7cf8270d5362fc0 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/std/ResponseTimeDistributionCopy.java @@ -0,0 +1,40 @@ +/* + * 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.apm.collector.analysis.metric.provider.worker.global.std; + +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistribution; + +/** + * @author peng-yongsheng + */ +public class ResponseTimeDistributionCopy { + + public static ResponseTimeDistribution copy(ResponseTimeDistribution responseTimeDistribution) { + ResponseTimeDistribution newResponseTimeDistribution = new ResponseTimeDistribution(); + newResponseTimeDistribution.setId(responseTimeDistribution.getId()); + newResponseTimeDistribution.setMetricId(responseTimeDistribution.getMetricId()); + newResponseTimeDistribution.setTimeBucket(responseTimeDistribution.getTimeBucket()); + + newResponseTimeDistribution.setStep(responseTimeDistribution.getStep()); + newResponseTimeDistribution.setCalls(responseTimeDistribution.getCalls()); + newResponseTimeDistribution.setSuccessCalls(responseTimeDistribution.getSuccessCalls()); + newResponseTimeDistribution.setErrorCalls(responseTimeDistribution.getErrorCalls()); + return newResponseTimeDistribution; + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/std/ResponseTimeDistributionDayPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/std/ResponseTimeDistributionDayPersistenceWorker.java new file mode 100644 index 0000000000000000000000000000000000000000..7970e9d8b7561a64a44002a6505ae77ab8fb7a2f --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/std/ResponseTimeDistributionDayPersistenceWorker.java @@ -0,0 +1,74 @@ +/* + * 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.apm.collector.analysis.metric.provider.worker.global.std; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorker; +import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorkerProvider; +import org.apache.skywalking.apm.collector.core.annotations.trace.GraphComputingMetric; +import org.apache.skywalking.apm.collector.core.module.ModuleManager; +import org.apache.skywalking.apm.collector.storage.StorageModule; +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.rtd.IResponseTimeDistributionDayPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistribution; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistributionTable; + +/** + * @author peng-yongsheng + */ +public class ResponseTimeDistributionDayPersistenceWorker extends PersistenceWorker { + + private ResponseTimeDistributionDayPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return MetricWorkerIdDefine.RESPONSE_TIME_DISTRIBUTION_DAY_PERSISTENCE_WORKER_ID; + } + + @Override protected boolean needMergeDBData() { + return true; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IResponseTimeDistributionDayPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public ResponseTimeDistributionDayPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new ResponseTimeDistributionDayPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } + + @GraphComputingMetric(name = "/persistence/onWork/" + ResponseTimeDistributionTable.TABLE + "/day") + @Override protected void onWork(ResponseTimeDistribution input) { + super.onWork(input); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/std/ResponseTimeDistributionDayTransformNode.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/std/ResponseTimeDistributionDayTransformNode.java new file mode 100644 index 0000000000000000000000000000000000000000..4eec989380330e412ec07e074300879fc6846602 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/std/ResponseTimeDistributionDayTransformNode.java @@ -0,0 +1,46 @@ +/* + * 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.apm.collector.analysis.metric.provider.worker.global.std; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +import org.apache.skywalking.apm.collector.core.graph.Next; +import org.apache.skywalking.apm.collector.core.graph.NodeProcessor; +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.global.ResponseTimeDistribution; + +/** + * @author peng-yongsheng + */ +public class ResponseTimeDistributionDayTransformNode implements NodeProcessor { + + @Override public int id() { + return MetricWorkerIdDefine.RESPONSE_TIME_DISTRIBUTION_DAY_TRANSFORM_NODE_ID; + } + + @Override + public void process(ResponseTimeDistribution responseTimeDistribution, Next next) { + long timeBucket = TimeBucketUtils.INSTANCE.minuteToDay(responseTimeDistribution.getTimeBucket()); + + ResponseTimeDistribution newResponseTimeDistribution = ResponseTimeDistributionCopy.copy(responseTimeDistribution); + newResponseTimeDistribution.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + responseTimeDistribution.getMetricId()); + newResponseTimeDistribution.setTimeBucket(timeBucket); + next.execute(newResponseTimeDistribution); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/std/ResponseTimeDistributionGraph.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/std/ResponseTimeDistributionGraph.java new file mode 100644 index 0000000000000000000000000000000000000000..f670bcbeca292dc365dc1677c4e26d34c5d8463d --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/std/ResponseTimeDistributionGraph.java @@ -0,0 +1,61 @@ +/* + * 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.apm.collector.analysis.metric.provider.worker.global.std; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricGraphIdDefine; +import org.apache.skywalking.apm.collector.analysis.worker.model.base.WorkerCreateListener; +import org.apache.skywalking.apm.collector.core.graph.GraphManager; +import org.apache.skywalking.apm.collector.core.graph.Node; +import org.apache.skywalking.apm.collector.core.module.ModuleManager; +import org.apache.skywalking.apm.collector.remote.RemoteModule; +import org.apache.skywalking.apm.collector.remote.service.RemoteSenderService; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistribution; + +/** + * @author peng-yongsheng + */ +public class ResponseTimeDistributionGraph { + + private final ModuleManager moduleManager; + private final WorkerCreateListener workerCreateListener; + + public ResponseTimeDistributionGraph(ModuleManager moduleManager, WorkerCreateListener workerCreateListener) { + this.moduleManager = moduleManager; + this.workerCreateListener = workerCreateListener; + } + + public void create() { + RemoteSenderService remoteSenderService = moduleManager.find(RemoteModule.NAME).getService(RemoteSenderService.class); + + Node remoteNode = GraphManager.INSTANCE.createIfAbsent(MetricGraphIdDefine.RESPONSE_TIME_DISTRIBUTION_GRAPH_ID, ResponseTimeDistribution.class) + .addNode(new ResponseTimeDistributionMinuteAggregationWorker.Factory(moduleManager).create(workerCreateListener)) + .addNext(new ResponseTimeDistributionMinuteRemoteWorker.Factory(moduleManager, remoteSenderService, MetricGraphIdDefine.RESPONSE_TIME_DISTRIBUTION_GRAPH_ID).create(workerCreateListener)); + + remoteNode.addNext(new ResponseTimeDistributionMinutePersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + remoteNode.addNext(new ResponseTimeDistributionHourTransformNode()) + .addNext(new ResponseTimeDistributionHourPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + remoteNode.addNext(new ResponseTimeDistributionDayTransformNode()) + .addNext(new ResponseTimeDistributionDayPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + + remoteNode.addNext(new ResponseTimeDistributionMonthTransformNode()) + .addNext(new ResponseTimeDistributionMonthPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/std/ResponseTimeDistributionHourPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/std/ResponseTimeDistributionHourPersistenceWorker.java new file mode 100644 index 0000000000000000000000000000000000000000..b5662fc91b1640fa666fa4bc2ce12c1cc2e69a48 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/std/ResponseTimeDistributionHourPersistenceWorker.java @@ -0,0 +1,74 @@ +/* + * 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.apm.collector.analysis.metric.provider.worker.global.std; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorker; +import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorkerProvider; +import org.apache.skywalking.apm.collector.core.annotations.trace.GraphComputingMetric; +import org.apache.skywalking.apm.collector.core.module.ModuleManager; +import org.apache.skywalking.apm.collector.storage.StorageModule; +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.rtd.IResponseTimeDistributionHourPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistribution; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistributionTable; + +/** + * @author peng-yongsheng + */ +public class ResponseTimeDistributionHourPersistenceWorker extends PersistenceWorker { + + private ResponseTimeDistributionHourPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return MetricWorkerIdDefine.RESPONSE_TIME_DISTRIBUTION_HOUR_PERSISTENCE_WORKER_ID; + } + + @Override protected boolean needMergeDBData() { + return true; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IResponseTimeDistributionHourPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public ResponseTimeDistributionHourPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new ResponseTimeDistributionHourPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } + + @GraphComputingMetric(name = "/persistence/onWork/" + ResponseTimeDistributionTable.TABLE + "/hour") + @Override protected void onWork(ResponseTimeDistribution input) { + super.onWork(input); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/std/ResponseTimeDistributionHourTransformNode.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/std/ResponseTimeDistributionHourTransformNode.java new file mode 100644 index 0000000000000000000000000000000000000000..03948296b2eb814d5af5b153ede4a8a55c85e705 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/std/ResponseTimeDistributionHourTransformNode.java @@ -0,0 +1,46 @@ +/* + * 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.apm.collector.analysis.metric.provider.worker.global.std; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +import org.apache.skywalking.apm.collector.core.graph.Next; +import org.apache.skywalking.apm.collector.core.graph.NodeProcessor; +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.global.ResponseTimeDistribution; + +/** + * @author peng-yongsheng + */ +public class ResponseTimeDistributionHourTransformNode implements NodeProcessor { + + @Override public int id() { + return MetricWorkerIdDefine.RESPONSE_TIME_DISTRIBUTION_HOUR_TRANSFORM_NODE_ID; + } + + @Override + public void process(ResponseTimeDistribution responseTimeDistribution, Next next) { + long timeBucket = TimeBucketUtils.INSTANCE.minuteToHour(responseTimeDistribution.getTimeBucket()); + + ResponseTimeDistribution newResponseTimeDistribution = ResponseTimeDistributionCopy.copy(responseTimeDistribution); + newResponseTimeDistribution.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + responseTimeDistribution.getMetricId()); + newResponseTimeDistribution.setTimeBucket(timeBucket); + next.execute(newResponseTimeDistribution); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/std/ResponseTimeDistributionMinuteAggregationWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/std/ResponseTimeDistributionMinuteAggregationWorker.java new file mode 100644 index 0000000000000000000000000000000000000000..df1601a6de34779604de3be534faa5009c1b657d --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/std/ResponseTimeDistributionMinuteAggregationWorker.java @@ -0,0 +1,63 @@ +/* + * 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.apm.collector.analysis.metric.provider.worker.global.std; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractLocalAsyncWorkerProvider; +import org.apache.skywalking.apm.collector.analysis.worker.model.base.WorkerException; +import org.apache.skywalking.apm.collector.analysis.worker.model.impl.AggregationWorker; +import org.apache.skywalking.apm.collector.core.annotations.trace.GraphComputingMetric; +import org.apache.skywalking.apm.collector.core.module.ModuleManager; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistribution; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistributionTable; + +/** + * @author peng-yongsheng + */ +public class ResponseTimeDistributionMinuteAggregationWorker extends AggregationWorker { + + private ResponseTimeDistributionMinuteAggregationWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return MetricWorkerIdDefine.RESPONSE_TIME_DISTRIBUTION_MINUTE_AGGREGATION_WORKER_ID; + } + + public static class Factory extends AbstractLocalAsyncWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public ResponseTimeDistributionMinuteAggregationWorker workerInstance(ModuleManager moduleManager) { + return new ResponseTimeDistributionMinuteAggregationWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } + + @GraphComputingMetric(name = "/aggregation/onWork/" + ResponseTimeDistributionTable.TABLE) + @Override protected void onWork(ResponseTimeDistribution message) throws WorkerException { + super.onWork(message); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/std/ResponseTimeDistributionMinutePersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/std/ResponseTimeDistributionMinutePersistenceWorker.java new file mode 100644 index 0000000000000000000000000000000000000000..d5a5150b5741afef2bbec58d15a4ed670e6faf04 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/std/ResponseTimeDistributionMinutePersistenceWorker.java @@ -0,0 +1,74 @@ +/* + * 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.apm.collector.analysis.metric.provider.worker.global.std; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorker; +import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorkerProvider; +import org.apache.skywalking.apm.collector.core.annotations.trace.GraphComputingMetric; +import org.apache.skywalking.apm.collector.core.module.ModuleManager; +import org.apache.skywalking.apm.collector.storage.StorageModule; +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.rtd.IResponseTimeDistributionMinutePersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistribution; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistributionTable; + +/** + * @author peng-yongsheng + */ +public class ResponseTimeDistributionMinutePersistenceWorker extends PersistenceWorker { + + private ResponseTimeDistributionMinutePersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return MetricWorkerIdDefine.RESPONSE_TIME_DISTRIBUTION_MINUTE_PERSISTENCE_WORKER_ID; + } + + @Override protected boolean needMergeDBData() { + return true; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IResponseTimeDistributionMinutePersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public ResponseTimeDistributionMinutePersistenceWorker workerInstance(ModuleManager moduleManager) { + return new ResponseTimeDistributionMinutePersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } + + @GraphComputingMetric(name = "/persistence/onWork/" + ResponseTimeDistributionTable.TABLE + "/minute") + @Override protected void onWork(ResponseTimeDistribution input) { + super.onWork(input); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/std/ResponseTimeDistributionMinuteRemoteWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/std/ResponseTimeDistributionMinuteRemoteWorker.java new file mode 100644 index 0000000000000000000000000000000000000000..49a83de838471a6535845ede86059f961be81116 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/std/ResponseTimeDistributionMinuteRemoteWorker.java @@ -0,0 +1,59 @@ +/* + * 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.apm.collector.analysis.metric.provider.worker.global.std; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractRemoteWorker; +import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractRemoteWorkerProvider; +import org.apache.skywalking.apm.collector.core.module.ModuleManager; +import org.apache.skywalking.apm.collector.remote.service.RemoteSenderService; +import org.apache.skywalking.apm.collector.remote.service.Selector; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistribution; + +/** + * @author peng-yongsheng + */ +public class ResponseTimeDistributionMinuteRemoteWorker extends AbstractRemoteWorker { + + private ResponseTimeDistributionMinuteRemoteWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return MetricWorkerIdDefine.RESPONSE_TIME_DISTRIBUTION_MINUTE_REMOTE_WORKER_ID; + } + + @Override protected void onWork(ResponseTimeDistribution responseTimeDistribution) { + onNext(responseTimeDistribution); + } + + @Override public Selector selector() { + return Selector.HashCode; + } + + public static class Factory extends AbstractRemoteWorkerProvider { + public Factory(ModuleManager moduleManager, RemoteSenderService remoteSenderService, int graphId) { + super(moduleManager, remoteSenderService, graphId); + } + + @Override public ResponseTimeDistributionMinuteRemoteWorker workerInstance(ModuleManager moduleManager) { + return new ResponseTimeDistributionMinuteRemoteWorker(moduleManager); + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/std/ResponseTimeDistributionMonthPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/std/ResponseTimeDistributionMonthPersistenceWorker.java new file mode 100644 index 0000000000000000000000000000000000000000..5624ab7c5cbee47f23d2b786cd543fedf6d227ab --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/std/ResponseTimeDistributionMonthPersistenceWorker.java @@ -0,0 +1,74 @@ +/* + * 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.apm.collector.analysis.metric.provider.worker.global.std; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorker; +import org.apache.skywalking.apm.collector.analysis.worker.model.impl.PersistenceWorkerProvider; +import org.apache.skywalking.apm.collector.core.annotations.trace.GraphComputingMetric; +import org.apache.skywalking.apm.collector.core.module.ModuleManager; +import org.apache.skywalking.apm.collector.storage.StorageModule; +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.rtd.IResponseTimeDistributionMonthPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistribution; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistributionTable; + +/** + * @author peng-yongsheng + */ +public class ResponseTimeDistributionMonthPersistenceWorker extends PersistenceWorker { + + private ResponseTimeDistributionMonthPersistenceWorker(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public int id() { + return MetricWorkerIdDefine.RESPONSE_TIME_DISTRIBUTION_MONTH_PERSISTENCE_WORKER_ID; + } + + @Override protected boolean needMergeDBData() { + return true; + } + + @SuppressWarnings("unchecked") + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(IResponseTimeDistributionMonthPersistenceDAO.class); + } + + public static class Factory extends PersistenceWorkerProvider { + + public Factory(ModuleManager moduleManager) { + super(moduleManager); + } + + @Override public ResponseTimeDistributionMonthPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new ResponseTimeDistributionMonthPersistenceWorker(moduleManager); + } + + @Override + public int queueSize() { + return 1024; + } + } + + @GraphComputingMetric(name = "/persistence/onWork/" + ResponseTimeDistributionTable.TABLE + "/month") + @Override protected void onWork(ResponseTimeDistribution input) { + super.onWork(input); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/std/ResponseTimeDistributionMonthTransformNode.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/std/ResponseTimeDistributionMonthTransformNode.java new file mode 100644 index 0000000000000000000000000000000000000000..13f2f738c68c1c450b6ceea5a118235a43779256 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/std/ResponseTimeDistributionMonthTransformNode.java @@ -0,0 +1,46 @@ +/* + * 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.apm.collector.analysis.metric.provider.worker.global.std; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricWorkerIdDefine; +import org.apache.skywalking.apm.collector.core.graph.Next; +import org.apache.skywalking.apm.collector.core.graph.NodeProcessor; +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.global.ResponseTimeDistribution; + +/** + * @author peng-yongsheng + */ +public class ResponseTimeDistributionMonthTransformNode implements NodeProcessor { + + @Override public int id() { + return MetricWorkerIdDefine.RESPONSE_TIME_DISTRIBUTION_MONTH_TRANSFORM_NODE_ID; + } + + @Override + public void process(ResponseTimeDistribution responseTimeDistribution, Next next) { + long timeBucket = TimeBucketUtils.INSTANCE.minuteToMonth(responseTimeDistribution.getTimeBucket()); + + ResponseTimeDistribution newResponseTimeDistribution = ResponseTimeDistributionCopy.copy(responseTimeDistribution); + newResponseTimeDistribution.setId(String.valueOf(timeBucket) + Const.ID_SPLIT + responseTimeDistribution.getMetricId()); + newResponseTimeDistribution.setTimeBucket(timeBucket); + next.execute(newResponseTimeDistribution); + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/std/ResponseTimeDistributionSpanListener.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/std/ResponseTimeDistributionSpanListener.java new file mode 100644 index 0000000000000000000000000000000000000000..e923bc57ada99afb2bc66bef90fdd271f32d7e13 --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/std/ResponseTimeDistributionSpanListener.java @@ -0,0 +1,130 @@ +/* + * 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.apm.collector.analysis.metric.provider.worker.global.std; + +import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricGraphIdDefine; +import org.apache.skywalking.apm.collector.analysis.segment.parser.define.decorator.SpanDecorator; +import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.EntrySpanListener; +import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.ExitSpanListener; +import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.FirstSpanListener; +import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.LocalSpanListener; +import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.SpanListener; +import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.SpanListenerFactory; +import org.apache.skywalking.apm.collector.core.annotations.trace.GraphComputingMetric; +import org.apache.skywalking.apm.collector.core.graph.Graph; +import org.apache.skywalking.apm.collector.core.graph.GraphManager; +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.global.ResponseTimeDistribution; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class ResponseTimeDistributionSpanListener implements FirstSpanListener, EntrySpanListener, ExitSpanListener, LocalSpanListener { + + private static final Logger logger = LoggerFactory.getLogger(ResponseTimeDistributionSpanListener.class); + + private long timeBucket; + private boolean isError = false; + private int entrySpanDuration = 0; + private int firstSpanDuration = 0; + + @Override public boolean containsPoint(Point point) { + return Point.First.equals(point) || Point.Entry.equals(point) || Point.Exit.equals(point) || Point.Local.equals(point); + } + + @Override public void parseEntry(SpanDecorator spanDecorator, int applicationId, int instanceId, String segmentId) { + isError = isError || spanDecorator.getIsError(); + entrySpanDuration = (int)(spanDecorator.getEndTime() - spanDecorator.getStartTime()); + } + + @Override + public void parseFirst(SpanDecorator spanDecorator, int applicationId, int instanceId, + String segmentId) { + isError = isError || spanDecorator.getIsError(); + + if (spanDecorator.getStartTimeMinuteTimeBucket() == 0) { + long startTimeMinuteTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(spanDecorator.getStartTime()); + spanDecorator.setStartTimeMinuteTimeBucket(startTimeMinuteTimeBucket); + } + timeBucket = spanDecorator.getStartTimeMinuteTimeBucket(); + + firstSpanDuration = (int)(spanDecorator.getEndTime() - spanDecorator.getStartTime()); + } + + @Override public void parseExit(SpanDecorator spanDecorator, int applicationId, int instanceId, String segmentId) { + isError = isError || spanDecorator.getIsError(); + } + + @Override public void parseLocal(SpanDecorator spanDecorator, int applicationId, int instanceId, String segmentId) { + isError = isError || spanDecorator.getIsError(); + } + + @Override public void build() { + int step = getStep(); + + ResponseTimeDistribution distribution = new ResponseTimeDistribution(); + distribution.setMetricId(String.valueOf(step)); + distribution.setId(timeBucket + Const.ID_SPLIT + distribution.getMetricId()); + distribution.setStep(step); + distribution.setCalls(1); + distribution.setTimeBucket(timeBucket); + + if (isError) { + distribution.setErrorCalls(1); + } else { + distribution.setSuccessCalls(1); + } + + Graph graph = GraphManager.INSTANCE.findGraph(MetricGraphIdDefine.RESPONSE_TIME_DISTRIBUTION_GRAPH_ID, ResponseTimeDistribution.class); + graph.start(distribution); + logger.debug("push to response time distribution aggregation worker, id: {}", distribution.getId()); + } + + int getStep() { + int abovePoint = 3000; + int interval = 50; + + int duration; + if (entrySpanDuration == 0) { + duration = firstSpanDuration; + } else { + duration = entrySpanDuration; + } + + if (duration > abovePoint) { + return abovePoint / interval; + } else if (duration <= interval) { + return 0; + } else { + return (int)Math.ceil((double)duration / (double)interval) - 1; + } + } + + public static class Factory implements SpanListenerFactory { + + @GraphComputingMetric(name = "/segment/parse/createSpanListeners/responseTimeDistributionSpanListener") + @Override public SpanListener create(ModuleManager moduleManager) { + return new ResponseTimeDistributionSpanListener(); + } + } +} diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/test/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/std/ResponseTimeDistributionSpanListenerTestCase.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/test/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/std/ResponseTimeDistributionSpanListenerTestCase.java new file mode 100644 index 0000000000000000000000000000000000000000..b67a9c34ad56e327133c0e85dbd9a29cf2136c2a --- /dev/null +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/test/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/global/std/ResponseTimeDistributionSpanListenerTestCase.java @@ -0,0 +1,47 @@ +/* + * 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.apm.collector.analysis.metric.provider.worker.global.std; + +import org.junit.Assert; +import org.junit.Test; +import org.powermock.reflect.Whitebox; + +/** + * @author peng-yongsheng + */ +public class ResponseTimeDistributionSpanListenerTestCase { + + @Test + public void testStep() { + ResponseTimeDistributionSpanListener listener = new ResponseTimeDistributionSpanListener(); + + Whitebox.setInternalState(listener, "entrySpanDuration", 0); + Whitebox.setInternalState(listener, "firstSpanDuration", 200); + Assert.assertEquals(3, listener.getStep()); + + Whitebox.setInternalState(listener, "entrySpanDuration", 10); + Assert.assertEquals(0, listener.getStep()); + + Whitebox.setInternalState(listener, "entrySpanDuration", 60); + Assert.assertEquals(1, listener.getStep()); + + Whitebox.setInternalState(listener, "entrySpanDuration", 3100); + Assert.assertEquals(60, listener.getStep()); + } +} diff --git a/apm-collector/apm-collector-component/client-component/src/main/java/org/apache/skywalking/apm/collector/client/NameSpace.java b/apm-collector/apm-collector-component/client-component/src/main/java/org/apache/skywalking/apm/collector/client/NameSpace.java new file mode 100644 index 0000000000000000000000000000000000000000..653af5e02c87b3804613f3f970dc82968b99dee5 --- /dev/null +++ b/apm-collector/apm-collector-component/client-component/src/main/java/org/apache/skywalking/apm/collector/client/NameSpace.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.apm.collector.client; + +import org.apache.skywalking.apm.collector.core.util.Const; + +/** + * @author peng-yongsheng + */ +public class NameSpace { + + private String nameSpace = Const.EMPTY_STRING; + + public String getNameSpace() { + return nameSpace; + } + + public void setNameSpace(String nameSpace) { + this.nameSpace = nameSpace; + } +} diff --git a/apm-collector/apm-collector-component/client-component/src/main/java/org/apache/skywalking/apm/collector/client/elasticsearch/ElasticSearchClient.java b/apm-collector/apm-collector-component/client-component/src/main/java/org/apache/skywalking/apm/collector/client/elasticsearch/ElasticSearchClient.java index 91bc98117be8c5c715a06568bb1464265078d00a..8499a14c9620dc13201e3c629923576da207ff05 100644 --- a/apm-collector/apm-collector-component/client-component/src/main/java/org/apache/skywalking/apm/collector/client/elasticsearch/ElasticSearchClient.java +++ b/apm-collector/apm-collector-component/client-component/src/main/java/org/apache/skywalking/apm/collector/client/elasticsearch/ElasticSearchClient.java @@ -25,6 +25,7 @@ import java.util.List; import java.util.function.Consumer; import org.apache.skywalking.apm.collector.client.Client; import org.apache.skywalking.apm.collector.client.ClientException; +import org.apache.skywalking.apm.collector.client.NameSpace; import org.apache.skywalking.apm.collector.core.data.CommonTable; import org.apache.skywalking.apm.collector.core.util.Const; import org.apache.skywalking.apm.collector.core.util.StringUtils; @@ -65,18 +66,18 @@ public class ElasticSearchClient implements Client { private final String clusterNodes; - private final String namespace; + private final NameSpace namespace; public ElasticSearchClient(String clusterName, boolean clusterTransportSniffer, String clusterNodes) { this.clusterName = clusterName; this.clusterTransportSniffer = clusterTransportSniffer; this.clusterNodes = clusterNodes; - this.namespace = Const.EMPTY_STRING; + this.namespace = new NameSpace(); } public ElasticSearchClient(String clusterName, boolean clusterTransportSniffer, - String clusterNodes, String namespace) { + String clusterNodes, NameSpace namespace) { this.clusterName = clusterName; this.clusterTransportSniffer = clusterTransportSniffer; this.clusterNodes = clusterNodes; @@ -187,7 +188,7 @@ public class ElasticSearchClient implements Client { public MultiGetRequestBuilder prepareMultiGet(List rows, MultiGetRowHandler rowHandler) { MultiGetRequestBuilder prepareMultiGet = client.prepareMultiGet(); rowHandler.setPrepareMultiGet(prepareMultiGet); - rowHandler.setNamespace(namespace); + rowHandler.setNamespace(namespace.getNameSpace()); rows.forEach(rowHandler::accept); @@ -221,7 +222,7 @@ public class ElasticSearchClient implements Client { } private String formatIndexName(String indexName) { - return formatIndexName(this.namespace, indexName); + return formatIndexName(this.namespace.getNameSpace(), indexName); } private static String formatIndexName(String namespace, String indexName) { diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/StorageModule.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/StorageModule.java index 0b7b3efb4f6a987f65c53b672b998051b7abec1c..2197a81ae83cf422edd07025c66922736115d7b9 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/StorageModule.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/StorageModule.java @@ -97,6 +97,10 @@ import org.apache.skywalking.apm.collector.storage.dao.register.IApplicationRegi import org.apache.skywalking.apm.collector.storage.dao.register.IInstanceRegisterDAO; import org.apache.skywalking.apm.collector.storage.dao.register.INetworkAddressRegisterDAO; import org.apache.skywalking.apm.collector.storage.dao.register.IServiceNameRegisterDAO; +import org.apache.skywalking.apm.collector.storage.dao.rtd.IResponseTimeDistributionDayPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.rtd.IResponseTimeDistributionHourPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.rtd.IResponseTimeDistributionMinutePersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.rtd.IResponseTimeDistributionMonthPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.smp.IServiceDayMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.smp.IServiceHourMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.smp.IServiceMinuteMetricPersistenceDAO; @@ -209,6 +213,11 @@ public class StorageModule extends Module { classes.add(ISegmentPersistenceDAO.class); classes.add(IInstanceHeartBeatPersistenceDAO.class); + classes.add(IResponseTimeDistributionMinutePersistenceDAO.class); + classes.add(IResponseTimeDistributionHourPersistenceDAO.class); + classes.add(IResponseTimeDistributionDayPersistenceDAO.class); + classes.add(IResponseTimeDistributionMonthPersistenceDAO.class); + classes.add(IApplicationMinuteMetricPersistenceDAO.class); classes.add(IApplicationHourMetricPersistenceDAO.class); classes.add(IApplicationDayMetricPersistenceDAO.class); diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/rtd/IResponseTimeDistributionDayPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/rtd/IResponseTimeDistributionDayPersistenceDAO.java new file mode 100644 index 0000000000000000000000000000000000000000..5d70aafc99183a6e98fdd5b2d4af3ade69adc63f --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/rtd/IResponseTimeDistributionDayPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.apm.collector.storage.dao.rtd; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistribution; + +/** + * @author peng-yongsheng + */ +public interface IResponseTimeDistributionDayPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/rtd/IResponseTimeDistributionHourPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/rtd/IResponseTimeDistributionHourPersistenceDAO.java new file mode 100644 index 0000000000000000000000000000000000000000..ff6649899ea4ef5ea3e7c452b539c4bd718de3b8 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/rtd/IResponseTimeDistributionHourPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.apm.collector.storage.dao.rtd; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistribution; + +/** + * @author peng-yongsheng + */ +public interface IResponseTimeDistributionHourPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/rtd/IResponseTimeDistributionMinutePersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/rtd/IResponseTimeDistributionMinutePersistenceDAO.java new file mode 100644 index 0000000000000000000000000000000000000000..bcae6b8c555f58a5fdfdd98c95ffa188ce7abd3e --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/rtd/IResponseTimeDistributionMinutePersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.apm.collector.storage.dao.rtd; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistribution; + +/** + * @author peng-yongsheng + */ +public interface IResponseTimeDistributionMinutePersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/rtd/IResponseTimeDistributionMonthPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/rtd/IResponseTimeDistributionMonthPersistenceDAO.java new file mode 100644 index 0000000000000000000000000000000000000000..13725b40b97b4a93e61f4f0aaea3758a19aa1327 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/rtd/IResponseTimeDistributionMonthPersistenceDAO.java @@ -0,0 +1,28 @@ +/* + * 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.apm.collector.storage.dao.rtd; + +import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistribution; + +/** + * @author peng-yongsheng + */ +public interface IResponseTimeDistributionMonthPersistenceDAO extends IPersistenceDAO { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/global/ResponseTimeDistribution.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/global/ResponseTimeDistribution.java new file mode 100644 index 0000000000000000000000000000000000000000..c4e8e6d974cd0169f551aebc1790d2ab56f1eea5 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/global/ResponseTimeDistribution.java @@ -0,0 +1,119 @@ +/* + * 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.apm.collector.storage.table.global; + +import org.apache.skywalking.apm.collector.core.data.Column; +import org.apache.skywalking.apm.collector.core.data.RemoteData; +import org.apache.skywalking.apm.collector.core.data.StreamData; +import org.apache.skywalking.apm.collector.core.data.operator.AddMergeOperation; +import org.apache.skywalking.apm.collector.core.data.operator.CoverMergeOperation; +import org.apache.skywalking.apm.collector.core.data.operator.NonMergeOperation; +import org.apache.skywalking.apm.collector.remote.service.RemoteDataRegisterService; + +/** + * @author peng-yongsheng + */ +public class ResponseTimeDistribution extends StreamData { + + private static final Column[] STRING_COLUMNS = { + new Column(ResponseTimeDistributionTable.ID, new NonMergeOperation()), + new Column(ResponseTimeDistributionTable.METRIC_ID, new NonMergeOperation()), + }; + + private static final Column[] LONG_COLUMNS = { + new Column(ResponseTimeDistributionTable.TIME_BUCKET, new CoverMergeOperation()), + new Column(ResponseTimeDistributionTable.CALLS, new AddMergeOperation()), + new Column(ResponseTimeDistributionTable.ERROR_CALLS, new AddMergeOperation()), + new Column(ResponseTimeDistributionTable.SUCCESS_CALLS, new AddMergeOperation()), + }; + + private static final Column[] DOUBLE_COLUMNS = {}; + + private static final Column[] INTEGER_COLUMNS = { + new Column(ResponseTimeDistributionTable.STEP, new NonMergeOperation()), + }; + + private static final Column[] BYTE_COLUMNS = {}; + + public ResponseTimeDistribution() { + super(STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BYTE_COLUMNS); + } + + @Override public String getId() { + return getDataString(0); + } + + @Override public void setId(String id) { + setDataString(0, id); + } + + @Override public String getMetricId() { + return getDataString(1); + } + + @Override public void setMetricId(String metricId) { + setDataString(1, metricId); + } + + public int getStep() { + return getDataInteger(0); + } + + public void setStep(int step) { + setDataInteger(0, step); + } + + public long getTimeBucket() { + return getDataLong(0); + } + + public void setTimeBucket(long timeBucket) { + setDataLong(0, timeBucket); + } + + public long getCalls() { + return getDataLong(1); + } + + public void setCalls(long calls) { + setDataLong(1, calls); + } + + public long getErrorCalls() { + return getDataLong(2); + } + + public void setErrorCalls(long errorCalls) { + setDataLong(2, errorCalls); + } + + public long getSuccessCalls() { + return getDataLong(3); + } + + public void setSuccessCalls(long successCalls) { + setDataLong(3, successCalls); + } + + public static class InstanceCreator implements RemoteDataRegisterService.RemoteDataInstanceCreator { + @Override public RemoteData createInstance() { + return new ResponseTimeDistribution(); + } + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/global/ResponseTimeDistributionTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/global/ResponseTimeDistributionTable.java new file mode 100644 index 0000000000000000000000000000000000000000..ba95eed99d993947ca5e284013df69c8ca283a3e --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/global/ResponseTimeDistributionTable.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.apm.collector.storage.table.global; + +import org.apache.skywalking.apm.collector.core.data.ColumnName; +import org.apache.skywalking.apm.collector.core.data.CommonTable; + +/** + * @author peng-yongsheng + */ +public interface ResponseTimeDistributionTable extends CommonTable { + String TABLE = "response_time_distribution"; + + ColumnName STEP = new ColumnName("step", "s"); + + ColumnName CALLS = new ColumnName("calls", "ac"); + + ColumnName ERROR_CALLS = new ColumnName("error_calls", "ec"); + + ColumnName SUCCESS_CALLS = new ColumnName("success_calls", "sc"); +} \ No newline at end of file diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/StorageModuleEsProvider.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/StorageModuleEsProvider.java index caf11ebb0a63d3bf139a439a0b3395635eee93c6..86cd66f261bb8bd488ffff51cfea463b2222b5e8 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/StorageModuleEsProvider.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/StorageModuleEsProvider.java @@ -20,6 +20,7 @@ package org.apache.skywalking.apm.collector.storage.es; import java.util.UUID; import org.apache.skywalking.apm.collector.client.ClientException; +import org.apache.skywalking.apm.collector.client.NameSpace; import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; import org.apache.skywalking.apm.collector.cluster.ClusterModule; import org.apache.skywalking.apm.collector.cluster.service.ModuleListenerService; @@ -110,6 +111,10 @@ import org.apache.skywalking.apm.collector.storage.dao.register.IApplicationRegi import org.apache.skywalking.apm.collector.storage.dao.register.IInstanceRegisterDAO; import org.apache.skywalking.apm.collector.storage.dao.register.INetworkAddressRegisterDAO; import org.apache.skywalking.apm.collector.storage.dao.register.IServiceNameRegisterDAO; +import org.apache.skywalking.apm.collector.storage.dao.rtd.IResponseTimeDistributionDayPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.rtd.IResponseTimeDistributionHourPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.rtd.IResponseTimeDistributionMinutePersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.rtd.IResponseTimeDistributionMonthPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.smp.IServiceDayMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.smp.IServiceHourMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.smp.IServiceMinuteMetricPersistenceDAO; @@ -215,6 +220,10 @@ import org.apache.skywalking.apm.collector.storage.es.dao.register.ApplicationRe import org.apache.skywalking.apm.collector.storage.es.dao.register.InstanceRegisterEsDAO; import org.apache.skywalking.apm.collector.storage.es.dao.register.NetworkAddressRegisterEsDAO; import org.apache.skywalking.apm.collector.storage.es.dao.register.ServiceNameRegisterEsDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.rtd.ResponseTimeDistributionDayEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.rtd.ResponseTimeDistributionHourEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.rtd.ResponseTimeDistributionMinuteEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.rtd.ResponseTimeDistributionMonthEsPersistenceDAO; import org.apache.skywalking.apm.collector.storage.es.dao.smp.ServiceDayMetricEsPersistenceDAO; import org.apache.skywalking.apm.collector.storage.es.dao.smp.ServiceHourMetricEsPersistenceDAO; import org.apache.skywalking.apm.collector.storage.es.dao.smp.ServiceMinuteMetricEsPersistenceDAO; @@ -251,12 +260,14 @@ public class StorageModuleEsProvider extends ModuleProvider { static final String NAME = "elasticsearch"; private final StorageModuleEsConfig config; + private final NameSpace nameSpace; private ElasticSearchClient elasticSearchClient; private DataTTLKeeperTimer deleteTimer; public StorageModuleEsProvider() { super(); this.config = new StorageModuleEsConfig(); + this.nameSpace = new NameSpace(); } @Override public String name() { @@ -272,6 +283,8 @@ public class StorageModuleEsProvider extends ModuleProvider { } @Override public void prepare() throws ServiceNotProvidedException { + elasticSearchClient = new ElasticSearchClient(config.getClusterName(), config.getClusterTransportSniffer(), config.getClusterNodes(), nameSpace); + this.registerServiceImplementation(IBatchDAO.class, new BatchEsDAO(elasticSearchClient)); registerCacheDAO(); registerRegisterDAO(); @@ -284,7 +297,7 @@ public class StorageModuleEsProvider extends ModuleProvider { public void start() throws ModuleStartException { try { String namespace = getManager().find(ConfigurationModule.NAME).getService(ICollectorConfig.class).getNamespace(); - elasticSearchClient = new ElasticSearchClient(config.getClusterName(), config.getClusterTransportSniffer(), config.getClusterNodes(), namespace); + nameSpace.setNameSpace(namespace); elasticSearchClient.initialize(); ElasticSearchStorageInstaller installer = new ElasticSearchStorageInstaller(config.getIndexShardsNumber(), config.getIndexReplicasNumber(), config.isHighPerformanceMode()); @@ -371,6 +384,11 @@ public class StorageModuleEsProvider extends ModuleProvider { this.registerServiceImplementation(IGlobalTracePersistenceDAO.class, new GlobalTraceEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IResponseTimeDistributionMinutePersistenceDAO.class, new ResponseTimeDistributionMinuteEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IResponseTimeDistributionHourPersistenceDAO.class, new ResponseTimeDistributionHourEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IResponseTimeDistributionDayPersistenceDAO.class, new ResponseTimeDistributionDayEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IResponseTimeDistributionMonthPersistenceDAO.class, new ResponseTimeDistributionMonthEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(IApplicationMinuteMetricPersistenceDAO.class, new ApplicationMinuteMetricEsPersistenceDAO(elasticSearchClient)); this.registerServiceImplementation(IApplicationHourMetricPersistenceDAO.class, new ApplicationHourMetricEsPersistenceDAO(elasticSearchClient)); this.registerServiceImplementation(IApplicationDayMetricPersistenceDAO.class, new ApplicationDayMetricEsPersistenceDAO(elasticSearchClient)); diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/rtd/AbstractResponseTimeDistributionEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/rtd/AbstractResponseTimeDistributionEsPersistenceDAO.java new file mode 100644 index 0000000000000000000000000000000000000000..d6fb4a5c1c9f2cfe55c050f24117954a6424fc85 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/rtd/AbstractResponseTimeDistributionEsPersistenceDAO.java @@ -0,0 +1,75 @@ +/* + * 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.apm.collector.storage.es.dao.rtd; + +import java.util.HashMap; +import java.util.Map; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.annotations.trace.GraphComputingMetric; +import org.apache.skywalking.apm.collector.storage.es.base.dao.AbstractPersistenceEsDAO; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistribution; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistributionTable; + +/** + * @author peng-yongsheng + */ +public abstract class AbstractResponseTimeDistributionEsPersistenceDAO extends AbstractPersistenceEsDAO { + + AbstractResponseTimeDistributionEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected final String timeBucketColumnNameForDelete() { + return ResponseTimeDistributionTable.TIME_BUCKET.getName(); + } + + @Override protected final ResponseTimeDistribution esDataToStreamData(Map source) { + ResponseTimeDistribution responseTimeDistribution = new ResponseTimeDistribution(); + responseTimeDistribution.setMetricId((String)source.get(ResponseTimeDistributionTable.METRIC_ID.getName())); + + responseTimeDistribution.setStep(((Number)source.get(ResponseTimeDistributionTable.STEP.getName())).intValue()); + + responseTimeDistribution.setCalls(((Number)source.get(ResponseTimeDistributionTable.CALLS.getName())).longValue()); + responseTimeDistribution.setErrorCalls(((Number)source.get(ResponseTimeDistributionTable.ERROR_CALLS.getName())).longValue()); + responseTimeDistribution.setSuccessCalls(((Number)source.get(ResponseTimeDistributionTable.SUCCESS_CALLS.getName())).longValue()); + + responseTimeDistribution.setTimeBucket(((Number)source.get(ResponseTimeDistributionTable.TIME_BUCKET.getName())).longValue()); + return responseTimeDistribution; + } + + @Override protected final Map esStreamDataToEsData(ResponseTimeDistribution streamData) { + Map target = new HashMap<>(); + target.put(ResponseTimeDistributionTable.METRIC_ID.getName(), streamData.getMetricId()); + + target.put(ResponseTimeDistributionTable.STEP.getName(), streamData.getStep()); + + target.put(ResponseTimeDistributionTable.CALLS.getName(), streamData.getCalls()); + target.put(ResponseTimeDistributionTable.ERROR_CALLS.getName(), streamData.getErrorCalls()); + target.put(ResponseTimeDistributionTable.SUCCESS_CALLS.getName(), streamData.getSuccessCalls()); + + target.put(ResponseTimeDistributionTable.TIME_BUCKET.getName(), streamData.getTimeBucket()); + + return target; + } + + @GraphComputingMetric(name = "/persistence/get/" + ResponseTimeDistributionTable.TABLE) + @Override public final ResponseTimeDistribution get(String id) { + return super.get(id); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/rtd/ResponseTimeDistributionDayEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/rtd/ResponseTimeDistributionDayEsPersistenceDAO.java new file mode 100644 index 0000000000000000000000000000000000000000..d491b4881b725ee5da6e76912b4f3925b60c4b57 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/rtd/ResponseTimeDistributionDayEsPersistenceDAO.java @@ -0,0 +1,42 @@ +/* + * 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.apm.collector.storage.es.dao.rtd; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.rtd.IResponseTimeDistributionDayPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistribution; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistributionTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class ResponseTimeDistributionDayEsPersistenceDAO extends AbstractResponseTimeDistributionEsPersistenceDAO implements IResponseTimeDistributionDayPersistenceDAO { + + public ResponseTimeDistributionDayEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return ResponseTimeDistributionTable.TABLE + Const.ID_SPLIT + TimePyramid.Day.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/rtd/ResponseTimeDistributionHourEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/rtd/ResponseTimeDistributionHourEsPersistenceDAO.java new file mode 100644 index 0000000000000000000000000000000000000000..6a4d3924a1dde146a3d21178eb4af2a23c1d0e7f --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/rtd/ResponseTimeDistributionHourEsPersistenceDAO.java @@ -0,0 +1,42 @@ +/* + * 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.apm.collector.storage.es.dao.rtd; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.rtd.IResponseTimeDistributionHourPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistribution; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistributionTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class ResponseTimeDistributionHourEsPersistenceDAO extends AbstractResponseTimeDistributionEsPersistenceDAO implements IResponseTimeDistributionHourPersistenceDAO { + + public ResponseTimeDistributionHourEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return ResponseTimeDistributionTable.TABLE + Const.ID_SPLIT + TimePyramid.Hour.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/rtd/ResponseTimeDistributionMinuteEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/rtd/ResponseTimeDistributionMinuteEsPersistenceDAO.java new file mode 100644 index 0000000000000000000000000000000000000000..19f4678d773c2b119533e149f2a3ab63abfdca2f --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/rtd/ResponseTimeDistributionMinuteEsPersistenceDAO.java @@ -0,0 +1,42 @@ +/* + * 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.apm.collector.storage.es.dao.rtd; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.rtd.IResponseTimeDistributionMinutePersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistribution; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistributionTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class ResponseTimeDistributionMinuteEsPersistenceDAO extends AbstractResponseTimeDistributionEsPersistenceDAO implements IResponseTimeDistributionMinutePersistenceDAO { + + public ResponseTimeDistributionMinuteEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return ResponseTimeDistributionTable.TABLE + Const.ID_SPLIT + TimePyramid.Minute.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/rtd/ResponseTimeDistributionMonthEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/rtd/ResponseTimeDistributionMonthEsPersistenceDAO.java new file mode 100644 index 0000000000000000000000000000000000000000..335d6c9690cfaa57b08c2ee5391d62371ab58330 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/rtd/ResponseTimeDistributionMonthEsPersistenceDAO.java @@ -0,0 +1,42 @@ +/* + * 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.apm.collector.storage.es.dao.rtd; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.rtd.IResponseTimeDistributionMonthPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistribution; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistributionTable; +import org.elasticsearch.action.index.IndexRequestBuilder; +import org.elasticsearch.action.update.UpdateRequestBuilder; + +/** + * @author peng-yongsheng + */ +public class ResponseTimeDistributionMonthEsPersistenceDAO extends AbstractResponseTimeDistributionEsPersistenceDAO implements IResponseTimeDistributionMonthPersistenceDAO { + + public ResponseTimeDistributionMonthEsPersistenceDAO(ElasticSearchClient client) { + super(client); + } + + @Override protected String tableName() { + return ResponseTimeDistributionTable.TABLE + Const.ID_SPLIT + TimePyramid.Month.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/rtd/AbstractResponseTimeDistributionEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/rtd/AbstractResponseTimeDistributionEsTableDefine.java new file mode 100644 index 0000000000000000000000000000000000000000..0fb9099c2628a4b35a3dba403d52ec497ce97512 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/rtd/AbstractResponseTimeDistributionEsTableDefine.java @@ -0,0 +1,42 @@ +/* + * 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.apm.collector.storage.es.define.rtd; + +import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchColumnDefine; +import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchTableDefine; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistributionTable; + +/** + * @author peng-yongsheng + */ +public abstract class AbstractResponseTimeDistributionEsTableDefine extends ElasticSearchTableDefine { + + AbstractResponseTimeDistributionEsTableDefine(String name) { + super(name); + } + + @Override public final void initialize() { + addColumn(new ElasticSearchColumnDefine(ResponseTimeDistributionTable.METRIC_ID, ElasticSearchColumnDefine.Type.Keyword.name())); + addColumn(new ElasticSearchColumnDefine(ResponseTimeDistributionTable.STEP, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(ResponseTimeDistributionTable.CALLS, ElasticSearchColumnDefine.Type.Long.name())); + addColumn(new ElasticSearchColumnDefine(ResponseTimeDistributionTable.ERROR_CALLS, ElasticSearchColumnDefine.Type.Long.name())); + addColumn(new ElasticSearchColumnDefine(ResponseTimeDistributionTable.SUCCESS_CALLS, ElasticSearchColumnDefine.Type.Long.name())); + addColumn(new ElasticSearchColumnDefine(ResponseTimeDistributionTable.TIME_BUCKET, ElasticSearchColumnDefine.Type.Long.name())); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/rtd/ResponseTimeDistributionDayEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/rtd/ResponseTimeDistributionDayEsTableDefine.java new file mode 100644 index 0000000000000000000000000000000000000000..bdc6c710dc78cb29987218bcda5dcf87b6670052 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/rtd/ResponseTimeDistributionDayEsTableDefine.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.apm.collector.storage.es.define.rtd; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistributionTable; + +/** + * @author peng-yongsheng + */ +public class ResponseTimeDistributionDayEsTableDefine extends AbstractResponseTimeDistributionEsTableDefine { + + public ResponseTimeDistributionDayEsTableDefine() { + super(ResponseTimeDistributionTable.TABLE + Const.ID_SPLIT + TimePyramid.Day.getName()); + } + + @Override public int refreshInterval() { + return 2; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/rtd/ResponseTimeDistributionHourEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/rtd/ResponseTimeDistributionHourEsTableDefine.java new file mode 100644 index 0000000000000000000000000000000000000000..a85fc6b6b3e82d4d625e34f8109d43fb4ae45724 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/rtd/ResponseTimeDistributionHourEsTableDefine.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.apm.collector.storage.es.define.rtd; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistributionTable; + +/** + * @author peng-yongsheng + */ +public class ResponseTimeDistributionHourEsTableDefine extends AbstractResponseTimeDistributionEsTableDefine { + + public ResponseTimeDistributionHourEsTableDefine() { + super(ResponseTimeDistributionTable.TABLE + Const.ID_SPLIT + TimePyramid.Hour.getName()); + } + + @Override public int refreshInterval() { + return 2; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/rtd/ResponseTimeDistributionMinuteEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/rtd/ResponseTimeDistributionMinuteEsTableDefine.java new file mode 100644 index 0000000000000000000000000000000000000000..e102b4402ca745d3171c551172a485ae4fc0bff3 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/rtd/ResponseTimeDistributionMinuteEsTableDefine.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.apm.collector.storage.es.define.rtd; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistributionTable; + +/** + * @author peng-yongsheng + */ +public class ResponseTimeDistributionMinuteEsTableDefine extends AbstractResponseTimeDistributionEsTableDefine { + + public ResponseTimeDistributionMinuteEsTableDefine() { + super(ResponseTimeDistributionTable.TABLE + Const.ID_SPLIT + TimePyramid.Minute.getName()); + } + + @Override public int refreshInterval() { + return 2; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/rtd/ResponseTimeDistributionMonthEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/rtd/ResponseTimeDistributionMonthEsTableDefine.java new file mode 100644 index 0000000000000000000000000000000000000000..3eb0d9453621cd292d733c9c1cb98674c5b3828d --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/rtd/ResponseTimeDistributionMonthEsTableDefine.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.apm.collector.storage.es.define.rtd; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistributionTable; + +/** + * @author peng-yongsheng + */ +public class ResponseTimeDistributionMonthEsTableDefine extends AbstractResponseTimeDistributionEsTableDefine { + + public ResponseTimeDistributionMonthEsTableDefine() { + super(ResponseTimeDistributionTable.TABLE + Const.ID_SPLIT + TimePyramid.Month.getName()); + } + + @Override public int refreshInterval() { + return 2; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/resources/META-INF/defines/storage.define b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/resources/META-INF/defines/storage.define index 1f9e7a83819e0c4741f9da7868cdba669dbca3ab..8cdb1416dfc44398a29409a9f696e5976569b22f 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/resources/META-INF/defines/storage.define +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/resources/META-INF/defines/storage.define @@ -66,6 +66,11 @@ org.apache.skywalking.apm.collector.storage.es.define.amp.ApplicationHourMetricE org.apache.skywalking.apm.collector.storage.es.define.amp.ApplicationDayMetricEsTableDefine org.apache.skywalking.apm.collector.storage.es.define.amp.ApplicationMonthMetricEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.rtd.ResponseTimeDistributionMinuteEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.rtd.ResponseTimeDistributionHourEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.rtd.ResponseTimeDistributionDayEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.rtd.ResponseTimeDistributionMonthEsTableDefine + org.apache.skywalking.apm.collector.storage.es.define.GlobalTraceEsTableDefine org.apache.skywalking.apm.collector.storage.es.define.SegmentEsTableDefine org.apache.skywalking.apm.collector.storage.es.define.SegmentDurationEsTableDefine diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/StorageModuleH2Provider.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/StorageModuleH2Provider.java index 63d7e09011d68ecd46f868c7a3de2f890ad832ef..d8c134e3f9334679e821d9078c25f8fe58946e88 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/StorageModuleH2Provider.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/StorageModuleH2Provider.java @@ -103,6 +103,10 @@ import org.apache.skywalking.apm.collector.storage.dao.register.IApplicationRegi import org.apache.skywalking.apm.collector.storage.dao.register.IInstanceRegisterDAO; import org.apache.skywalking.apm.collector.storage.dao.register.INetworkAddressRegisterDAO; import org.apache.skywalking.apm.collector.storage.dao.register.IServiceNameRegisterDAO; +import org.apache.skywalking.apm.collector.storage.dao.rtd.IResponseTimeDistributionDayPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.rtd.IResponseTimeDistributionHourPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.rtd.IResponseTimeDistributionMinutePersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.rtd.IResponseTimeDistributionMonthPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.smp.IServiceDayMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.smp.IServiceHourMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.smp.IServiceMinuteMetricPersistenceDAO; @@ -208,6 +212,10 @@ import org.apache.skywalking.apm.collector.storage.h2.dao.register.ApplicationRe import org.apache.skywalking.apm.collector.storage.h2.dao.register.InstanceRegisterH2DAO; import org.apache.skywalking.apm.collector.storage.h2.dao.register.NetworkAddressRegisterH2DAO; import org.apache.skywalking.apm.collector.storage.h2.dao.register.ServiceNameRegisterH2DAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.rtd.ResponseTimeDistributionDayH2PersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.rtd.ResponseTimeDistributionHourH2PersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.rtd.ResponseTimeDistributionMinuteH2PersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.rtd.ResponseTimeDistributionMonthH2PersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.smp.ServiceDayMetricH2PersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.smp.ServiceHourMetricH2PersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.smp.ServiceMinuteMetricH2PersistenceDAO; @@ -334,6 +342,12 @@ public class StorageModuleH2Provider extends ModuleProvider { this.registerServiceImplementation(IMemoryPoolMonthMetricPersistenceDAO.class, new MemoryPoolMonthMetricH2PersistenceDAO(h2Client)); this.registerServiceImplementation(IGlobalTracePersistenceDAO.class, new GlobalTraceH2PersistenceDAO(h2Client)); + + this.registerServiceImplementation(IResponseTimeDistributionMinutePersistenceDAO.class, new ResponseTimeDistributionMinuteH2PersistenceDAO(h2Client)); + this.registerServiceImplementation(IResponseTimeDistributionHourPersistenceDAO.class, new ResponseTimeDistributionHourH2PersistenceDAO(h2Client)); + this.registerServiceImplementation(IResponseTimeDistributionDayPersistenceDAO.class, new ResponseTimeDistributionDayH2PersistenceDAO(h2Client)); + this.registerServiceImplementation(IResponseTimeDistributionMonthPersistenceDAO.class, new ResponseTimeDistributionMonthH2PersistenceDAO(h2Client)); + this.registerServiceImplementation(ISegmentDurationPersistenceDAO.class, new SegmentDurationH2PersistenceDAO(h2Client)); this.registerServiceImplementation(ISegmentPersistenceDAO.class, new SegmentH2PersistenceDAO(h2Client)); this.registerServiceImplementation(IInstanceHeartBeatPersistenceDAO.class, new InstanceHeartBeatH2PersistenceDAO(h2Client)); diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/rtd/AbstractResponseTimeDistributionH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/rtd/AbstractResponseTimeDistributionH2PersistenceDAO.java new file mode 100644 index 0000000000000000000000000000000000000000..f6ff210ab8d79704c4f2c456d3351fbce91d0d30 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/rtd/AbstractResponseTimeDistributionH2PersistenceDAO.java @@ -0,0 +1,69 @@ +/* + * 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.apm.collector.storage.h2.dao.rtd; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.HashMap; +import java.util.Map; +import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.storage.h2.base.dao.AbstractPersistenceH2DAO; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistribution; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistributionTable; + +/** + * @author peng-yongsheng + */ +public abstract class AbstractResponseTimeDistributionH2PersistenceDAO extends AbstractPersistenceH2DAO { + + AbstractResponseTimeDistributionH2PersistenceDAO(H2Client client) { + super(client); + } + + @Override protected final ResponseTimeDistribution h2DataToStreamData(ResultSet resultSet) throws SQLException { + ResponseTimeDistribution responseTimeDistribution = new ResponseTimeDistribution(); + responseTimeDistribution.setMetricId(resultSet.getString(ResponseTimeDistributionTable.METRIC_ID.getName())); + + responseTimeDistribution.setStep(resultSet.getInt(ResponseTimeDistributionTable.STEP.getName())); + + responseTimeDistribution.setCalls(resultSet.getLong(ResponseTimeDistributionTable.CALLS.getName())); + responseTimeDistribution.setErrorCalls(resultSet.getLong(ResponseTimeDistributionTable.ERROR_CALLS.getName())); + responseTimeDistribution.setSuccessCalls(resultSet.getLong(ResponseTimeDistributionTable.SUCCESS_CALLS.getName())); + + responseTimeDistribution.setTimeBucket(resultSet.getLong(ResponseTimeDistributionTable.TIME_BUCKET.getName())); + + return responseTimeDistribution; + } + + @Override protected final Map streamDataToH2Data(ResponseTimeDistribution streamData) { + Map target = new HashMap<>(); + target.put(ResponseTimeDistributionTable.ID.getName(), streamData.getId()); + target.put(ResponseTimeDistributionTable.METRIC_ID.getName(), streamData.getMetricId()); + + target.put(ResponseTimeDistributionTable.STEP.getName(), streamData.getStep()); + + target.put(ResponseTimeDistributionTable.CALLS.getName(), streamData.getCalls()); + target.put(ResponseTimeDistributionTable.ERROR_CALLS.getName(), streamData.getErrorCalls()); + target.put(ResponseTimeDistributionTable.SUCCESS_CALLS.getName(), streamData.getSuccessCalls()); + + target.put(ResponseTimeDistributionTable.TIME_BUCKET.getName(), streamData.getTimeBucket()); + + return target; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/rtd/ResponseTimeDistributionDayH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/rtd/ResponseTimeDistributionDayH2PersistenceDAO.java new file mode 100644 index 0000000000000000000000000000000000000000..3ea7e4479d7487ac73fb829d2c75fa05772a32b3 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/rtd/ResponseTimeDistributionDayH2PersistenceDAO.java @@ -0,0 +1,41 @@ +/* + * 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.apm.collector.storage.h2.dao.rtd; + +import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.rtd.IResponseTimeDistributionDayPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistribution; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistributionTable; + +/** + * @author peng-yongsheng + */ +public class ResponseTimeDistributionDayH2PersistenceDAO extends AbstractResponseTimeDistributionH2PersistenceDAO implements IResponseTimeDistributionDayPersistenceDAO { + + public ResponseTimeDistributionDayH2PersistenceDAO(H2Client client) { + super(client); + } + + @Override protected String tableName() { + return ResponseTimeDistributionTable.TABLE + Const.ID_SPLIT + TimePyramid.Day.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/rtd/ResponseTimeDistributionHourH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/rtd/ResponseTimeDistributionHourH2PersistenceDAO.java new file mode 100644 index 0000000000000000000000000000000000000000..cf7b9eae7a7539ea53a68881a9ca8d35570fb575 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/rtd/ResponseTimeDistributionHourH2PersistenceDAO.java @@ -0,0 +1,41 @@ +/* + * 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.apm.collector.storage.h2.dao.rtd; + +import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.rtd.IResponseTimeDistributionHourPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistribution; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistributionTable; + +/** + * @author peng-yongsheng + */ +public class ResponseTimeDistributionHourH2PersistenceDAO extends AbstractResponseTimeDistributionH2PersistenceDAO implements IResponseTimeDistributionHourPersistenceDAO { + + public ResponseTimeDistributionHourH2PersistenceDAO(H2Client client) { + super(client); + } + + @Override protected String tableName() { + return ResponseTimeDistributionTable.TABLE + Const.ID_SPLIT + TimePyramid.Hour.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/rtd/ResponseTimeDistributionMinuteH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/rtd/ResponseTimeDistributionMinuteH2PersistenceDAO.java new file mode 100644 index 0000000000000000000000000000000000000000..382d27eef0f6d175afe7e4d3edeff7e96523053d --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/rtd/ResponseTimeDistributionMinuteH2PersistenceDAO.java @@ -0,0 +1,41 @@ +/* + * 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.apm.collector.storage.h2.dao.rtd; + +import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.rtd.IResponseTimeDistributionMinutePersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistribution; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistributionTable; + +/** + * @author peng-yongsheng + */ +public class ResponseTimeDistributionMinuteH2PersistenceDAO extends AbstractResponseTimeDistributionH2PersistenceDAO implements IResponseTimeDistributionMinutePersistenceDAO { + + public ResponseTimeDistributionMinuteH2PersistenceDAO(H2Client client) { + super(client); + } + + @Override protected String tableName() { + return ResponseTimeDistributionTable.TABLE + Const.ID_SPLIT + TimePyramid.Minute.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/rtd/ResponseTimeDistributionMonthH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/rtd/ResponseTimeDistributionMonthH2PersistenceDAO.java new file mode 100644 index 0000000000000000000000000000000000000000..0838b7607eb140932f293ab7d8cbc467c7e31163 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/rtd/ResponseTimeDistributionMonthH2PersistenceDAO.java @@ -0,0 +1,41 @@ +/* + * 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.apm.collector.storage.h2.dao.rtd; + +import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.rtd.IResponseTimeDistributionMonthPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistribution; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistributionTable; + +/** + * @author peng-yongsheng + */ +public class ResponseTimeDistributionMonthH2PersistenceDAO extends AbstractResponseTimeDistributionH2PersistenceDAO implements IResponseTimeDistributionMonthPersistenceDAO { + + public ResponseTimeDistributionMonthH2PersistenceDAO(H2Client client) { + super(client); + } + + @Override protected String tableName() { + return ResponseTimeDistributionTable.TABLE + Const.ID_SPLIT + TimePyramid.Month.getName(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/rtd/AbstractResponseTimeDistributionH2TableDefine.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/rtd/AbstractResponseTimeDistributionH2TableDefine.java new file mode 100644 index 0000000000000000000000000000000000000000..e907a815a382f876f87a4b453b27e7f0b4e37bee --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/rtd/AbstractResponseTimeDistributionH2TableDefine.java @@ -0,0 +1,43 @@ +/* + * 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.apm.collector.storage.h2.define.rtd; + +import org.apache.skywalking.apm.collector.storage.h2.base.define.H2ColumnDefine; +import org.apache.skywalking.apm.collector.storage.h2.base.define.H2TableDefine; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistributionTable; + +/** + * @author peng-yongsheng + */ +public abstract class AbstractResponseTimeDistributionH2TableDefine extends H2TableDefine { + + AbstractResponseTimeDistributionH2TableDefine(String name) { + super(name); + } + + @Override public final void initialize() { + addColumn(new H2ColumnDefine(ResponseTimeDistributionTable.ID, H2ColumnDefine.Type.Varchar.name())); + addColumn(new H2ColumnDefine(ResponseTimeDistributionTable.METRIC_ID, H2ColumnDefine.Type.Varchar.name())); + addColumn(new H2ColumnDefine(ResponseTimeDistributionTable.STEP, H2ColumnDefine.Type.Int.name())); + addColumn(new H2ColumnDefine(ResponseTimeDistributionTable.CALLS, H2ColumnDefine.Type.Bigint.name())); + addColumn(new H2ColumnDefine(ResponseTimeDistributionTable.ERROR_CALLS, H2ColumnDefine.Type.Bigint.name())); + addColumn(new H2ColumnDefine(ResponseTimeDistributionTable.SUCCESS_CALLS, H2ColumnDefine.Type.Bigint.name())); + addColumn(new H2ColumnDefine(ResponseTimeDistributionTable.TIME_BUCKET, H2ColumnDefine.Type.Bigint.name())); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/rtd/ResponseTimeDistributionDayH2TableDefine.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/rtd/ResponseTimeDistributionDayH2TableDefine.java new file mode 100644 index 0000000000000000000000000000000000000000..89dda09c3ecf1507866b132012b4c7d0bb56f42c --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/rtd/ResponseTimeDistributionDayH2TableDefine.java @@ -0,0 +1,33 @@ +/* + * 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.apm.collector.storage.h2.define.rtd; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistributionTable; + +/** + * @author peng-yongsheng + */ +public class ResponseTimeDistributionDayH2TableDefine extends AbstractResponseTimeDistributionH2TableDefine { + + public ResponseTimeDistributionDayH2TableDefine() { + super(ResponseTimeDistributionTable.TABLE + Const.ID_SPLIT + TimePyramid.Day.getName()); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/rtd/ResponseTimeDistributionHourH2TableDefine.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/rtd/ResponseTimeDistributionHourH2TableDefine.java new file mode 100644 index 0000000000000000000000000000000000000000..8ff7394f0424155ad371f61fd753cd65a6b7209b --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/rtd/ResponseTimeDistributionHourH2TableDefine.java @@ -0,0 +1,33 @@ +/* + * 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.apm.collector.storage.h2.define.rtd; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistributionTable; + +/** + * @author peng-yongsheng + */ +public class ResponseTimeDistributionHourH2TableDefine extends AbstractResponseTimeDistributionH2TableDefine { + + public ResponseTimeDistributionHourH2TableDefine() { + super(ResponseTimeDistributionTable.TABLE + Const.ID_SPLIT + TimePyramid.Hour.getName()); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/rtd/ResponseTimeDistributionMinuteH2TableDefine.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/rtd/ResponseTimeDistributionMinuteH2TableDefine.java new file mode 100644 index 0000000000000000000000000000000000000000..386ce3c2a3a87125b055237e527979427814fb73 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/rtd/ResponseTimeDistributionMinuteH2TableDefine.java @@ -0,0 +1,33 @@ +/* + * 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.apm.collector.storage.h2.define.rtd; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistributionTable; + +/** + * @author peng-yongsheng + */ +public class ResponseTimeDistributionMinuteH2TableDefine extends AbstractResponseTimeDistributionH2TableDefine { + + public ResponseTimeDistributionMinuteH2TableDefine() { + super(ResponseTimeDistributionTable.TABLE + Const.ID_SPLIT + TimePyramid.Minute.getName()); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/rtd/ResponseTimeDistributionMonthH2TableDefine.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/rtd/ResponseTimeDistributionMonthH2TableDefine.java new file mode 100644 index 0000000000000000000000000000000000000000..b463331eafec41343f6873b40f6f7655843293a5 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/rtd/ResponseTimeDistributionMonthH2TableDefine.java @@ -0,0 +1,33 @@ +/* + * 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.apm.collector.storage.h2.define.rtd; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.table.global.ResponseTimeDistributionTable; + +/** + * @author peng-yongsheng + */ +public class ResponseTimeDistributionMonthH2TableDefine extends AbstractResponseTimeDistributionH2TableDefine { + + public ResponseTimeDistributionMonthH2TableDefine() { + super(ResponseTimeDistributionTable.TABLE + Const.ID_SPLIT + TimePyramid.Month.getName()); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/resources/META-INF/defines/storage.define b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/resources/META-INF/defines/storage.define index 0f044a09134da7ffa0bc9659fd5b44924cb02ee2..b42543e47c99f6bf5c012798c4068a2f4b9b55a4 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/resources/META-INF/defines/storage.define +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/resources/META-INF/defines/storage.define @@ -61,6 +61,12 @@ org.apache.skywalking.apm.collector.storage.h2.define.impp.InstanceMappingDayH2T org.apache.skywalking.apm.collector.storage.h2.define.impp.InstanceMappingMonthH2TableDefine org.apache.skywalking.apm.collector.storage.h2.define.GlobalTraceH2TableDefine + +org.apache.skywalking.apm.collector.storage.h2.define.rtd.ResponseTimeDistributionMinuteH2TableDefine +org.apache.skywalking.apm.collector.storage.h2.define.rtd.ResponseTimeDistributionHourH2TableDefine +org.apache.skywalking.apm.collector.storage.h2.define.rtd.ResponseTimeDistributionDayH2TableDefine +org.apache.skywalking.apm.collector.storage.h2.define.rtd.ResponseTimeDistributionMonthH2TableDefine + org.apache.skywalking.apm.collector.storage.h2.define.SegmentDurationH2TableDefine org.apache.skywalking.apm.collector.storage.h2.define.SegmentH2TableDefine