You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2022/09/29 00:08:35 UTC
[skywalking] branch master updated: Unify query services and DAOs codes time range condition to `Duration`. (#9702)
This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking.git
The following commit(s) were added to refs/heads/master by this push:
new 4a7e8191dd Unify query services and DAOs codes time range condition to `Duration`. (#9702)
4a7e8191dd is described below
commit 4a7e8191ddfe55b33db092ae0ad4f356f72b58f3
Author: Wan Kai <wa...@foxmail.com>
AuthorDate: Thu Sep 29 08:08:15 2022 +0800
Unify query services and DAOs codes time range condition to `Duration`. (#9702)
---
docs/en/changes/changes.md | 1 +
.../oap/server/core/query/AlarmQueryService.java | 7 +-
.../server/core/query/BrowserLogQueryService.java | 6 +-
.../oap/server/core/query/LogQueryService.java | 6 +-
.../server/core/query/MetadataQueryService.java | 6 +-
.../core/query/TagAutoCompleteQueryService.java | 11 ++--
.../server/core/query/TopologyQueryService.java | 37 ++++++-----
.../oap/server/core/query/TraceQueryService.java | 6 +-
.../server/core/storage/query/IAlarmQueryDAO.java | 5 +-
.../core/storage/query/IBrowserLogQueryDAO.java | 4 +-
.../server/core/storage/query/ILogQueryDAO.java | 4 +-
.../core/storage/query/IMetadataQueryDAO.java | 12 ++--
.../storage/query/ITagAutoCompleteQueryDAO.java | 7 +-
.../core/storage/query/ITopologyQueryDAO.java | 26 +++-----
.../server/core/storage/query/ITraceQueryDAO.java | 4 +-
.../server/core/storage/query/IZipkinQueryDAO.java | 3 +-
.../oap/query/graphql/resolver/AlarmQuery.java | 6 +-
.../query/graphql/resolver/BrowserLogQuery.java | 11 +---
.../oap/query/graphql/resolver/LogQuery.java | 14 ++--
.../oap/query/graphql/resolver/MetadataQuery.java | 3 +-
.../query/graphql/resolver/MetadataQueryV2.java | 3 +-
.../oap/query/graphql/resolver/TopologyQuery.java | 15 ++---
.../oap/query/graphql/resolver/TraceQuery.java | 15 ++---
.../handler/ZipkinQueryExceptionHandler.java | 4 ++
.../query/zipkin/handler/ZipkinQueryHandler.java | 41 +++++++-----
.../banyandb/measure/BanyanDBMetadataQueryDAO.java | 9 ++-
.../measure/BanyanDBTagAutocompleteQueryDAO.java | 31 +++++++--
.../banyandb/measure/BanyanDBTopologyQueryDAO.java | 71 ++++++++++++++-------
.../banyandb/stream/BanyanDBAlarmQueryDAO.java | 5 +-
.../stream/BanyanDBBrowserLogQueryDAO.java | 7 +-
.../banyandb/stream/BanyanDBLogQueryDAO.java | 11 +++-
.../banyandb/stream/BanyanDBTraceQueryDAO.java | 11 +++-
.../banyandb/stream/BanyanDBZipkinQueryDAO.java | 3 +-
.../elasticsearch/query/AlarmQueryEsDAO.java | 6 +-
.../elasticsearch/query/BrowserLogQueryEsDAO.java | 9 ++-
.../plugin/elasticsearch/query/LogQueryEsDAO.java | 10 ++-
.../elasticsearch/query/MetadataQueryEsDAO.java | 9 ++-
.../query/TagAutoCompleteQueryDAO.java | 23 +++++--
.../elasticsearch/query/TopologyQueryEsDAO.java | 66 +++++++++----------
.../elasticsearch/query/TraceQueryEsDAO.java | 12 +++-
.../query/zipkin/ZipkinQueryEsDAO.java | 7 +-
.../plugin/jdbc/h2/dao/H2AlarmQueryDAO.java | 13 +++-
.../plugin/jdbc/h2/dao/H2BrowserLogQueryDAO.java | 9 ++-
.../storage/plugin/jdbc/h2/dao/H2LogQueryDAO.java | 10 ++-
.../plugin/jdbc/h2/dao/H2MetadataQueryDAO.java | 9 ++-
.../jdbc/h2/dao/H2TagAutoCompleteQueryDAO.java | 28 +++++---
.../plugin/jdbc/h2/dao/H2TopologyQueryDAO.java | 74 ++++++++++------------
.../plugin/jdbc/h2/dao/H2TraceQueryDAO.java | 12 +++-
.../plugin/jdbc/h2/dao/H2ZipkinQueryDAO.java | 7 +-
.../profile/exporter/test/ProfileTraceDAO.java | 4 +-
50 files changed, 415 insertions(+), 298 deletions(-)
diff --git a/docs/en/changes/changes.md b/docs/en/changes/changes.md
index 65d3a0281c..898f229644 100644
--- a/docs/en/changes/changes.md
+++ b/docs/en/changes/changes.md
@@ -27,6 +27,7 @@
* Fix the wrong watch semantics in Kubernetes watchers, which causes heavy traffic to API server in some Kubernetes clusters,
we should use `Get State and Start at Most Recent` semantic instead of `Start at Exact`
because we don't need the changing history events, see https://kubernetes.io/docs/reference/using-api/api-concepts/#semantics-for-watch.
+* Unify query services and DAOs codes time range condition to `Duration`.
#### UI
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/AlarmQueryService.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/AlarmQueryService.java
index fb06c1907b..11f13904fd 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/AlarmQueryService.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/AlarmQueryService.java
@@ -22,6 +22,7 @@ import java.io.IOException;
import java.util.List;
import org.apache.skywalking.oap.server.core.analysis.manual.searchtag.Tag;
+import org.apache.skywalking.oap.server.core.query.input.Duration;
import org.apache.skywalking.oap.server.core.query.type.Alarms;
import org.apache.skywalking.oap.server.core.query.type.Pagination;
import org.apache.skywalking.oap.server.core.storage.StorageModule;
@@ -45,9 +46,9 @@ public class AlarmQueryService implements Service {
return alarmQueryDAO;
}
- public Alarms getAlarm(final Integer scopeId, final String keyword, final Pagination paging, final long startTB,
- final long endTB, final List<Tag> tags) throws IOException {
+ public Alarms getAlarm(final Integer scopeId, final String keyword, final Pagination paging,
+ final Duration duration, final List<Tag> tags) throws IOException {
PaginationUtils.Page page = PaginationUtils.INSTANCE.exchange(paging);
- return getAlarmQueryDAO().getAlarm(scopeId, keyword, page.getLimit(), page.getFrom(), startTB, endTB, tags);
+ return getAlarmQueryDAO().getAlarm(scopeId, keyword, page.getLimit(), page.getFrom(), duration, tags);
}
}
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/BrowserLogQueryService.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/BrowserLogQueryService.java
index a967305ba6..e04b91a07b 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/BrowserLogQueryService.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/BrowserLogQueryService.java
@@ -21,6 +21,7 @@ import java.io.IOException;
import java.util.Optional;
import lombok.RequiredArgsConstructor;
import org.apache.skywalking.oap.server.core.browser.source.BrowserErrorCategory;
+import org.apache.skywalking.oap.server.core.query.input.Duration;
import org.apache.skywalking.oap.server.core.query.type.BrowserErrorLogs;
import org.apache.skywalking.oap.server.core.query.type.ErrorCategory;
import org.apache.skywalking.oap.server.core.query.type.Pagination;
@@ -47,8 +48,7 @@ public class BrowserLogQueryService implements Service {
final String serviceVersionId,
final String pagePathId,
final ErrorCategory category,
- final long startSecondTB,
- final long endSecondTB,
+ final Duration duration,
final Pagination paging) throws IOException {
PaginationUtils.Page page = PaginationUtils.INSTANCE.exchange(paging);
BrowserErrorCategory errorCategory = Optional.ofNullable(category)
@@ -57,7 +57,7 @@ public class BrowserLogQueryService implements Service {
.orElse(null);
return getBrowserLogQueryDAO().queryBrowserErrorLogs(
- serviceId, serviceVersionId, pagePathId, errorCategory, startSecondTB, endSecondTB,
+ serviceId, serviceVersionId, pagePathId, errorCategory, duration,
page.getLimit(),
page.getFrom()
);
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/LogQueryService.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/LogQueryService.java
index f3707b7bd3..fc93944c21 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/LogQueryService.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/LogQueryService.java
@@ -21,6 +21,7 @@ package org.apache.skywalking.oap.server.core.query;
import java.io.IOException;
import java.util.List;
import java.util.stream.Collectors;
+import org.apache.skywalking.oap.server.core.query.input.Duration;
import org.apache.skywalking.oap.server.library.util.StringUtil;
import org.apache.skywalking.oap.server.core.analysis.IDManager;
import org.apache.skywalking.oap.server.core.analysis.manual.searchtag.Tag;
@@ -61,8 +62,7 @@ public class LogQueryService implements Service {
TraceScopeCondition relatedTrace,
Pagination paging,
Order queryOrder,
- final long startTB,
- final long endTB,
+ final Duration duration,
final List<Tag> tags,
List<String> keywordsOfContent,
List<String> excludingKeywordsOfContent) throws IOException {
@@ -85,7 +85,7 @@ public class LogQueryService implements Service {
relatedTrace,
queryOrder,
page.getFrom(), page.getLimit(),
- startTB, endTB, tags,
+ duration, tags,
keywordsOfContent, excludingKeywordsOfContent
);
logs.getLogs().forEach(log -> {
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/MetadataQueryService.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/MetadataQueryService.java
index b54fdf40d0..5db46c3d9a 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/MetadataQueryService.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/MetadataQueryService.java
@@ -78,9 +78,9 @@ public class MetadataQueryService implements org.apache.skywalking.oap.server.li
return getMetadataQueryDAO().getInstance(instanceId);
}
- public List<ServiceInstance> listInstances(final long startTimestamp, final long endTimestamp,
+ public List<ServiceInstance> listInstances(final Duration duration,
final String serviceId) throws IOException {
- return getMetadataQueryDAO().listInstances(startTimestamp, endTimestamp, serviceId)
+ return getMetadataQueryDAO().listInstances(duration, serviceId)
.stream().distinct().collect(Collectors.toList());
}
@@ -108,7 +108,7 @@ public class MetadataQueryService implements org.apache.skywalking.oap.server.li
if (duration.getEndTimeBucket() < duration.getStartTimeBucket()) {
return Collections.emptyList();
}
- return getMetadataQueryDAO().listProcesses(instanceId, duration.getStartTimeBucket(), duration.getEndTimeBucket(), true);
+ return getMetadataQueryDAO().listProcesses(instanceId, duration, true);
}
public Process getProcess(String processId) throws IOException {
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/TagAutoCompleteQueryService.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/TagAutoCompleteQueryService.java
index 79992dd1dc..ba09013883 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/TagAutoCompleteQueryService.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/TagAutoCompleteQueryService.java
@@ -22,6 +22,7 @@ import java.io.IOException;
import java.util.Set;
import org.apache.skywalking.oap.server.core.CoreModuleConfig;
import org.apache.skywalking.oap.server.core.analysis.manual.searchtag.TagType;
+import org.apache.skywalking.oap.server.core.query.input.Duration;
import org.apache.skywalking.oap.server.core.storage.StorageModule;
import org.apache.skywalking.oap.server.core.storage.query.ITagAutoCompleteQueryDAO;
import org.apache.skywalking.oap.server.library.module.ModuleManager;
@@ -45,16 +46,14 @@ public class TagAutoCompleteQueryService implements Service {
}
public Set<String> queryTagAutocompleteKeys(final TagType tagType,
- final long startSecondTB,
- final long endSecondTB) throws IOException {
- return getTagAutoCompleteQueryDAO().queryTagAutocompleteKeys(tagType, config.getAutocompleteTagKeysQueryMaxSize(), startSecondTB, endSecondTB);
+ final Duration duration) throws IOException {
+ return getTagAutoCompleteQueryDAO().queryTagAutocompleteKeys(tagType, config.getAutocompleteTagKeysQueryMaxSize(), duration);
}
public Set<String> queryTagAutocompleteValues(final TagType tagType,
final String tagKey,
- final long startSecondTB,
- final long endSecondTB) throws IOException {
+ final Duration duration) throws IOException {
return getTagAutoCompleteQueryDAO().queryTagAutocompleteValues(
- tagType, tagKey, config.getAutocompleteTagValuesQueryMaxSize(), startSecondTB, endSecondTB);
+ tagType, tagKey, config.getAutocompleteTagValuesQueryMaxSize(), duration);
}
}
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/TopologyQueryService.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/TopologyQueryService.java
index 40a4b10a50..4ed5796127 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/TopologyQueryService.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/TopologyQueryService.java
@@ -29,6 +29,7 @@ import org.apache.skywalking.oap.server.core.Const;
import org.apache.skywalking.oap.server.core.CoreModule;
import org.apache.skywalking.oap.server.core.analysis.IDManager;
import org.apache.skywalking.oap.server.core.config.IComponentLibraryCatalogService;
+import org.apache.skywalking.oap.server.core.query.input.Duration;
import org.apache.skywalking.oap.server.core.query.type.Call;
import org.apache.skywalking.oap.server.core.query.type.EndpointNode;
import org.apache.skywalking.oap.server.core.query.type.EndpointTopology;
@@ -72,23 +73,22 @@ public class TopologyQueryService implements Service {
return componentLibraryCatalogService;
}
- public Topology getGlobalTopology(final long startTB,
- final long endTB) throws IOException {
+ public Topology getGlobalTopology(final Duration duration) throws IOException {
List<Call.CallDetail> serviceRelationServerCalls = getTopologyQueryDAO().loadServiceRelationsDetectedAtServerSide(
- startTB, endTB);
+ duration);
List<Call.CallDetail> serviceRelationClientCalls = getTopologyQueryDAO().loadServiceRelationDetectedAtClientSide(
- startTB, endTB);
+ duration);
ServiceTopologyBuilder builder = new ServiceTopologyBuilder(moduleManager);
return builder.build(serviceRelationClientCalls, serviceRelationServerCalls);
}
- public Topology getServiceTopology(final long startTB, final long endTB,
+ public Topology getServiceTopology(final Duration duration,
final List<String> serviceIds) throws IOException {
List<Call.CallDetail> serviceRelationClientCalls = getTopologyQueryDAO().loadServiceRelationDetectedAtClientSide(
- startTB, endTB, serviceIds);
+ duration, serviceIds);
List<Call.CallDetail> serviceRelationServerCalls = getTopologyQueryDAO().loadServiceRelationsDetectedAtServerSide(
- startTB, endTB, serviceIds);
+ duration, serviceIds);
ServiceTopologyBuilder builder = new ServiceTopologyBuilder(moduleManager);
Topology topology = builder.build(serviceRelationClientCalls, serviceRelationServerCalls);
@@ -109,7 +109,7 @@ public class TopologyQueryService implements Service {
if (CollectionUtils.isNotEmpty(outScopeSourceServiceIds)) {
// If exist, query them as the server side to get the target's component.
List<Call.CallDetail> sourceCalls = getTopologyQueryDAO().loadServiceRelationsDetectedAtServerSide(
- startTB, endTB, outScopeSourceServiceIds);
+ duration, outScopeSourceServiceIds);
topology.getNodes().forEach(node -> {
if (Strings.isNullOrEmpty(node.getType())) {
for (Call.CallDetail call : sourceCalls) {
@@ -127,22 +127,21 @@ public class TopologyQueryService implements Service {
public ServiceInstanceTopology getServiceInstanceTopology(final String clientServiceId,
final String serverServiceId,
- final long startTB,
- final long endTB) throws IOException {
+ final Duration duration) throws IOException {
List<Call.CallDetail> serviceInstanceRelationClientCalls = getTopologyQueryDAO().loadInstanceRelationDetectedAtClientSide(
- clientServiceId, serverServiceId, startTB, endTB);
+ clientServiceId, serverServiceId, duration);
List<Call.CallDetail> serviceInstanceRelationServerCalls = getTopologyQueryDAO().loadInstanceRelationDetectedAtServerSide(
- clientServiceId, serverServiceId, startTB, endTB);
+ clientServiceId, serverServiceId, duration);
ServiceInstanceTopologyBuilder builder = new ServiceInstanceTopologyBuilder(moduleManager);
return builder.build(serviceInstanceRelationClientCalls, serviceInstanceRelationServerCalls);
}
@Deprecated
- public Topology getEndpointTopology(final long startTB, final long endTB,
+ public Topology getEndpointTopology(final Duration duration,
final String endpointId) throws IOException {
List<Call.CallDetail> serverSideCalls = getTopologyQueryDAO().loadEndpointRelation(
- startTB, endTB, endpointId);
+ duration, endpointId);
Topology topology = new Topology();
serverSideCalls.forEach(callDetail -> {
@@ -169,10 +168,10 @@ public class TopologyQueryService implements Service {
return topology;
}
- public EndpointTopology getEndpointDependencies(final long startTB, final long endTB,
+ public EndpointTopology getEndpointDependencies(final Duration duration,
final String endpointId) throws IOException {
List<Call.CallDetail> serverSideCalls = getTopologyQueryDAO().loadEndpointRelation(
- startTB, endTB, endpointId);
+ duration, endpointId);
EndpointTopology topology = new EndpointTopology();
serverSideCalls.forEach(callDetail -> {
@@ -199,9 +198,9 @@ public class TopologyQueryService implements Service {
return topology;
}
- public ProcessTopology getProcessTopology(final String instanceId, final long startTB, final long endTB) throws IOException {
- final List<Call.CallDetail> clientCalls = getTopologyQueryDAO().loadProcessRelationDetectedAtClientSide(instanceId, startTB, endTB);
- final List<Call.CallDetail> serverCalls = getTopologyQueryDAO().loadProcessRelationDetectedAtServerSide(instanceId, startTB, endTB);
+ public ProcessTopology getProcessTopology(final String instanceId, final Duration duration) throws IOException {
+ final List<Call.CallDetail> clientCalls = getTopologyQueryDAO().loadProcessRelationDetectedAtClientSide(instanceId, duration);
+ final List<Call.CallDetail> serverCalls = getTopologyQueryDAO().loadProcessRelationDetectedAtServerSide(instanceId, duration);
final ProcessTopologyBuilder topologyBuilder = new ProcessTopologyBuilder(moduleManager, storageModels);
return topologyBuilder.build(clientCalls, serverCalls);
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/TraceQueryService.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/TraceQueryService.java
index 35af099f28..af1ebd5cb6 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/TraceQueryService.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/TraceQueryService.java
@@ -29,6 +29,7 @@ import org.apache.skywalking.oap.server.core.CoreModule;
import org.apache.skywalking.oap.server.core.analysis.manual.searchtag.Tag;
import org.apache.skywalking.oap.server.core.analysis.manual.segment.SegmentRecord;
import org.apache.skywalking.oap.server.core.config.IComponentLibraryCatalogService;
+import org.apache.skywalking.oap.server.core.query.input.Duration;
import org.apache.skywalking.oap.server.core.query.type.KeyValue;
import org.apache.skywalking.oap.server.core.query.type.LogEntity;
import org.apache.skywalking.oap.server.core.query.type.Pagination;
@@ -82,13 +83,12 @@ public class TraceQueryService implements Service {
final TraceState traceState,
final QueryOrder queryOrder,
final Pagination paging,
- final long startTB,
- final long endTB,
+ final Duration duration,
final List<Tag> tags) throws IOException {
PaginationUtils.Page page = PaginationUtils.INSTANCE.exchange(paging);
return getTraceQueryDAO().queryBasicTraces(
- startTB, endTB, minTraceDuration, maxTraceDuration, serviceId, serviceInstanceId, endpointId,
+ duration, minTraceDuration, maxTraceDuration, serviceId, serviceInstanceId, endpointId,
traceId, page.getLimit(), page.getFrom(), traceState, queryOrder, tags
);
}
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/IAlarmQueryDAO.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/IAlarmQueryDAO.java
index 65f91b376b..6f61226a5b 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/IAlarmQueryDAO.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/IAlarmQueryDAO.java
@@ -26,6 +26,7 @@ import com.google.common.base.Charsets;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import org.apache.skywalking.oap.server.core.analysis.manual.searchtag.Tag;
+import org.apache.skywalking.oap.server.core.query.input.Duration;
import org.apache.skywalking.oap.server.core.query.type.Alarms;
import org.apache.skywalking.oap.server.core.query.type.KeyValue;
import org.apache.skywalking.oap.server.core.storage.DAO;
@@ -34,8 +35,8 @@ public interface IAlarmQueryDAO extends DAO {
Gson GSON = new Gson();
- Alarms getAlarm(final Integer scopeId, final String keyword, final int limit, final int from, final long startTB,
- final long endTB, final List<Tag> tags) throws IOException;
+ Alarms getAlarm(final Integer scopeId, final String keyword, final int limit, final int from,
+ final Duration duration, final List<Tag> tags) throws IOException;
/**
* Parser the raw tags.
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/IBrowserLogQueryDAO.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/IBrowserLogQueryDAO.java
index a8352ff156..0f0f51e98e 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/IBrowserLogQueryDAO.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/IBrowserLogQueryDAO.java
@@ -21,6 +21,7 @@ import com.google.protobuf.InvalidProtocolBufferException;
import java.io.IOException;
import java.util.Base64;
import org.apache.skywalking.oap.server.core.browser.source.BrowserErrorCategory;
+import org.apache.skywalking.oap.server.core.query.input.Duration;
import org.apache.skywalking.oap.server.core.query.type.BrowserErrorLog;
import org.apache.skywalking.oap.server.core.query.type.BrowserErrorLogs;
import org.apache.skywalking.oap.server.core.query.type.ErrorCategory;
@@ -31,8 +32,7 @@ public interface IBrowserLogQueryDAO extends Service {
String serviceVersionId,
String pagePathId,
BrowserErrorCategory category,
- long startSecondTB,
- long endSecondTB,
+ Duration duration,
int limit,
int from) throws IOException;
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/ILogQueryDAO.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/ILogQueryDAO.java
index f7c7b94bb4..f4365fbbac 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/ILogQueryDAO.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/ILogQueryDAO.java
@@ -25,6 +25,7 @@ import java.util.List;
import org.apache.skywalking.apm.network.logging.v3.LogTags;
import org.apache.skywalking.oap.server.core.analysis.manual.searchtag.Tag;
import org.apache.skywalking.oap.server.core.query.enumeration.Order;
+import org.apache.skywalking.oap.server.core.query.input.Duration;
import org.apache.skywalking.oap.server.core.query.input.TraceScopeCondition;
import org.apache.skywalking.oap.server.core.query.type.KeyValue;
import org.apache.skywalking.oap.server.core.query.type.Logs;
@@ -43,8 +44,7 @@ public interface ILogQueryDAO extends Service {
Order queryOrder,
int from,
int limit,
- final long startTB,
- final long endTB,
+ final Duration duration,
final List<Tag> tags,
final List<String> keywordsOfContent,
final List<String> excludingKeywordsOfContent) throws IOException;
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/IMetadataQueryDAO.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/IMetadataQueryDAO.java
index 5734d9a058..e069a49116 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/IMetadataQueryDAO.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/IMetadataQueryDAO.java
@@ -22,6 +22,7 @@ import java.io.IOException;
import java.util.List;
import org.apache.skywalking.oap.server.core.query.enumeration.ProfilingSupportStatus;
+import org.apache.skywalking.oap.server.core.query.input.Duration;
import org.apache.skywalking.oap.server.core.query.type.Endpoint;
import org.apache.skywalking.oap.server.core.query.type.Process;
import org.apache.skywalking.oap.server.core.query.type.Service;
@@ -42,12 +43,11 @@ public interface IMetadataQueryDAO extends DAO {
List<Service> getServices(final String serviceId) throws IOException;
/**
- * @param startTimestamp The instance is required to be live after this timestamp
- * @param endTimestamp The instance is required to be live before this timestamp.
+ * @param duration The instance is required to be live in this duration.
* @param serviceId the owner of the instances.
* @return list of instances matching the given conditions.
*/
- List<ServiceInstance> listInstances(final long startTimestamp, final long endTimestamp,
+ List<ServiceInstance> listInstances(final Duration duration,
final String serviceId) throws IOException;
ServiceInstance getInstance(final String instanceId) throws IOException;
@@ -71,11 +71,9 @@ public interface IMetadataQueryDAO extends DAO {
/**
* @param serviceInstanceId the instance id of the process.
- * @param lastPingStartTimeBucket the start time bucket of last ping.
- * @param lastPingEndTimeBucket the end time bucket of last ping.
+ * @param duration the start and end time bucket of last ping.
*/
- List<Process> listProcesses(final String serviceInstanceId, final long lastPingStartTimeBucket,
- final long lastPingEndTimeBucket, boolean includeVirtual) throws IOException;
+ List<Process> listProcesses(final String serviceInstanceId, final Duration duration, boolean includeVirtual) throws IOException;
/**
* @param agentId the agent id of the process.
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/ITagAutoCompleteQueryDAO.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/ITagAutoCompleteQueryDAO.java
index e54802a949..2f3d7c4283 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/ITagAutoCompleteQueryDAO.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/ITagAutoCompleteQueryDAO.java
@@ -21,17 +21,16 @@ package org.apache.skywalking.oap.server.core.storage.query;
import java.io.IOException;
import java.util.Set;
import org.apache.skywalking.oap.server.core.analysis.manual.searchtag.TagType;
+import org.apache.skywalking.oap.server.core.query.input.Duration;
import org.apache.skywalking.oap.server.library.module.Service;
public interface ITagAutoCompleteQueryDAO extends Service {
Set<String> queryTagAutocompleteKeys(final TagType tagType,
final int limit,
- final long startSecondTB,
- final long endSecondTB) throws IOException;
+ final Duration duration) throws IOException;
Set<String> queryTagAutocompleteValues(final TagType tagType,
final String tagKey,
final int limit,
- final long startSecondTB,
- final long endSecondTB) throws IOException;
+ final Duration duration) throws IOException;
}
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/ITopologyQueryDAO.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/ITopologyQueryDAO.java
index ca96897612..2415911283 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/ITopologyQueryDAO.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/ITopologyQueryDAO.java
@@ -24,6 +24,7 @@ import org.apache.skywalking.oap.server.core.analysis.manual.relation.instance.S
import org.apache.skywalking.oap.server.core.analysis.manual.relation.instance.ServiceInstanceRelationServerSideMetrics;
import org.apache.skywalking.oap.server.core.analysis.manual.relation.service.ServiceRelationClientSideMetrics;
import org.apache.skywalking.oap.server.core.analysis.manual.relation.service.ServiceRelationServerSideMetrics;
+import org.apache.skywalking.oap.server.core.query.input.Duration;
import org.apache.skywalking.oap.server.core.query.type.Call;
import org.apache.skywalking.oap.server.library.module.Service;
@@ -31,26 +32,24 @@ public interface ITopologyQueryDAO extends Service {
/**
* Query {@link ServiceRelationServerSideMetrics} through the given conditions
*/
- List<Call.CallDetail> loadServiceRelationsDetectedAtServerSide(long startTB, long endTB,
+ List<Call.CallDetail> loadServiceRelationsDetectedAtServerSide(Duration duration,
List<String> serviceIds) throws IOException;
/**
* Query {@link ServiceRelationClientSideMetrics} through the given conditions
*/
- List<Call.CallDetail> loadServiceRelationDetectedAtClientSide(long startTB, long endTB,
+ List<Call.CallDetail> loadServiceRelationDetectedAtClientSide(Duration duration,
List<String> serviceIds) throws IOException;
/**
* Query {@link ServiceRelationServerSideMetrics} globally, without given serviceIds
*/
- List<Call.CallDetail> loadServiceRelationsDetectedAtServerSide(long startTB,
- long endTB) throws IOException;
+ List<Call.CallDetail> loadServiceRelationsDetectedAtServerSide(Duration duration) throws IOException;
/**
* Query {@link ServiceRelationClientSideMetrics} globally, without given serviceIds
*/
- List<Call.CallDetail> loadServiceRelationDetectedAtClientSide(long startTB,
- long endTB) throws IOException;
+ List<Call.CallDetail> loadServiceRelationDetectedAtClientSide(Duration duration) throws IOException;
/**
* Query {@link ServiceInstanceRelationServerSideMetrics} through given conditions, including the specific
@@ -58,8 +57,7 @@ public interface ITopologyQueryDAO extends Service {
*/
List<Call.CallDetail> loadInstanceRelationDetectedAtServerSide(String clientServiceId,
String serverServiceId,
- long startTB,
- long endTB) throws IOException;
+ Duration duration) throws IOException;
/**
* Query {@link ServiceInstanceRelationClientSideMetrics} through given conditions, including the specific
@@ -67,14 +65,12 @@ public interface ITopologyQueryDAO extends Service {
*/
List<Call.CallDetail> loadInstanceRelationDetectedAtClientSide(String clientServiceId,
String serverServiceId,
- long startTB,
- long endTB) throws IOException;
+ Duration duration) throws IOException;
/**
* Query the endpoint relationship. Endpoint dependency is not detected from server side agent.
*/
- List<Call.CallDetail> loadEndpointRelation(long startTB,
- long endTB,
+ List<Call.CallDetail> loadEndpointRelation(Duration duration,
String destEndpointId) throws IOException;
/**
@@ -82,14 +78,12 @@ public interface ITopologyQueryDAO extends Service {
* through given conditions, including the specific service instance id
*/
List<Call.CallDetail> loadProcessRelationDetectedAtClientSide(String serviceInstanceId,
- long startTB,
- long endTB) throws IOException;
+ Duration duration) throws IOException;
/**
* Query {@link org.apache.skywalking.oap.server.core.analysis.manual.relation.process.ProcessRelationServerSideMetrics}
* through given conditions, including the specific service instance id
*/
List<Call.CallDetail> loadProcessRelationDetectedAtServerSide(String serviceInstanceId,
- long startTB,
- long endTB) throws IOException;
+ Duration duration) throws IOException;
}
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/ITraceQueryDAO.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/ITraceQueryDAO.java
index 7db5741231..d5fc9e923c 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/ITraceQueryDAO.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/ITraceQueryDAO.java
@@ -22,6 +22,7 @@ import java.io.IOException;
import java.util.List;
import org.apache.skywalking.oap.server.core.analysis.manual.searchtag.Tag;
import org.apache.skywalking.oap.server.core.analysis.manual.segment.SegmentRecord;
+import org.apache.skywalking.oap.server.core.query.input.Duration;
import org.apache.skywalking.oap.server.core.query.type.QueryOrder;
import org.apache.skywalking.oap.server.core.query.type.Span;
import org.apache.skywalking.oap.server.core.query.type.TraceBrief;
@@ -30,8 +31,7 @@ import org.apache.skywalking.oap.server.library.module.Service;
public interface ITraceQueryDAO extends Service {
- TraceBrief queryBasicTraces(long startSecondTB,
- long endSecondTB,
+ TraceBrief queryBasicTraces(Duration duration,
long minDuration,
long maxDuration,
String serviceId,
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/IZipkinQueryDAO.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/IZipkinQueryDAO.java
index 3c36228f15..0331f28bab 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/IZipkinQueryDAO.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/query/IZipkinQueryDAO.java
@@ -21,6 +21,7 @@ package org.apache.skywalking.oap.server.core.storage.query;
import java.io.IOException;
import java.util.List;
import java.util.Set;
+import org.apache.skywalking.oap.server.core.query.input.Duration;
import org.apache.skywalking.oap.server.core.storage.DAO;
import zipkin2.Span;
import zipkin2.storage.QueryRequest;
@@ -34,7 +35,7 @@ public interface IZipkinQueryDAO extends DAO {
List<Span> getTrace(final String traceId) throws IOException;
- List<List<Span>> getTraces(final QueryRequest request) throws IOException;
+ List<List<Span>> getTraces(final QueryRequest request, final Duration duration) throws IOException;
List<List<Span>> getTraces(final Set<String> traceIds) throws IOException;
}
diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/AlarmQuery.java b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/AlarmQuery.java
index 2c26a8c6e9..eca8f0f2a6 100644
--- a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/AlarmQuery.java
+++ b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/AlarmQuery.java
@@ -86,18 +86,14 @@ public class AlarmQuery implements GraphQLQueryResolver {
if (scope != null) {
scopeId = scope.getScopeId();
}
- long startSecondTB = 0;
- long endSecondTB = 0;
final EventQueryCondition.EventQueryConditionBuilder conditionPrototype =
EventQueryCondition.builder()
.paging(new Pagination(1, IEventQueryDAO.MAX_SIZE));
if (nonNull(duration)) {
- startSecondTB = duration.getStartTimeBucketInSec();
- endSecondTB = duration.getEndTimeBucketInSec();
conditionPrototype.time(duration);
}
Alarms alarms = getQueryService().getAlarm(
- scopeId, keyword, paging, startSecondTB, endSecondTB, tags);
+ scopeId, keyword, paging, duration, tags);
final boolean selectEvents = env.getSelectionSet().contains("**/events/**");
diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/BrowserLogQuery.java b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/BrowserLogQuery.java
index 89fe83389e..bb19870c5e 100644
--- a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/BrowserLogQuery.java
+++ b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/BrowserLogQuery.java
@@ -27,8 +27,6 @@ import org.apache.skywalking.oap.server.core.query.input.BrowserErrorLogQueryCon
import org.apache.skywalking.oap.server.core.query.type.BrowserErrorLogs;
import org.apache.skywalking.oap.server.library.module.ModuleManager;
-import static java.util.Objects.nonNull;
-
@RequiredArgsConstructor
public class BrowserLogQuery implements GraphQLQueryResolver {
private final ModuleManager moduleManager;
@@ -42,17 +40,10 @@ public class BrowserLogQuery implements GraphQLQueryResolver {
}
public BrowserErrorLogs queryBrowserErrorLogs(BrowserErrorLogQueryCondition condition) throws IOException {
- long startSecondTB = 0, endSecondTB = 0;
- if (nonNull(condition.getQueryDuration())) {
- startSecondTB = condition.getQueryDuration()
- .getStartTimeBucketInSec();
- endSecondTB = condition.getQueryDuration()
- .getEndTimeBucketInSec();
- }
return getQueryService().queryBrowserErrorLogs(
condition.getServiceId(), condition.getServiceVersionId(), condition.getPagePathId(),
- condition.getCategory(), startSecondTB, endSecondTB, condition.getPaging()
+ condition.getCategory(), condition.getQueryDuration(), condition.getPaging()
);
}
}
diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/LogQuery.java b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/LogQuery.java
index 4c0b132895..c45a617f8a 100644
--- a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/LogQuery.java
+++ b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/LogQuery.java
@@ -35,7 +35,6 @@ import org.apache.skywalking.oap.server.library.util.CollectionUtils;
import org.apache.skywalking.oap.server.library.util.StringUtil;
import static java.util.Objects.isNull;
-import static java.util.Objects.nonNull;
public class LogQuery implements GraphQLQueryResolver {
private final ModuleManager moduleManager;
@@ -68,12 +67,7 @@ public class LogQuery implements GraphQLQueryResolver {
if (isNull(condition.getQueryDuration()) && isNull(condition.getRelatedTrace())) {
throw new UnexpectedException("The condition must contains either queryDuration or relatedTrace.");
}
- long startSecondTB = 0;
- long endSecondTB = 0;
- if (nonNull(condition.getQueryDuration())) {
- startSecondTB = condition.getQueryDuration().getStartTimeBucketInSec();
- endSecondTB = condition.getQueryDuration().getEndTimeBucketInSec();
- }
+
Order queryOrder = isNull(condition.getQueryOrder()) ? Order.DES : condition.getQueryOrder();
if (CollectionUtils.isNotEmpty(condition.getTags())) {
condition.getTags().forEach(tag -> {
@@ -94,7 +88,7 @@ public class LogQuery implements GraphQLQueryResolver {
condition.getRelatedTrace(),
condition.getPaging(),
queryOrder,
- startSecondTB, endSecondTB,
+ condition.getQueryDuration(),
condition.getTags(),
condition.getKeywordsOfContent(),
condition.getExcludingKeywordsOfContent()
@@ -102,10 +96,10 @@ public class LogQuery implements GraphQLQueryResolver {
}
public Set<String> queryLogTagAutocompleteKeys(final Duration queryDuration) throws IOException {
- return getTagQueryService().queryTagAutocompleteKeys(TagType.LOG, queryDuration.getStartTimeBucketInSec(), queryDuration.getEndTimeBucketInSec());
+ return getTagQueryService().queryTagAutocompleteKeys(TagType.LOG, queryDuration);
}
public Set<String> queryLogTagAutocompleteValues(final String tagKey, final Duration queryDuration) throws IOException {
- return getTagQueryService().queryTagAutocompleteValues(TagType.LOG, tagKey, queryDuration.getStartTimeBucketInSec(), queryDuration.getEndTimeBucketInSec());
+ return getTagQueryService().queryTagAutocompleteValues(TagType.LOG, tagKey, queryDuration);
}
}
diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/MetadataQuery.java b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/MetadataQuery.java
index 498a6bd5af..b7e6904962 100644
--- a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/MetadataQuery.java
+++ b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/MetadataQuery.java
@@ -86,8 +86,7 @@ public class MetadataQuery implements GraphQLQueryResolver {
public List<ServiceInstance> getServiceInstances(final Duration duration,
final String serviceId) throws IOException {
- return getMetadataQueryService().listInstances(
- duration.getStartTimestamp(), duration.getEndTimestamp(), serviceId);
+ return getMetadataQueryService().listInstances(duration, serviceId);
}
public List<Endpoint> searchEndpoint(final String keyword, final String serviceId,
diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/MetadataQueryV2.java b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/MetadataQueryV2.java
index 6151c184d0..3d768d1791 100644
--- a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/MetadataQueryV2.java
+++ b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/MetadataQueryV2.java
@@ -77,8 +77,7 @@ public class MetadataQueryV2 implements GraphQLQueryResolver {
public List<ServiceInstance> listInstances(final Duration duration,
final String serviceId) throws IOException {
- return getMetadataQueryService().listInstances(
- duration.getStartTimestamp(), duration.getEndTimestamp(), serviceId);
+ return getMetadataQueryService().listInstances(duration, serviceId);
}
public ServiceInstance getInstance(final String instanceId) throws IOException {
diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/TopologyQuery.java b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/TopologyQuery.java
index 3840e0597d..8534985880 100644
--- a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/TopologyQuery.java
+++ b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/TopologyQuery.java
@@ -48,7 +48,7 @@ public class TopologyQuery implements GraphQLQueryResolver {
}
public Topology getGlobalTopology(final Duration duration) throws IOException {
- return getQueryService().getGlobalTopology(duration.getStartTimeBucket(), duration.getEndTimeBucket());
+ return getQueryService().getGlobalTopology(duration);
}
public Topology getServiceTopology(final String serviceId, final Duration duration) throws IOException {
@@ -58,8 +58,7 @@ public class TopologyQuery implements GraphQLQueryResolver {
}
public Topology getServicesTopology(final List<String> serviceIds, final Duration duration) throws IOException {
- return getQueryService().getServiceTopology(
- duration.getStartTimeBucket(), duration.getEndTimeBucket(), serviceIds);
+ return getQueryService().getServiceTopology(duration, serviceIds);
}
public ServiceInstanceTopology getServiceInstanceTopology(final String clientServiceId,
@@ -67,7 +66,7 @@ public class TopologyQuery implements GraphQLQueryResolver {
final Duration duration) throws IOException {
return getQueryService().getServiceInstanceTopology(
clientServiceId, serverServiceId,
- duration.getStartTimeBucket(), duration.getEndTimeBucket()
+ duration
);
}
@@ -76,17 +75,15 @@ public class TopologyQuery implements GraphQLQueryResolver {
*/
@Deprecated
public Topology getEndpointTopology(final String endpointId, final Duration duration) throws IOException {
- return getQueryService().getEndpointTopology(
- duration.getStartTimeBucket(), duration.getEndTimeBucket(), endpointId);
+ return getQueryService().getEndpointTopology(duration, endpointId);
}
public EndpointTopology getEndpointDependencies(final String endpointId,
final Duration duration) throws IOException {
- return getQueryService().getEndpointDependencies(
- duration.getStartTimeBucket(), duration.getEndTimeBucket(), endpointId);
+ return getQueryService().getEndpointDependencies(duration, endpointId);
}
public ProcessTopology getProcessTopology(final String instanceId, final Duration duration) throws IOException {
- return getQueryService().getProcessTopology(instanceId, duration.getStartTimeBucket(), duration.getEndTimeBucket());
+ return getQueryService().getProcessTopology(instanceId, duration);
}
}
diff --git a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/TraceQuery.java b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/TraceQuery.java
index 4f1202cf05..d8c4103762 100644
--- a/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/TraceQuery.java
+++ b/oap-server/server-query-plugin/query-graphql-plugin/src/main/java/org/apache/skywalking/oap/query/graphql/resolver/TraceQuery.java
@@ -37,7 +37,7 @@ import org.apache.skywalking.oap.server.core.query.type.TraceBrief;
import org.apache.skywalking.oap.server.core.query.type.TraceState;
import org.apache.skywalking.oap.server.library.module.ModuleManager;
-import static java.util.Objects.nonNull;
+import static java.util.Objects.isNull;
public class TraceQuery implements GraphQLQueryResolver {
@@ -64,16 +64,11 @@ public class TraceQuery implements GraphQLQueryResolver {
}
public TraceBrief queryBasicTraces(final TraceQueryCondition condition) throws IOException {
- long startSecondTB = 0;
- long endSecondTB = 0;
String traceId = Const.EMPTY_STRING;
if (!Strings.isNullOrEmpty(condition.getTraceId())) {
traceId = condition.getTraceId();
- } else if (nonNull(condition.getQueryDuration())) {
- startSecondTB = condition.getQueryDuration().getStartTimeBucketInSec();
- endSecondTB = condition.getQueryDuration().getEndTimeBucketInSec();
- } else {
+ } else if (isNull(condition.getQueryDuration())) {
throw new UnexpectedException("The condition must contains either queryDuration or traceId.");
}
@@ -86,7 +81,7 @@ public class TraceQuery implements GraphQLQueryResolver {
return getQueryService().queryBasicTraces(
condition.getServiceId(), condition.getServiceInstanceId(), endpointId, traceId, minDuration,
- maxDuration, traceState, queryOrder, pagination, startSecondTB, endSecondTB, condition.getTags()
+ maxDuration, traceState, queryOrder, pagination, condition.getQueryDuration(), condition.getTags()
);
}
@@ -95,10 +90,10 @@ public class TraceQuery implements GraphQLQueryResolver {
}
public Set<String> queryTraceTagAutocompleteKeys(final Duration queryDuration) throws IOException {
- return getTagQueryService().queryTagAutocompleteKeys(TagType.TRACE, queryDuration.getStartTimeBucketInSec(), queryDuration.getEndTimeBucketInSec());
+ return getTagQueryService().queryTagAutocompleteKeys(TagType.TRACE, queryDuration);
}
public Set<String> queryTraceTagAutocompleteValues(final String tagKey, final Duration queryDuration) throws IOException {
- return getTagQueryService().queryTagAutocompleteValues(TagType.TRACE, tagKey, queryDuration.getStartTimeBucketInSec(), queryDuration.getEndTimeBucketInSec());
+ return getTagQueryService().queryTagAutocompleteValues(TagType.TRACE, tagKey, queryDuration);
}
}
diff --git a/oap-server/server-query-plugin/zipkin-query-plugin/src/main/java/org/apache/skywalking/oap/query/zipkin/handler/ZipkinQueryExceptionHandler.java b/oap-server/server-query-plugin/zipkin-query-plugin/src/main/java/org/apache/skywalking/oap/query/zipkin/handler/ZipkinQueryExceptionHandler.java
index 7c1c71beae..c187d6e96f 100644
--- a/oap-server/server-query-plugin/zipkin-query-plugin/src/main/java/org/apache/skywalking/oap/query/zipkin/handler/ZipkinQueryExceptionHandler.java
+++ b/oap-server/server-query-plugin/zipkin-query-plugin/src/main/java/org/apache/skywalking/oap/query/zipkin/handler/ZipkinQueryExceptionHandler.java
@@ -22,19 +22,23 @@ import com.linecorp.armeria.common.HttpRequest;
import com.linecorp.armeria.common.HttpResponse;
import com.linecorp.armeria.server.ServiceRequestContext;
import com.linecorp.armeria.server.annotation.ExceptionHandlerFunction;
+import lombok.extern.slf4j.Slf4j;
import static com.linecorp.armeria.common.HttpStatus.BAD_REQUEST;
import static com.linecorp.armeria.common.HttpStatus.INTERNAL_SERVER_ERROR;
import static com.linecorp.armeria.common.MediaType.ANY_TEXT_TYPE;
+@Slf4j
public class ZipkinQueryExceptionHandler implements ExceptionHandlerFunction {
@Override
public HttpResponse handleException(final ServiceRequestContext ctx, final HttpRequest req, final Throwable cause) {
String rspMsg = cause.getMessage() != null ? cause.getMessage() : cause.getClass().getSimpleName();
// Response msg for illegal query args.
if (cause instanceof IllegalArgumentException) {
+ log.error(cause.getMessage(), cause);
return HttpResponse.of(BAD_REQUEST, ANY_TEXT_TYPE, rspMsg);
} else {
+ log.error(cause.getMessage(), cause);
return HttpResponse.of(INTERNAL_SERVER_ERROR, ANY_TEXT_TYPE, rspMsg);
}
}
diff --git a/oap-server/server-query-plugin/zipkin-query-plugin/src/main/java/org/apache/skywalking/oap/query/zipkin/handler/ZipkinQueryHandler.java b/oap-server/server-query-plugin/zipkin-query-plugin/src/main/java/org/apache/skywalking/oap/query/zipkin/handler/ZipkinQueryHandler.java
index 8ad88b3421..a507f6811d 100644
--- a/oap-server/server-query-plugin/zipkin-query-plugin/src/main/java/org/apache/skywalking/oap/query/zipkin/handler/ZipkinQueryHandler.java
+++ b/oap-server/server-query-plugin/zipkin-query-plugin/src/main/java/org/apache/skywalking/oap/query/zipkin/handler/ZipkinQueryHandler.java
@@ -42,16 +42,17 @@ import java.util.List;
import java.util.Optional;
import java.util.Set;
import org.apache.skywalking.oap.server.core.CoreModule;
-import org.apache.skywalking.oap.server.core.analysis.DownSampling;
-import org.apache.skywalking.oap.server.core.analysis.TimeBucket;
import org.apache.skywalking.oap.server.core.analysis.manual.searchtag.TagType;
import org.apache.skywalking.oap.server.core.query.TagAutoCompleteQueryService;
+import org.apache.skywalking.oap.server.core.query.enumeration.Step;
+import org.apache.skywalking.oap.server.core.query.input.Duration;
import org.apache.skywalking.oap.server.core.storage.StorageModule;
import org.apache.skywalking.oap.server.core.storage.query.IZipkinQueryDAO;
import org.apache.skywalking.oap.server.library.module.ModuleManager;
import org.apache.skywalking.oap.query.zipkin.ZipkinQueryConfig;
import org.apache.skywalking.oap.server.library.util.CollectionUtils;
import org.apache.skywalking.oap.server.library.util.StringUtil;
+import org.joda.time.DateTime;
import zipkin2.Span;
import zipkin2.codec.SpanBytesEncoder;
import zipkin2.storage.QueryRequest;
@@ -175,7 +176,13 @@ public class ZipkinQueryHandler {
.lookback(lookback.orElse(defaultLookback))
.limit(limit)
.build();
- List<List<Span>> traces = getZipkinQueryDAO().getTraces(queryRequest);
+ Duration duration = new Duration();
+ duration.setStep(Step.SECOND);
+ DateTime endTime = new DateTime(queryRequest.endTs());
+ DateTime startTime = endTime.minus(org.joda.time.Duration.millis(queryRequest.lookback()));
+ duration.setStart(startTime.toString("yyyy-MM-dd HHmmss"));
+ duration.setEnd(endTime.toString("yyyy-MM-dd HHmmss"));
+ List<List<Span>> traces = getZipkinQueryDAO().getTraces(queryRequest, duration);
return response(encodeTraces(traces));
}
@@ -201,26 +208,26 @@ public class ZipkinQueryHandler {
@Get("/api/v2/autocompleteKeys")
@Blocking
public AggregatedHttpResponse getAutocompleteKeys() throws IOException {
- long endTimeMillis = System.currentTimeMillis();
- long startTimeMillis = endTimeMillis - defaultLookback;
- Set<String> autocompleteKeys =
- getTagQueryService().queryTagAutocompleteKeys(
- TagType.ZIPKIN, TimeBucket.getTimeBucket(startTimeMillis, DownSampling.Second),
- TimeBucket.getTimeBucket(endTimeMillis, DownSampling.Second)
- );
+ Duration duration = new Duration();
+ duration.setStep(Step.SECOND);
+ DateTime endTime = DateTime.now();
+ DateTime startTime = endTime.minus(org.joda.time.Duration.millis(defaultLookback));
+ duration.setStart(startTime.toString("yyyy-MM-dd HHmmss"));
+ duration.setEnd(endTime.toString("yyyy-MM-dd HHmmss"));
+ Set<String> autocompleteKeys = getTagQueryService().queryTagAutocompleteKeys(TagType.ZIPKIN, duration);
return cachedResponse(true, new ArrayList<>(autocompleteKeys));
}
@Get("/api/v2/autocompleteValues")
@Blocking
public AggregatedHttpResponse getAutocompleteValues(@Param("key") String key) throws IOException {
- long endTimeMillis = System.currentTimeMillis();
- long startTimeMillis = endTimeMillis - defaultLookback;
- Set<String> autocompleteValues =
- getTagQueryService().queryTagAutocompleteValues(
- TagType.ZIPKIN, key, TimeBucket.getTimeBucket(startTimeMillis, DownSampling.Second),
- TimeBucket.getTimeBucket(endTimeMillis, DownSampling.Second)
- );
+ Duration duration = new Duration();
+ duration.setStep(Step.SECOND);
+ DateTime endTime = DateTime.now();
+ DateTime startTime = endTime.minus(org.joda.time.Duration.millis(defaultLookback));
+ duration.setStart(startTime.toString("yyyy-MM-dd HHmmss"));
+ duration.setEnd(endTime.toString("yyyy-MM-dd HHmmss"));
+ Set<String> autocompleteValues = getTagQueryService().queryTagAutocompleteValues(TagType.ZIPKIN, key, duration);
return cachedResponse(autocompleteValues.size() > 3, new ArrayList<>(autocompleteValues));
}
diff --git a/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/measure/BanyanDBMetadataQueryDAO.java b/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/measure/BanyanDBMetadataQueryDAO.java
index 71eb282d3c..e666929a76 100644
--- a/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/measure/BanyanDBMetadataQueryDAO.java
+++ b/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/measure/BanyanDBMetadataQueryDAO.java
@@ -36,6 +36,7 @@ import org.apache.skywalking.oap.server.core.analysis.manual.process.ProcessTraf
import org.apache.skywalking.oap.server.core.analysis.manual.service.ServiceTraffic;
import org.apache.skywalking.oap.server.core.query.enumeration.Language;
import org.apache.skywalking.oap.server.core.query.enumeration.ProfilingSupportStatus;
+import org.apache.skywalking.oap.server.core.query.input.Duration;
import org.apache.skywalking.oap.server.core.query.type.Attribute;
import org.apache.skywalking.oap.server.core.query.type.Endpoint;
import org.apache.skywalking.oap.server.core.query.type.Process;
@@ -133,7 +134,7 @@ public class BanyanDBMetadataQueryDAO extends AbstractBanyanDBDAO implements IMe
}
@Override
- public List<ServiceInstance> listInstances(long startTimestamp, long endTimestamp, String serviceId) throws IOException {
+ public List<ServiceInstance> listInstances(Duration duration, String serviceId) throws IOException {
MeasureQueryResponse resp = query(InstanceTraffic.INDEX_NAME,
INSTANCE_TRAFFIC_TAGS,
Collections.emptySet(),
@@ -143,7 +144,7 @@ public class BanyanDBMetadataQueryDAO extends AbstractBanyanDBDAO implements IMe
if (StringUtil.isNotEmpty(serviceId)) {
query.and(eq(InstanceTraffic.SERVICE_ID, serviceId));
}
- final long minuteTimeBucket = TimeBucket.getMinuteTimeBucket(startTimestamp);
+ final long minuteTimeBucket = TimeBucket.getMinuteTimeBucket(duration.getStartTimestamp());
query.and(gte(InstanceTraffic.LAST_PING_TIME_BUCKET, minuteTimeBucket));
}
});
@@ -225,7 +226,9 @@ public class BanyanDBMetadataQueryDAO extends AbstractBanyanDBDAO implements IMe
}
@Override
- public List<Process> listProcesses(String serviceInstanceId, long lastPingStartTimeBucket, long lastPingEndTimeBucket, boolean includeVirtual) throws IOException {
+ public List<Process> listProcesses(String serviceInstanceId, Duration duration, boolean includeVirtual) throws IOException {
+ long lastPingStartTimeBucket = duration.getStartTimeBucket();
+ long lastPingEndTimeBucket = duration.getEndTimeBucket();
MeasureQueryResponse resp = query(ProcessTraffic.INDEX_NAME,
PROCESS_TRAFFIC_TAGS,
Collections.emptySet(),
diff --git a/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/measure/BanyanDBTagAutocompleteQueryDAO.java b/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/measure/BanyanDBTagAutocompleteQueryDAO.java
index 2e330a64d7..fda0100830 100644
--- a/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/measure/BanyanDBTagAutocompleteQueryDAO.java
+++ b/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/measure/BanyanDBTagAutocompleteQueryDAO.java
@@ -26,6 +26,7 @@ import org.apache.skywalking.banyandb.v1.client.TimestampRange;
import org.apache.skywalking.oap.server.core.analysis.TimeBucket;
import org.apache.skywalking.oap.server.core.analysis.manual.searchtag.TagAutocompleteData;
import org.apache.skywalking.oap.server.core.analysis.manual.searchtag.TagType;
+import org.apache.skywalking.oap.server.core.query.input.Duration;
import org.apache.skywalking.oap.server.core.storage.query.ITagAutoCompleteQueryDAO;
import org.apache.skywalking.oap.server.storage.plugin.banyandb.BanyanDBStorageClient;
import org.apache.skywalking.oap.server.storage.plugin.banyandb.stream.AbstractBanyanDBDAO;
@@ -35,6 +36,8 @@ import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
+import static java.util.Objects.nonNull;
+
public class BanyanDBTagAutocompleteQueryDAO extends AbstractBanyanDBDAO implements ITagAutoCompleteQueryDAO {
private static final Set<String> TAGS_KEY = ImmutableSet.of(TagAutocompleteData.TAG_TYPE,
TagAutocompleteData.TAG_KEY);
@@ -47,10 +50,16 @@ public class BanyanDBTagAutocompleteQueryDAO extends AbstractBanyanDBDAO impleme
}
@Override
- public Set<String> queryTagAutocompleteKeys(TagType tagType, int limit, long startSecondTB, long endSecondTB) throws IOException {
+ public Set<String> queryTagAutocompleteKeys(TagType tagType, int limit, Duration duration) throws IOException {
+ long startTB = 0;
+ long endTB = 0;
+ if (nonNull(duration)) {
+ startTB = TimeBucket.getMinuteTimeBucket(duration.getStartTimestamp());
+ endTB = TimeBucket.getMinuteTimeBucket(duration.getEndTimestamp());
+ }
TimestampRange range = null;
- if (startSecondTB > 0 && endSecondTB > 0) {
- range = new TimestampRange(TimeBucket.getTimestamp(startSecondTB), TimeBucket.getTimestamp(endSecondTB));
+ if (startTB > 0 && endTB > 0) {
+ range = new TimestampRange(TimeBucket.getTimestamp(startTB), TimeBucket.getTimestamp(endTB));
}
MeasureQueryResponse resp = query(TagAutocompleteData.INDEX_NAME,
TAGS_KEY, Collections.emptySet(),
@@ -77,10 +86,20 @@ public class BanyanDBTagAutocompleteQueryDAO extends AbstractBanyanDBDAO impleme
}
@Override
- public Set<String> queryTagAutocompleteValues(TagType tagType, String tagKey, int limit, long startSecondTB, long endSecondTB) throws IOException {
+ public Set<String> queryTagAutocompleteValues(TagType tagType, String tagKey, int limit, Duration duration) throws IOException {
+ long startSecondTB = 0;
+ long endSecondTB = 0;
+ if (nonNull(duration)) {
+ startSecondTB = duration.getStartTimeBucketInSec();
+ endSecondTB = duration.getEndTimeBucketInSec();
+ }
+
+ long startTB = startSecondTB / 1000000 * 10000;
+ long endTB = endSecondTB / 1000000 * 10000 + 2359;
+
TimestampRange range = null;
- if (startSecondTB > 0 && endSecondTB > 0) {
- range = new TimestampRange(TimeBucket.getTimestamp(startSecondTB), TimeBucket.getTimestamp(endSecondTB));
+ if (startTB > 0 && endTB > 0) {
+ range = new TimestampRange(TimeBucket.getTimestamp(startTB), TimeBucket.getTimestamp(endTB));
}
MeasureQueryResponse resp = query(TagAutocompleteData.INDEX_NAME,
TAGS_KV, Collections.emptySet(),
diff --git a/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/measure/BanyanDBTopologyQueryDAO.java b/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/measure/BanyanDBTopologyQueryDAO.java
index 71eb23c601..5190ac43be 100644
--- a/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/measure/BanyanDBTopologyQueryDAO.java
+++ b/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/measure/BanyanDBTopologyQueryDAO.java
@@ -32,6 +32,7 @@ import org.apache.skywalking.oap.server.core.analysis.manual.relation.process.Pr
import org.apache.skywalking.oap.server.core.analysis.manual.relation.service.ServiceRelationClientSideMetrics;
import org.apache.skywalking.oap.server.core.analysis.manual.relation.service.ServiceRelationServerSideMetrics;
import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics;
+import org.apache.skywalking.oap.server.core.query.input.Duration;
import org.apache.skywalking.oap.server.core.query.type.Call;
import org.apache.skywalking.oap.server.core.source.DetectPoint;
import org.apache.skywalking.oap.server.core.storage.query.ITopologyQueryDAO;
@@ -47,6 +48,8 @@ import org.apache.skywalking.oap.server.library.util.CollectionUtils;
import org.apache.skywalking.oap.server.storage.plugin.banyandb.BanyanDBStorageClient;
import org.apache.skywalking.oap.server.storage.plugin.banyandb.stream.AbstractBanyanDBDAO;
+import static java.util.Objects.nonNull;
+
public class BanyanDBTopologyQueryDAO extends AbstractBanyanDBDAO implements ITopologyQueryDAO {
public BanyanDBTopologyQueryDAO(final BanyanDBStorageClient client) {
@@ -54,35 +57,35 @@ public class BanyanDBTopologyQueryDAO extends AbstractBanyanDBDAO implements ITo
}
@Override
- public List<Call.CallDetail> loadServiceRelationsDetectedAtServerSide(long startTB, long endTB, List<String> serviceIds) throws IOException {
+ public List<Call.CallDetail> loadServiceRelationsDetectedAtServerSide(Duration duration, List<String> serviceIds) throws IOException {
if (CollectionUtils.isEmpty(serviceIds)) {
throw new UnexpectedException("Service id is empty");
}
List<QueryBuilder<MeasureQuery>> queryBuilderList = buildServiceRelationsQueries(serviceIds);
- return queryServiceRelation(startTB, endTB, queryBuilderList, DetectPoint.SERVER);
+ return queryServiceRelation(duration, queryBuilderList, DetectPoint.SERVER);
}
@Override
- public List<Call.CallDetail> loadServiceRelationDetectedAtClientSide(long startTB, long endTB, List<String> serviceIds) throws IOException {
+ public List<Call.CallDetail> loadServiceRelationDetectedAtClientSide(Duration duration, List<String> serviceIds) throws IOException {
if (CollectionUtils.isEmpty(serviceIds)) {
throw new UnexpectedException("Service id is empty");
}
List<QueryBuilder<MeasureQuery>> queryBuilderList = buildServiceRelationsQueries(serviceIds);
- return queryServiceRelation(startTB, endTB, queryBuilderList, DetectPoint.CLIENT);
+ return queryServiceRelation(duration, queryBuilderList, DetectPoint.CLIENT);
}
@Override
- public List<Call.CallDetail> loadServiceRelationsDetectedAtServerSide(long startTB, long endTB) throws IOException {
- return queryServiceRelation(startTB, endTB, Collections.singletonList(emptyMeasureQuery()), DetectPoint.SERVER);
+ public List<Call.CallDetail> loadServiceRelationsDetectedAtServerSide(Duration duration) throws IOException {
+ return queryServiceRelation(duration, Collections.singletonList(emptyMeasureQuery()), DetectPoint.SERVER);
}
@Override
- public List<Call.CallDetail> loadServiceRelationDetectedAtClientSide(long startTB, long endTB) throws IOException {
- return queryServiceRelation(startTB, endTB, Collections.singletonList(emptyMeasureQuery()), DetectPoint.CLIENT);
+ public List<Call.CallDetail> loadServiceRelationDetectedAtClientSide(Duration duration) throws IOException {
+ return queryServiceRelation(duration, Collections.singletonList(emptyMeasureQuery()), DetectPoint.CLIENT);
}
private List<QueryBuilder<MeasureQuery>> buildServiceRelationsQueries(List<String> serviceIds) {
@@ -105,7 +108,13 @@ public class BanyanDBTopologyQueryDAO extends AbstractBanyanDBDAO implements ITo
return queryBuilderList;
}
- List<Call.CallDetail> queryServiceRelation(long startTB, long endTB, List<QueryBuilder<MeasureQuery>> queryBuilderList, DetectPoint detectPoint) throws IOException {
+ List<Call.CallDetail> queryServiceRelation(Duration duration, List<QueryBuilder<MeasureQuery>> queryBuilderList, DetectPoint detectPoint) throws IOException {
+ long startTB = 0;
+ long endTB = 0;
+ if (nonNull(duration)) {
+ startTB = duration.getStartTimeBucketInSec();
+ endTB = duration.getEndTimeBucketInSec();
+ }
TimestampRange timestampRange = null;
if (startTB > 0 && endTB > 0) {
timestampRange = new TimestampRange(TimeBucket.getTimestamp(startTB), TimeBucket.getTimestamp(endTB));
@@ -133,15 +142,15 @@ public class BanyanDBTopologyQueryDAO extends AbstractBanyanDBDAO implements ITo
}
@Override
- public List<Call.CallDetail> loadInstanceRelationDetectedAtServerSide(String clientServiceId, String serverServiceId, long startTB, long endTB) throws IOException {
+ public List<Call.CallDetail> loadInstanceRelationDetectedAtServerSide(String clientServiceId, String serverServiceId, Duration duration) throws IOException {
List<QueryBuilder<MeasureQuery>> queryBuilderList = buildInstanceRelationsQueries(clientServiceId, serverServiceId);
- return queryInstanceRelation(startTB, endTB, queryBuilderList, DetectPoint.SERVER);
+ return queryInstanceRelation(duration, queryBuilderList, DetectPoint.SERVER);
}
@Override
- public List<Call.CallDetail> loadInstanceRelationDetectedAtClientSide(String clientServiceId, String serverServiceId, long startTB, long endTB) throws IOException {
+ public List<Call.CallDetail> loadInstanceRelationDetectedAtClientSide(String clientServiceId, String serverServiceId, Duration duration) throws IOException {
List<QueryBuilder<MeasureQuery>> queryBuilderList = buildInstanceRelationsQueries(clientServiceId, serverServiceId);
- return queryInstanceRelation(startTB, endTB, queryBuilderList, DetectPoint.CLIENT);
+ return queryInstanceRelation(duration, queryBuilderList, DetectPoint.CLIENT);
}
private List<QueryBuilder<MeasureQuery>> buildInstanceRelationsQueries(String clientServiceId, String serverServiceId) {
@@ -164,7 +173,13 @@ public class BanyanDBTopologyQueryDAO extends AbstractBanyanDBDAO implements ITo
return queryBuilderList;
}
- List<Call.CallDetail> queryInstanceRelation(long startTB, long endTB, List<QueryBuilder<MeasureQuery>> queryBuilderList, DetectPoint detectPoint) throws IOException {
+ List<Call.CallDetail> queryInstanceRelation(Duration duration, List<QueryBuilder<MeasureQuery>> queryBuilderList, DetectPoint detectPoint) throws IOException {
+ long startTB = 0;
+ long endTB = 0;
+ if (nonNull(duration)) {
+ startTB = duration.getStartTimeBucketInSec();
+ endTB = duration.getEndTimeBucketInSec();
+ }
TimestampRange timestampRange = null;
if (startTB > 0 && endTB > 0) {
timestampRange = new TimestampRange(TimeBucket.getTimestamp(startTB), TimeBucket.getTimestamp(endTB));
@@ -192,19 +207,19 @@ public class BanyanDBTopologyQueryDAO extends AbstractBanyanDBDAO implements ITo
}
@Override
- public List<Call.CallDetail> loadEndpointRelation(long startTB, long endTB, String destEndpointId) throws IOException {
+ public List<Call.CallDetail> loadEndpointRelation(Duration duration, String destEndpointId) throws IOException {
List<QueryBuilder<MeasureQuery>> queryBuilderList = buildEndpointRelationsQueries(destEndpointId);
- return queryEndpointRelation(startTB, endTB, queryBuilderList, DetectPoint.SERVER);
+ return queryEndpointRelation(duration, queryBuilderList, DetectPoint.SERVER);
}
@Override
- public List<Call.CallDetail> loadProcessRelationDetectedAtClientSide(String serviceInstanceId, long startTB, long endTB) throws IOException {
- return queryProcessRelation(startTB, endTB, serviceInstanceId, DetectPoint.CLIENT);
+ public List<Call.CallDetail> loadProcessRelationDetectedAtClientSide(String serviceInstanceId, Duration duration) throws IOException {
+ return queryProcessRelation(duration, serviceInstanceId, DetectPoint.CLIENT);
}
@Override
- public List<Call.CallDetail> loadProcessRelationDetectedAtServerSide(String serviceInstanceId, long startTB, long endTB) throws IOException {
- return queryProcessRelation(startTB, endTB, serviceInstanceId, DetectPoint.SERVER);
+ public List<Call.CallDetail> loadProcessRelationDetectedAtServerSide(String serviceInstanceId, Duration duration) throws IOException {
+ return queryProcessRelation(duration, serviceInstanceId, DetectPoint.SERVER);
}
private List<QueryBuilder<MeasureQuery>> buildEndpointRelationsQueries(String destEndpointId) {
@@ -225,7 +240,13 @@ public class BanyanDBTopologyQueryDAO extends AbstractBanyanDBDAO implements ITo
return queryBuilderList;
}
- List<Call.CallDetail> queryEndpointRelation(long startTB, long endTB, List<QueryBuilder<MeasureQuery>> queryBuilderList, DetectPoint detectPoint) throws IOException {
+ List<Call.CallDetail> queryEndpointRelation(Duration duration, List<QueryBuilder<MeasureQuery>> queryBuilderList, DetectPoint detectPoint) throws IOException {
+ long startTB = 0;
+ long endTB = 0;
+ if (nonNull(duration)) {
+ startTB = duration.getStartTimeBucketInSec();
+ endTB = duration.getEndTimeBucketInSec();
+ }
TimestampRange timestampRange = null;
if (startTB > 0 && endTB > 0) {
timestampRange = new TimestampRange(TimeBucket.getTimestamp(startTB), TimeBucket.getTimestamp(endTB));
@@ -248,7 +269,13 @@ public class BanyanDBTopologyQueryDAO extends AbstractBanyanDBDAO implements ITo
return new ArrayList<>(callMap.values());
}
- List<Call.CallDetail> queryProcessRelation(long startTB, long endTB, String serviceInstanceId, DetectPoint detectPoint) throws IOException {
+ List<Call.CallDetail> queryProcessRelation(Duration duration, String serviceInstanceId, DetectPoint detectPoint) throws IOException {
+ long startTB = 0;
+ long endTB = 0;
+ if (nonNull(duration)) {
+ startTB = duration.getStartTimeBucketInSec();
+ endTB = duration.getEndTimeBucketInSec();
+ }
TimestampRange timestampRange = null;
if (startTB > 0 && endTB > 0) {
timestampRange = new TimestampRange(TimeBucket.getTimestamp(startTB), TimeBucket.getTimestamp(endTB));
diff --git a/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/stream/BanyanDBAlarmQueryDAO.java b/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/stream/BanyanDBAlarmQueryDAO.java
index 277f00f558..812f6f84af 100644
--- a/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/stream/BanyanDBAlarmQueryDAO.java
+++ b/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/stream/BanyanDBAlarmQueryDAO.java
@@ -27,6 +27,7 @@ import org.apache.skywalking.oap.server.core.alarm.AlarmRecord;
import org.apache.skywalking.oap.server.core.analysis.TimeBucket;
import org.apache.skywalking.oap.server.core.analysis.manual.searchtag.Tag;
import org.apache.skywalking.oap.server.core.query.enumeration.Scope;
+import org.apache.skywalking.oap.server.core.query.input.Duration;
import org.apache.skywalking.oap.server.core.query.type.AlarmMessage;
import org.apache.skywalking.oap.server.core.query.type.Alarms;
import org.apache.skywalking.oap.server.core.storage.query.IAlarmQueryDAO;
@@ -54,7 +55,9 @@ public class BanyanDBAlarmQueryDAO extends AbstractBanyanDBDAO implements IAlarm
}
@Override
- public Alarms getAlarm(Integer scopeId, String keyword, int limit, int from, long startTB, long endTB, List<Tag> tags) throws IOException {
+ public Alarms getAlarm(Integer scopeId, String keyword, int limit, int from, Duration duration, List<Tag> tags) throws IOException {
+ long startTB = duration.getStartTimeBucketInSec();
+ long endTB = duration.getEndTimeBucketInSec();
TimestampRange tsRange = null;
if (startTB > 0 && endTB > 0) {
tsRange = new TimestampRange(TimeBucket.getTimestamp(startTB), TimeBucket.getTimestamp(endTB));
diff --git a/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/stream/BanyanDBBrowserLogQueryDAO.java b/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/stream/BanyanDBBrowserLogQueryDAO.java
index 5d11ec835e..2ac1be38c7 100644
--- a/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/stream/BanyanDBBrowserLogQueryDAO.java
+++ b/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/stream/BanyanDBBrowserLogQueryDAO.java
@@ -27,6 +27,7 @@ import org.apache.skywalking.banyandb.v1.client.TimestampRange;
import org.apache.skywalking.oap.server.core.analysis.TimeBucket;
import org.apache.skywalking.oap.server.core.browser.manual.errorlog.BrowserErrorLogRecord;
import org.apache.skywalking.oap.server.core.browser.source.BrowserErrorCategory;
+import org.apache.skywalking.oap.server.core.query.input.Duration;
import org.apache.skywalking.oap.server.core.query.type.BrowserErrorLog;
import org.apache.skywalking.oap.server.core.query.type.BrowserErrorLogs;
import org.apache.skywalking.oap.server.core.query.type.ErrorCategory;
@@ -51,7 +52,11 @@ public class BanyanDBBrowserLogQueryDAO extends AbstractBanyanDBDAO implements I
}
@Override
- public BrowserErrorLogs queryBrowserErrorLogs(String serviceId, String serviceVersionId, String pagePathId, BrowserErrorCategory category, long startSecondTB, long endSecondTB, int limit, int from) throws IOException {
+ public BrowserErrorLogs queryBrowserErrorLogs(String serviceId, String serviceVersionId, String pagePathId,
+ BrowserErrorCategory category, Duration duration,
+ int limit, int from) throws IOException {
+ long startSecondTB = duration.getStartTimeBucketInSec();
+ long endSecondTB = duration.getEndTimeBucketInSec();
TimestampRange tsRange = null;
if (startSecondTB > 0 && endSecondTB > 0) {
tsRange = new TimestampRange(TimeBucket.getTimestamp(startSecondTB), TimeBucket.getTimestamp(endSecondTB));
diff --git a/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/stream/BanyanDBLogQueryDAO.java b/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/stream/BanyanDBLogQueryDAO.java
index 6b46ce44a7..6c3c9d35de 100644
--- a/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/stream/BanyanDBLogQueryDAO.java
+++ b/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/stream/BanyanDBLogQueryDAO.java
@@ -31,6 +31,7 @@ import org.apache.skywalking.oap.server.core.analysis.manual.log.AbstractLogReco
import org.apache.skywalking.oap.server.core.analysis.manual.log.LogRecord;
import org.apache.skywalking.oap.server.core.analysis.manual.searchtag.Tag;
import org.apache.skywalking.oap.server.core.query.enumeration.Order;
+import org.apache.skywalking.oap.server.core.query.input.Duration;
import org.apache.skywalking.oap.server.core.query.input.TraceScopeCondition;
import org.apache.skywalking.oap.server.core.query.type.ContentType;
import org.apache.skywalking.oap.server.core.query.type.KeyValue;
@@ -47,6 +48,8 @@ import java.util.List;
import java.util.Objects;
import java.util.Set;
+import static java.util.Objects.nonNull;
+
/**
* {@link org.apache.skywalking.oap.server.core.analysis.manual.log.LogRecord} is a stream
*/
@@ -70,8 +73,14 @@ public class BanyanDBLogQueryDAO extends AbstractBanyanDBDAO implements ILogQuer
@Override
public Logs queryLogs(String serviceId, String serviceInstanceId, String endpointId,
TraceScopeCondition relatedTrace, Order queryOrder, int from, int limit,
- long startTB, long endTB, List<Tag> tags, List<String> keywordsOfContent,
+ Duration duration, List<Tag> tags, List<String> keywordsOfContent,
List<String> excludingKeywordsOfContent) throws IOException {
+ long startTB = 0;
+ long endTB = 0;
+ if (nonNull(duration)) {
+ startTB = duration.getStartTimeBucketInSec();
+ endTB = duration.getEndTimeBucketInSec();
+ }
final QueryBuilder<StreamQuery> query = new QueryBuilder<StreamQuery>() {
@Override
public void apply(StreamQuery query) {
diff --git a/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/stream/BanyanDBTraceQueryDAO.java b/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/stream/BanyanDBTraceQueryDAO.java
index 357c73c1b5..5b6540a244 100644
--- a/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/stream/BanyanDBTraceQueryDAO.java
+++ b/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/stream/BanyanDBTraceQueryDAO.java
@@ -28,6 +28,7 @@ import org.apache.skywalking.oap.server.core.analysis.IDManager;
import org.apache.skywalking.oap.server.core.analysis.TimeBucket;
import org.apache.skywalking.oap.server.core.analysis.manual.searchtag.Tag;
import org.apache.skywalking.oap.server.core.analysis.manual.segment.SegmentRecord;
+import org.apache.skywalking.oap.server.core.query.input.Duration;
import org.apache.skywalking.oap.server.core.query.type.BasicTrace;
import org.apache.skywalking.oap.server.core.query.type.QueryOrder;
import org.apache.skywalking.oap.server.core.query.type.Span;
@@ -46,6 +47,8 @@ import java.util.Collections;
import java.util.List;
import java.util.Set;
+import static java.util.Objects.nonNull;
+
public class BanyanDBTraceQueryDAO extends AbstractBanyanDBDAO implements ITraceQueryDAO {
private static final Set<String> BASIC_TAGS = ImmutableSet.of(SegmentRecord.TRACE_ID,
SegmentRecord.IS_ERROR,
@@ -72,7 +75,13 @@ public class BanyanDBTraceQueryDAO extends AbstractBanyanDBDAO implements ITrace
}
@Override
- public TraceBrief queryBasicTraces(long startSecondTB, long endSecondTB, long minDuration, long maxDuration, String serviceId, String serviceInstanceId, String endpointId, String traceId, int limit, int from, TraceState traceState, QueryOrder queryOrder, List<Tag> tags) throws IOException {
+ public TraceBrief queryBasicTraces(Duration duration, long minDuration, long maxDuration, String serviceId, String serviceInstanceId, String endpointId, String traceId, int limit, int from, TraceState traceState, QueryOrder queryOrder, List<Tag> tags) throws IOException {
+ long startSecondTB = 0;
+ long endSecondTB = 0;
+ if (nonNull(duration)) {
+ startSecondTB = duration.getStartTimeBucketInSec();
+ endSecondTB = duration.getEndTimeBucketInSec();
+ }
final QueryBuilder<StreamQuery> q = new QueryBuilder<StreamQuery>() {
@Override
public void apply(StreamQuery query) {
diff --git a/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/stream/BanyanDBZipkinQueryDAO.java b/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/stream/BanyanDBZipkinQueryDAO.java
index 2a3b7ba221..9da423e02d 100644
--- a/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/stream/BanyanDBZipkinQueryDAO.java
+++ b/oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/stream/BanyanDBZipkinQueryDAO.java
@@ -22,6 +22,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
+import org.apache.skywalking.oap.server.core.query.input.Duration;
import org.apache.skywalking.oap.server.core.storage.query.IZipkinQueryDAO;
import org.apache.skywalking.oap.server.storage.plugin.banyandb.BanyanDBStorageClient;
import zipkin2.Span;
@@ -55,7 +56,7 @@ public class BanyanDBZipkinQueryDAO extends AbstractBanyanDBDAO implements IZipk
}
@Override
- public List<List<Span>> getTraces(final QueryRequest request) throws IOException {
+ public List<List<Span>> getTraces(final QueryRequest request, Duration duration) throws IOException {
return new ArrayList<>();
}
diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/AlarmQueryEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/AlarmQueryEsDAO.java
index c25617ddad..6a02976088 100644
--- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/AlarmQueryEsDAO.java
+++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/AlarmQueryEsDAO.java
@@ -32,6 +32,7 @@ import org.apache.skywalking.library.elasticsearch.response.search.SearchRespons
import org.apache.skywalking.oap.server.core.alarm.AlarmRecord;
import org.apache.skywalking.oap.server.core.analysis.manual.searchtag.Tag;
import org.apache.skywalking.oap.server.core.query.enumeration.Scope;
+import org.apache.skywalking.oap.server.core.query.input.Duration;
import org.apache.skywalking.oap.server.core.query.type.AlarmMessage;
import org.apache.skywalking.oap.server.core.query.type.Alarms;
import org.apache.skywalking.oap.server.core.storage.query.IAlarmQueryDAO;
@@ -51,8 +52,11 @@ public class AlarmQueryEsDAO extends EsDAO implements IAlarmQueryDAO {
@Override
public Alarms getAlarm(final Integer scopeId, final String keyword, final int limit,
final int from,
- final long startTB, final long endTB, final List<Tag> tags)
+ final Duration duration,
+ final List<Tag> tags)
throws IOException {
+ long startTB = duration.getStartTimeBucketInSec();
+ long endTB = duration.getEndTimeBucketInSec();
final String index =
IndexController.LogicIndicesRegister.getPhysicalTableName(AlarmRecord.INDEX_NAME);
final BoolQueryBuilder query = Query.bool();
diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/BrowserLogQueryEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/BrowserLogQueryEsDAO.java
index 6d8d1c3f89..1a0b1188a1 100644
--- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/BrowserLogQueryEsDAO.java
+++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/BrowserLogQueryEsDAO.java
@@ -18,6 +18,7 @@
package org.apache.skywalking.oap.server.storage.plugin.elasticsearch.query;
import java.io.IOException;
+import org.apache.skywalking.oap.server.core.query.input.Duration;
import org.apache.skywalking.oap.server.library.util.StringUtil;
import org.apache.skywalking.library.elasticsearch.requests.search.BoolQueryBuilder;
import org.apache.skywalking.library.elasticsearch.requests.search.Query;
@@ -47,10 +48,14 @@ public class BrowserLogQueryEsDAO extends EsDAO implements IBrowserLogQueryDAO {
final String serviceVersionId,
final String pagePathId,
final BrowserErrorCategory category,
- final long startSecondTB,
- final long endSecondTB,
+ final Duration duration,
final int limit,
final int from) throws IOException {
+ long startSecondTB = 0, endSecondTB = 0;
+ if (nonNull(duration)) {
+ startSecondTB = duration.getStartTimeBucketInSec();
+ endSecondTB = duration.getEndTimeBucketInSec();
+ }
final BoolQueryBuilder boolQueryBuilder = Query.bool();
if (IndexController.LogicIndicesRegister.isPhysicalTable(BrowserErrorLogRecord.INDEX_NAME)) {
boolQueryBuilder.must(Query.term(IndexController.LogicIndicesRegister.RECORD_TABLE_NAME, BrowserErrorLogRecord.INDEX_NAME));
diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/LogQueryEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/LogQueryEsDAO.java
index 5a8ec07ac5..7592e09a3b 100644
--- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/LogQueryEsDAO.java
+++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/LogQueryEsDAO.java
@@ -34,6 +34,7 @@ import org.apache.skywalking.oap.server.core.analysis.manual.log.LogRecord;
import org.apache.skywalking.oap.server.core.analysis.manual.searchtag.Tag;
import org.apache.skywalking.oap.server.core.analysis.record.Record;
import org.apache.skywalking.oap.server.core.query.enumeration.Order;
+import org.apache.skywalking.oap.server.core.query.input.Duration;
import org.apache.skywalking.oap.server.core.query.input.TraceScopeCondition;
import org.apache.skywalking.oap.server.core.query.type.ContentType;
import org.apache.skywalking.oap.server.core.query.type.Log;
@@ -67,11 +68,16 @@ public class LogQueryEsDAO extends EsDAO implements ILogQueryDAO {
final Order queryOrder,
final int from,
final int limit,
- final long startSecondTB,
- final long endSecondTB,
+ final Duration duration,
final List<Tag> tags,
final List<String> keywordsOfContent,
final List<String> excludingKeywordsOfContent) throws IOException {
+ long startSecondTB = 0;
+ long endSecondTB = 0;
+ if (nonNull(duration)) {
+ startSecondTB = duration.getStartTimeBucketInSec();
+ endSecondTB = duration.getEndTimeBucketInSec();
+ }
final BoolQueryBuilder query = Query.bool();
if (IndexController.LogicIndicesRegister.isPhysicalTable(LogRecord.INDEX_NAME)) {
query.must(Query.term(IndexController.LogicIndicesRegister.RECORD_TABLE_NAME, LogRecord.INDEX_NAME));
diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetadataQueryEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetadataQueryEsDAO.java
index e491045250..010d0c16cb 100644
--- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetadataQueryEsDAO.java
+++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/MetadataQueryEsDAO.java
@@ -47,6 +47,7 @@ import org.apache.skywalking.oap.server.core.analysis.manual.process.ProcessTraf
import org.apache.skywalking.oap.server.core.analysis.manual.service.ServiceTraffic;
import org.apache.skywalking.oap.server.core.query.enumeration.Language;
import org.apache.skywalking.oap.server.core.query.enumeration.ProfilingSupportStatus;
+import org.apache.skywalking.oap.server.core.query.input.Duration;
import org.apache.skywalking.oap.server.core.query.type.Attribute;
import org.apache.skywalking.oap.server.core.query.type.Endpoint;
import org.apache.skywalking.oap.server.core.query.type.Process;
@@ -145,12 +146,12 @@ public class MetadataQueryEsDAO extends EsDAO implements IMetadataQueryDAO {
}
@Override
- public List<ServiceInstance> listInstances(long startTimestamp, long endTimestamp,
+ public List<ServiceInstance> listInstances(Duration duration,
String serviceId) throws IOException {
final String index =
IndexController.LogicIndicesRegister.getPhysicalTableName(InstanceTraffic.INDEX_NAME);
- final long minuteTimeBucket = TimeBucket.getMinuteTimeBucket(startTimestamp);
+ final long minuteTimeBucket = TimeBucket.getMinuteTimeBucket(duration.getStartTimestamp());
final BoolQueryBuilder query =
Query.bool()
.must(Query.range(InstanceTraffic.LAST_PING_TIME_BUCKET).gte(minuteTimeBucket))
@@ -252,7 +253,9 @@ public class MetadataQueryEsDAO extends EsDAO implements IMetadataQueryDAO {
}
@Override
- public List<Process> listProcesses(String serviceInstanceId, long lastPingStartTimeBucket, long lastPingEndTimeBucket, boolean includeVirtual) throws IOException {
+ public List<Process> listProcesses(String serviceInstanceId, Duration duration, boolean includeVirtual) throws IOException {
+ long lastPingStartTimeBucket = duration.getStartTimeBucket();
+ long lastPingEndTimeBucket = duration.getEndTimeBucket();
final String index =
IndexController.LogicIndicesRegister.getPhysicalTableName(ProcessTraffic.INDEX_NAME);
diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/TagAutoCompleteQueryDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/TagAutoCompleteQueryDAO.java
index 69e36d21f4..366d15958c 100644
--- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/TagAutoCompleteQueryDAO.java
+++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/TagAutoCompleteQueryDAO.java
@@ -32,6 +32,7 @@ import org.apache.skywalking.library.elasticsearch.response.search.SearchHit;
import org.apache.skywalking.library.elasticsearch.response.search.SearchResponse;
import org.apache.skywalking.oap.server.core.analysis.manual.searchtag.TagAutocompleteData;
import org.apache.skywalking.oap.server.core.analysis.manual.searchtag.TagType;
+import org.apache.skywalking.oap.server.core.query.input.Duration;
import org.apache.skywalking.oap.server.core.storage.query.ITagAutoCompleteQueryDAO;
import org.apache.skywalking.oap.server.library.client.elasticsearch.ElasticSearchClient;
import org.apache.skywalking.oap.server.library.util.StringUtil;
@@ -40,6 +41,8 @@ import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base.EsDAO;
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base.IndexController;
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base.TimeRangeIndexNameGenerator;
+import static java.util.Objects.nonNull;
+
public class TagAutoCompleteQueryDAO extends EsDAO implements ITagAutoCompleteQueryDAO {
public TagAutoCompleteQueryDAO(ElasticSearchClient client) {
super(client);
@@ -48,8 +51,15 @@ public class TagAutoCompleteQueryDAO extends EsDAO implements ITagAutoCompleteQu
@Override
public Set<String> queryTagAutocompleteKeys(final TagType tagType,
final int limit,
- final long startSecondTB,
- final long endSecondTB) throws IOException {
+ final Duration duration) throws IOException {
+ // Tags combine records by day and es rolling index by day, need search the whole day
+ // just use the time to locate the physical indexes and ignore time conditions.
+ long startSecondTB = 0;
+ long endSecondTB = 0;
+ if (nonNull(duration)) {
+ startSecondTB = duration.getStartTimeBucketInSec();
+ endSecondTB = duration.getEndTimeBucketInSec();
+ }
BoolQueryBuilder query = Query.bool();
query.must(Query.term(TagAutocompleteData.TAG_TYPE, tagType.name()));
if (IndexController.LogicIndicesRegister.isPhysicalTable(TagAutocompleteData.INDEX_NAME)) {
@@ -84,8 +94,13 @@ public class TagAutoCompleteQueryDAO extends EsDAO implements ITagAutoCompleteQu
@Override
public Set<String> queryTagAutocompleteValues(final TagType tagType, final String tagKey,
final int limit,
- final long startSecondTB,
- final long endSecondTB) throws IOException {
+ final Duration duration) throws IOException {
+ long startSecondTB = 0;
+ long endSecondTB = 0;
+ if (nonNull(duration)) {
+ startSecondTB = duration.getStartTimeBucketInSec();
+ endSecondTB = duration.getEndTimeBucketInSec();
+ }
BoolQueryBuilder query = Query.bool().must(Query.term(TagAutocompleteData.TAG_KEY, tagKey));
query.must(Query.term(TagAutocompleteData.TAG_TYPE, tagType.name()));
if (IndexController.LogicIndicesRegister.isPhysicalTable(TagAutocompleteData.INDEX_NAME)) {
diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/TopologyQueryEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/TopologyQueryEsDAO.java
index 1bd7fdb8bd..d69c830206 100644
--- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/TopologyQueryEsDAO.java
+++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/TopologyQueryEsDAO.java
@@ -38,6 +38,7 @@ import org.apache.skywalking.oap.server.core.analysis.manual.relation.process.Pr
import org.apache.skywalking.oap.server.core.analysis.manual.relation.service.ServiceRelationClientSideMetrics;
import org.apache.skywalking.oap.server.core.analysis.manual.relation.service.ServiceRelationServerSideMetrics;
import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics;
+import org.apache.skywalking.oap.server.core.query.input.Duration;
import org.apache.skywalking.oap.server.core.query.type.Call;
import org.apache.skywalking.oap.server.core.source.DetectPoint;
import org.apache.skywalking.oap.server.core.storage.query.ITopologyQueryDAO;
@@ -53,42 +54,39 @@ public class TopologyQueryEsDAO extends EsDAO implements ITopologyQueryDAO {
}
@Override
- public List<Call.CallDetail> loadServiceRelationsDetectedAtServerSide(
- long startTB, long endTB, List<String> serviceIds) {
+ public List<Call.CallDetail> loadServiceRelationsDetectedAtServerSide(Duration duration, List<String> serviceIds) {
if (CollectionUtils.isEmpty(serviceIds)) {
throw new UnexpectedException("Service id is empty");
}
final SearchBuilder sourceBuilder = Search.builder().size(0);
- setQueryCondition(sourceBuilder, startTB, endTB, serviceIds, ServiceRelationServerSideMetrics.INDEX_NAME);
+ setQueryCondition(sourceBuilder, duration, serviceIds, ServiceRelationServerSideMetrics.INDEX_NAME);
return buildServiceRelation(
sourceBuilder, ServiceRelationServerSideMetrics.INDEX_NAME, DetectPoint.SERVER);
}
@Override
- public List<Call.CallDetail> loadServiceRelationDetectedAtClientSide(long startTB,
- long endTB,
+ public List<Call.CallDetail> loadServiceRelationDetectedAtClientSide(Duration duration,
List<String> serviceIds) {
if (CollectionUtils.isEmpty(serviceIds)) {
throw new UnexpectedException("Service id is empty");
}
final SearchBuilder sourceBuilder = Search.builder().size(0);
- setQueryCondition(sourceBuilder, startTB, endTB, serviceIds, ServiceRelationClientSideMetrics.INDEX_NAME);
+ setQueryCondition(sourceBuilder, duration, serviceIds, ServiceRelationClientSideMetrics.INDEX_NAME);
return buildServiceRelation(
sourceBuilder, ServiceRelationClientSideMetrics.INDEX_NAME, DetectPoint.CLIENT);
}
@Override
- public List<Call.CallDetail> loadServiceRelationsDetectedAtServerSide(long startTB,
- long endTB) {
+ public List<Call.CallDetail> loadServiceRelationsDetectedAtServerSide(Duration duration) {
SearchBuilder sourceBuilder = Search.builder();
final BoolQueryBuilder query = Query.bool()
.must(Query.range(ServiceRelationServerSideMetrics.TIME_BUCKET)
- .gte(startTB)
- .lte(endTB));
+ .gte(duration.getStartTimeBucket())
+ .lte(duration.getEndTimeBucket()));
if (IndexController.LogicIndicesRegister.isPhysicalTable(ServiceRelationServerSideMetrics.INDEX_NAME)) {
query.must(Query.term(IndexController.LogicIndicesRegister.METRIC_TABLE_NAME, ServiceRelationServerSideMetrics.INDEX_NAME));
}
@@ -99,13 +97,12 @@ public class TopologyQueryEsDAO extends EsDAO implements ITopologyQueryDAO {
}
@Override
- public List<Call.CallDetail> loadServiceRelationDetectedAtClientSide(long startTB,
- long endTB) {
+ public List<Call.CallDetail> loadServiceRelationDetectedAtClientSide(Duration duration) {
SearchBuilder sourceBuilder = Search.builder();
final BoolQueryBuilder query = Query.bool()
.must(Query.range(ServiceRelationClientSideMetrics.TIME_BUCKET)
- .gte(startTB)
- .lte(endTB));
+ .gte(duration.getStartTimeBucket())
+ .lte(duration.getEndTimeBucket()));
if (IndexController.LogicIndicesRegister.isPhysicalTable(ServiceRelationClientSideMetrics.INDEX_NAME)) {
query.must(Query.term(IndexController.LogicIndicesRegister.METRIC_TABLE_NAME, ServiceRelationClientSideMetrics.INDEX_NAME));
}
@@ -118,10 +115,9 @@ public class TopologyQueryEsDAO extends EsDAO implements ITopologyQueryDAO {
@Override
public List<Call.CallDetail> loadInstanceRelationDetectedAtServerSide(String clientServiceId,
String serverServiceId,
- long startTB,
- long endTB) {
+ Duration duration) {
final SearchBuilder search = Search.builder().size(0);
- setInstanceQueryCondition(search, startTB, endTB, clientServiceId, serverServiceId, ServiceInstanceRelationServerSideMetrics.INDEX_NAME);
+ setInstanceQueryCondition(search, duration, clientServiceId, serverServiceId, ServiceInstanceRelationServerSideMetrics.INDEX_NAME);
return buildInstanceRelation(
search, ServiceInstanceRelationServerSideMetrics.INDEX_NAME, DetectPoint.SERVER);
@@ -130,16 +126,15 @@ public class TopologyQueryEsDAO extends EsDAO implements ITopologyQueryDAO {
@Override
public List<Call.CallDetail> loadInstanceRelationDetectedAtClientSide(String clientServiceId,
String serverServiceId,
- long startTB,
- long endTB) {
+ Duration duration) {
final SearchBuilder search = Search.builder().size(0);
- setInstanceQueryCondition(search, startTB, endTB, clientServiceId, serverServiceId, ServiceInstanceRelationClientSideMetrics.INDEX_NAME);
+ setInstanceQueryCondition(search, duration, clientServiceId, serverServiceId, ServiceInstanceRelationClientSideMetrics.INDEX_NAME);
return buildInstanceRelation(
search, ServiceInstanceRelationClientSideMetrics.INDEX_NAME, DetectPoint.CLIENT);
}
- private void setInstanceQueryCondition(SearchBuilder search, long startTB, long endTB,
+ private void setInstanceQueryCondition(SearchBuilder search, Duration duration,
String clientServiceId, String serverServiceId, String indexName) {
final BoolQueryBuilder serverRelationBoolQuery =
Query.bool()
@@ -175,8 +170,8 @@ public class TopologyQueryEsDAO extends EsDAO implements ITopologyQueryDAO {
final BoolQueryBuilder boolQuery =
Query.bool()
.must(Query.range(EndpointRelationServerSideMetrics.TIME_BUCKET)
- .gte(startTB)
- .lte(endTB))
+ .gte(duration.getStartTimeBucket())
+ .lte(duration.getEndTimeBucket()))
.must(serviceIdBoolQuery);
if (IndexController.LogicIndicesRegister.isPhysicalTable(indexName)) {
boolQuery.must(Query.term(IndexController.LogicIndicesRegister.METRIC_TABLE_NAME, indexName));
@@ -185,15 +180,14 @@ public class TopologyQueryEsDAO extends EsDAO implements ITopologyQueryDAO {
}
@Override
- public List<Call.CallDetail> loadEndpointRelation(long startTB, long endTB,
- String destEndpointId) {
+ public List<Call.CallDetail> loadEndpointRelation(Duration duration, String destEndpointId) {
SearchBuilder sourceBuilder = Search.builder();
sourceBuilder.size(0);
BoolQueryBuilder boolQuery = Query.bool();
boolQuery.must(
Query.range(EndpointRelationServerSideMetrics.TIME_BUCKET)
- .gte(startTB).lte(endTB));
+ .gte(duration.getStartTimeBucket()).lte(duration.getEndTimeBucket()));
BoolQueryBuilder serviceIdBoolQuery = Query.bool();
boolQuery.must(serviceIdBoolQuery);
@@ -215,22 +209,22 @@ public class TopologyQueryEsDAO extends EsDAO implements ITopologyQueryDAO {
}
@Override
- public List<Call.CallDetail> loadProcessRelationDetectedAtClientSide(String serviceInstanceId, long startTB, long endTB) throws IOException {
- return buildProcessRelation(serviceInstanceId, startTB, endTB, DetectPoint.CLIENT);
+ public List<Call.CallDetail> loadProcessRelationDetectedAtClientSide(String serviceInstanceId, Duration duration) throws IOException {
+ return buildProcessRelation(serviceInstanceId, duration, DetectPoint.CLIENT);
}
@Override
- public List<Call.CallDetail> loadProcessRelationDetectedAtServerSide(String serviceInstanceId, long startTB, long endTB) throws IOException {
- return buildProcessRelation(serviceInstanceId, startTB, endTB, DetectPoint.SERVER);
+ public List<Call.CallDetail> loadProcessRelationDetectedAtServerSide(String serviceInstanceId, Duration duration) throws IOException {
+ return buildProcessRelation(serviceInstanceId, duration, DetectPoint.SERVER);
}
- private List<Call.CallDetail> buildProcessRelation(String serviceInstanceId, long startTB, long endTB, DetectPoint detectPoint) throws IOException {
+ private List<Call.CallDetail> buildProcessRelation(String serviceInstanceId, Duration duration, DetectPoint detectPoint) throws IOException {
final SearchBuilder sourceBuilder = Search.builder().size(0);
final BoolQueryBuilder query = Query.bool()
.must(Query.term(ProcessRelationServerSideMetrics.SERVICE_INSTANCE_ID, serviceInstanceId))
.must(Query.range(EndpointRelationServerSideMetrics.TIME_BUCKET)
- .gte(startTB)
- .lte(endTB));
+ .gte(duration.getStartTimeBucket())
+ .lte(duration.getEndTimeBucket()));
sourceBuilder.query(query);
sourceBuilder.aggregation(
Aggregation
@@ -380,13 +374,13 @@ public class TopologyQueryEsDAO extends EsDAO implements ITopologyQueryDAO {
return calls;
}
- private void setQueryCondition(SearchBuilder search, long startTB, long endTB,
+ private void setQueryCondition(SearchBuilder search, Duration duration,
List<String> serviceIds, String indexName) {
final BoolQueryBuilder query =
Query.bool()
.must(Query.range(ServiceRelationServerSideMetrics.TIME_BUCKET)
- .gte(startTB)
- .lte(endTB));
+ .gte(duration.getStartTimeBucket())
+ .lte(duration.getEndTimeBucket()));
final BoolQueryBuilder serviceIdBoolQuery = Query.bool();
diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/TraceQueryEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/TraceQueryEsDAO.java
index 5401c676a1..2beb3dde7e 100644
--- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/TraceQueryEsDAO.java
+++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/TraceQueryEsDAO.java
@@ -34,6 +34,7 @@ import org.apache.skywalking.library.elasticsearch.response.search.SearchRespons
import org.apache.skywalking.oap.server.core.analysis.IDManager;
import org.apache.skywalking.oap.server.core.analysis.manual.searchtag.Tag;
import org.apache.skywalking.oap.server.core.analysis.manual.segment.SegmentRecord;
+import org.apache.skywalking.oap.server.core.query.input.Duration;
import org.apache.skywalking.oap.server.core.query.type.BasicTrace;
import org.apache.skywalking.oap.server.core.query.type.QueryOrder;
import org.apache.skywalking.oap.server.core.query.type.Span;
@@ -49,6 +50,8 @@ import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base.EsDAO;
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base.IndexController;
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.base.TimeRangeIndexNameGenerator;
+import static java.util.Objects.nonNull;
+
public class TraceQueryEsDAO extends EsDAO implements ITraceQueryDAO {
private final int segmentQueryMaxSize;
@@ -59,8 +62,7 @@ public class TraceQueryEsDAO extends EsDAO implements ITraceQueryDAO {
}
@Override
- public TraceBrief queryBasicTraces(long startSecondTB,
- long endSecondTB,
+ public TraceBrief queryBasicTraces(Duration duration,
long minDuration,
long maxDuration,
String serviceId,
@@ -72,6 +74,12 @@ public class TraceQueryEsDAO extends EsDAO implements ITraceQueryDAO {
TraceState traceState,
QueryOrder queryOrder,
final List<Tag> tags) throws IOException {
+ long startSecondTB = 0;
+ long endSecondTB = 0;
+ if (nonNull(duration)) {
+ startSecondTB = duration.getStartTimeBucketInSec();
+ endSecondTB = duration.getEndTimeBucketInSec();
+ }
final BoolQueryBuilder query = Query.bool();
if (IndexController.LogicIndicesRegister.isPhysicalTable(SegmentRecord.INDEX_NAME)) {
query.must(Query.term(IndexController.LogicIndicesRegister.RECORD_TABLE_NAME, SegmentRecord.INDEX_NAME));
diff --git a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/zipkin/ZipkinQueryEsDAO.java b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/zipkin/ZipkinQueryEsDAO.java
index 0b6545c877..41d88cdb7b 100644
--- a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/zipkin/ZipkinQueryEsDAO.java
+++ b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/zipkin/ZipkinQueryEsDAO.java
@@ -37,6 +37,7 @@ import org.apache.skywalking.library.elasticsearch.requests.search.aggregation.T
import org.apache.skywalking.library.elasticsearch.response.search.SearchHit;
import org.apache.skywalking.library.elasticsearch.response.search.SearchResponse;
import org.apache.skywalking.oap.server.core.analysis.TimeBucket;
+import org.apache.skywalking.oap.server.core.query.input.Duration;
import org.apache.skywalking.oap.server.core.storage.query.IZipkinQueryDAO;
import org.apache.skywalking.oap.server.core.zipkin.ZipkinServiceRelationTraffic;
import org.apache.skywalking.oap.server.core.zipkin.ZipkinServiceSpanTraffic;
@@ -166,9 +167,9 @@ public class ZipkinQueryEsDAO extends EsDAO implements IZipkinQueryDAO {
}
@Override
- public List<List<Span>> getTraces(final QueryRequest request) {
- final long startTimeMillis = request.endTs() - request.lookback();
- final long endTimeMillis = request.endTs();
+ public List<List<Span>> getTraces(final QueryRequest request, Duration duration) {
+ final long startTimeMillis = duration.getStartTimestamp();
+ final long endTimeMillis = duration.getEndTimestamp();
BoolQueryBuilder query = Query.bool();
if (startTimeMillis > 0 && endTimeMillis > 0) {
query.must(Query.range(ZipkinSpanRecord.TIMESTAMP_MILLIS)
diff --git a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2AlarmQueryDAO.java b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2AlarmQueryDAO.java
index a28820d21e..613e3b3cbc 100644
--- a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2AlarmQueryDAO.java
+++ b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2AlarmQueryDAO.java
@@ -33,12 +33,15 @@ import org.apache.skywalking.oap.server.core.alarm.AlarmRecord;
import org.apache.skywalking.oap.server.core.analysis.manual.searchtag.Tag;
import org.apache.skywalking.oap.server.core.config.ConfigService;
import org.apache.skywalking.oap.server.core.query.enumeration.Scope;
+import org.apache.skywalking.oap.server.core.query.input.Duration;
import org.apache.skywalking.oap.server.core.query.type.AlarmMessage;
import org.apache.skywalking.oap.server.core.query.type.Alarms;
import org.apache.skywalking.oap.server.core.storage.query.IAlarmQueryDAO;
import org.apache.skywalking.oap.server.library.client.jdbc.hikaricp.JDBCHikariCPClient;
import org.apache.skywalking.oap.server.library.module.ModuleManager;
import org.apache.skywalking.oap.server.library.util.CollectionUtils;
+
+import static java.util.Objects.nonNull;
import static org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2TableInstaller.ID_COLUMN;
public class H2AlarmQueryDAO implements IAlarmQueryDAO {
@@ -56,8 +59,14 @@ public class H2AlarmQueryDAO implements IAlarmQueryDAO {
}
@Override
- public Alarms getAlarm(Integer scopeId, String keyword, int limit, int from, long startTB,
- long endTB, final List<Tag> tags) throws IOException {
+ public Alarms getAlarm(Integer scopeId, String keyword, int limit, int from,
+ Duration duration, final List<Tag> tags) throws IOException {
+ long startTB = 0;
+ long endTB = 0;
+ if (nonNull(duration)) {
+ startTB = duration.getStartTimeBucketInSec();
+ endTB = duration.getEndTimeBucketInSec();
+ }
if (searchableTagKeys == null) {
final ConfigService configService = manager.find(CoreModule.NAME)
.provider()
diff --git a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2BrowserLogQueryDAO.java b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2BrowserLogQueryDAO.java
index 51dba90095..9c5ec540c3 100644
--- a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2BrowserLogQueryDAO.java
+++ b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2BrowserLogQueryDAO.java
@@ -24,6 +24,7 @@ import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import lombok.RequiredArgsConstructor;
+import org.apache.skywalking.oap.server.core.query.input.Duration;
import org.apache.skywalking.oap.server.library.util.StringUtil;
import org.apache.skywalking.oap.server.core.browser.manual.errorlog.BrowserErrorLogRecord;
import org.apache.skywalking.oap.server.core.browser.source.BrowserErrorCategory;
@@ -43,10 +44,14 @@ public class H2BrowserLogQueryDAO implements IBrowserLogQueryDAO {
String serviceVersionId,
String pagePathId,
BrowserErrorCategory category,
- long startSecondTB,
- long endSecondTB,
+ Duration duration,
int limit,
int from) throws IOException {
+ long startSecondTB = 0, endSecondTB = 0;
+ if (nonNull(duration)) {
+ startSecondTB = duration.getStartTimeBucketInSec();
+ endSecondTB = duration.getEndTimeBucketInSec();
+ }
StringBuilder sql = new StringBuilder();
List<Object> parameters = new ArrayList<>(9);
diff --git a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2LogQueryDAO.java b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2LogQueryDAO.java
index e3b10d7645..47efa7202e 100644
--- a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2LogQueryDAO.java
+++ b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2LogQueryDAO.java
@@ -26,6 +26,7 @@ import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import org.apache.skywalking.oap.server.core.query.input.Duration;
import org.apache.skywalking.oap.server.library.util.StringUtil;
import org.apache.skywalking.oap.server.core.Const;
import org.apache.skywalking.oap.server.core.CoreModule;
@@ -75,11 +76,16 @@ public class H2LogQueryDAO implements ILogQueryDAO {
Order queryOrder,
int from,
int limit,
- final long startSecondTB,
- final long endSecondTB,
+ final Duration duration,
final List<Tag> tags,
final List<String> keywordsOfContent,
final List<String> excludingKeywordsOfContent) throws IOException {
+ long startSecondTB = 0;
+ long endSecondTB = 0;
+ if (nonNull(duration)) {
+ startSecondTB = duration.getStartTimeBucketInSec();
+ endSecondTB = duration.getEndTimeBucketInSec();
+ }
if (searchableTagKeys == null) {
final ConfigService configService = manager.find(CoreModule.NAME)
.provider()
diff --git a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2MetadataQueryDAO.java b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2MetadataQueryDAO.java
index 07a38d4e43..253a2495fa 100644
--- a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2MetadataQueryDAO.java
+++ b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2MetadataQueryDAO.java
@@ -40,6 +40,7 @@ import org.apache.skywalking.oap.server.core.analysis.manual.process.ProcessTraf
import org.apache.skywalking.oap.server.core.analysis.manual.service.ServiceTraffic;
import org.apache.skywalking.oap.server.core.query.enumeration.Language;
import org.apache.skywalking.oap.server.core.query.enumeration.ProfilingSupportStatus;
+import org.apache.skywalking.oap.server.core.query.input.Duration;
import org.apache.skywalking.oap.server.core.query.type.Attribute;
import org.apache.skywalking.oap.server.core.query.type.Endpoint;
import org.apache.skywalking.oap.server.core.query.type.Process;
@@ -112,9 +113,9 @@ public class H2MetadataQueryDAO implements IMetadataQueryDAO {
}
@Override
- public List<ServiceInstance> listInstances(long startTimestamp, long endTimestamp,
+ public List<ServiceInstance> listInstances(Duration duration,
String serviceId) throws IOException {
- final long minuteTimeBucket = TimeBucket.getMinuteTimeBucket(startTimestamp);
+ final long minuteTimeBucket = TimeBucket.getMinuteTimeBucket(duration.getStartTimestamp());
StringBuilder sql = new StringBuilder();
List<Object> condition = new ArrayList<>(5);
@@ -204,7 +205,9 @@ public class H2MetadataQueryDAO implements IMetadataQueryDAO {
}
@Override
- public List<Process> listProcesses(String serviceInstanceId, long lastPingStartTimeBucket, long lastPingEndTimeBucket, boolean includeVirtual) throws IOException {
+ public List<Process> listProcesses(String serviceInstanceId, Duration duration, boolean includeVirtual) throws IOException {
+ long lastPingStartTimeBucket = duration.getStartTimeBucket();
+ long lastPingEndTimeBucket = duration.getEndTimeBucket();
StringBuilder sql = new StringBuilder();
List<Object> condition = new ArrayList<>();
sql.append("select * from ").append(ProcessTraffic.INDEX_NAME);
diff --git a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2TagAutoCompleteQueryDAO.java b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2TagAutoCompleteQueryDAO.java
index b73414c71d..7ea5e01b97 100644
--- a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2TagAutoCompleteQueryDAO.java
+++ b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2TagAutoCompleteQueryDAO.java
@@ -29,9 +29,12 @@ import java.util.Set;
import lombok.RequiredArgsConstructor;
import org.apache.skywalking.oap.server.core.analysis.manual.searchtag.TagAutocompleteData;
import org.apache.skywalking.oap.server.core.analysis.manual.searchtag.TagType;
+import org.apache.skywalking.oap.server.core.query.input.Duration;
import org.apache.skywalking.oap.server.core.storage.query.ITagAutoCompleteQueryDAO;
import org.apache.skywalking.oap.server.library.client.jdbc.hikaricp.JDBCHikariCPClient;
+import static java.util.Objects.nonNull;
+
@RequiredArgsConstructor
public class H2TagAutoCompleteQueryDAO implements ITagAutoCompleteQueryDAO {
private final JDBCHikariCPClient h2Client;
@@ -39,15 +42,14 @@ public class H2TagAutoCompleteQueryDAO implements ITagAutoCompleteQueryDAO {
@Override
public Set<String> queryTagAutocompleteKeys(final TagType tagType,
final int limit,
- final long startSecondTB,
- final long endSecondTB) throws IOException {
+ final Duration duration) throws IOException {
StringBuilder sql = new StringBuilder();
List<Object> condition = new ArrayList<>(2);
sql.append("select distinct ").append(TagAutocompleteData.TAG_KEY).append(" from ")
.append(TagAutocompleteData.INDEX_NAME).append(" where ");
sql.append(" 1=1 ");
- appendTagAutocompleteCondition(tagType, startSecondTB, endSecondTB, sql, condition);
+ appendTagAutocompleteCondition(tagType, duration, sql, condition);
sql.append(" limit ").append(limit);
try (Connection connection = h2Client.getConnection()) {
ResultSet resultSet = h2Client.executeQuery(connection, sql.toString(), condition.toArray(new Object[0]));
@@ -65,14 +67,13 @@ public class H2TagAutoCompleteQueryDAO implements ITagAutoCompleteQueryDAO {
public Set<String> queryTagAutocompleteValues(final TagType tagType,
final String tagKey,
final int limit,
- final long startSecondTB,
- final long endSecondTB) throws IOException {
+ final Duration duration) throws IOException {
StringBuilder sql = new StringBuilder();
List<Object> condition = new ArrayList<>(3);
sql.append("select * from ").append(TagAutocompleteData.INDEX_NAME).append(" where ");
sql.append(TagAutocompleteData.TAG_KEY).append(" = ?");
condition.add(tagKey);
- appendTagAutocompleteCondition(tagType, startSecondTB, endSecondTB, sql, condition);
+ appendTagAutocompleteCondition(tagType, duration, sql, condition);
sql.append(" limit ").append(limit);
try (Connection connection = h2Client.getConnection()) {
@@ -88,16 +89,23 @@ public class H2TagAutoCompleteQueryDAO implements ITagAutoCompleteQueryDAO {
}
private void appendTagAutocompleteCondition(final TagType tagType,
- final long startSecondTB,
- final long endSecondTB,
+ final Duration duration,
final StringBuilder sql,
final List<Object> condition) {
+ long startSecondTB = 0;
+ long endSecondTB = 0;
+ if (nonNull(duration)) {
+ startSecondTB = duration.getStartTimeBucketInSec();
+ endSecondTB = duration.getEndTimeBucketInSec();
+ }
+
+ long startTB = startSecondTB / 1000000 * 10000;
+ long endTB = endSecondTB / 1000000 * 10000 + 2359;
+
sql.append(" and ");
sql.append(TagAutocompleteData.TAG_TYPE).append(" = ?");
condition.add(tagType.name());
- long startTB = startSecondTB / 1000000 * 10000;
- long endTB = endSecondTB / 1000000 * 10000 + 9999;
if (startTB > 0) {
sql.append(" and ");
sql.append(TagAutocompleteData.TIME_BUCKET).append(">=?");
diff --git a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2TopologyQueryDAO.java b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2TopologyQueryDAO.java
index a7d0f71380..a7cd8354b2 100644
--- a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2TopologyQueryDAO.java
+++ b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2TopologyQueryDAO.java
@@ -32,6 +32,7 @@ import org.apache.skywalking.oap.server.core.analysis.manual.relation.process.Pr
import org.apache.skywalking.oap.server.core.analysis.manual.relation.service.ServiceRelationClientSideMetrics;
import org.apache.skywalking.oap.server.core.analysis.manual.relation.service.ServiceRelationServerSideMetrics;
import org.apache.skywalking.oap.server.core.analysis.metrics.Metrics;
+import org.apache.skywalking.oap.server.core.query.input.Duration;
import org.apache.skywalking.oap.server.core.query.type.Call;
import org.apache.skywalking.oap.server.core.source.DetectPoint;
import org.apache.skywalking.oap.server.core.storage.query.ITopologyQueryDAO;
@@ -45,42 +46,38 @@ public class H2TopologyQueryDAO implements ITopologyQueryDAO {
}
@Override
- public List<Call.CallDetail> loadServiceRelationsDetectedAtServerSide(long startTB,
- long endTB,
+ public List<Call.CallDetail> loadServiceRelationsDetectedAtServerSide(Duration duration,
List<String> serviceIds) throws IOException {
return loadServiceCalls(
- ServiceRelationServerSideMetrics.INDEX_NAME, startTB, endTB,
+ ServiceRelationServerSideMetrics.INDEX_NAME, duration,
ServiceRelationServerSideMetrics.SOURCE_SERVICE_ID,
ServiceRelationServerSideMetrics.DEST_SERVICE_ID, serviceIds, DetectPoint.SERVER
);
}
@Override
- public List<Call.CallDetail> loadServiceRelationDetectedAtClientSide(long startTB,
- long endTB,
+ public List<Call.CallDetail> loadServiceRelationDetectedAtClientSide(Duration duration,
List<String> serviceIds) throws IOException {
return loadServiceCalls(
- ServiceRelationClientSideMetrics.INDEX_NAME, startTB, endTB,
+ ServiceRelationClientSideMetrics.INDEX_NAME, duration,
ServiceRelationClientSideMetrics.SOURCE_SERVICE_ID,
ServiceRelationClientSideMetrics.DEST_SERVICE_ID, serviceIds, DetectPoint.CLIENT
);
}
@Override
- public List<Call.CallDetail> loadServiceRelationsDetectedAtServerSide(long startTB,
- long endTB) throws IOException {
+ public List<Call.CallDetail> loadServiceRelationsDetectedAtServerSide(Duration duration) throws IOException {
return loadServiceCalls(
- ServiceRelationServerSideMetrics.INDEX_NAME, startTB, endTB,
+ ServiceRelationServerSideMetrics.INDEX_NAME, duration,
ServiceRelationServerSideMetrics.SOURCE_SERVICE_ID,
ServiceRelationServerSideMetrics.DEST_SERVICE_ID, new ArrayList<>(0), DetectPoint.SERVER
);
}
@Override
- public List<Call.CallDetail> loadServiceRelationDetectedAtClientSide(long startTB,
- long endTB) throws IOException {
+ public List<Call.CallDetail> loadServiceRelationDetectedAtClientSide(Duration duration) throws IOException {
return loadServiceCalls(
- ServiceRelationClientSideMetrics.INDEX_NAME, startTB, endTB,
+ ServiceRelationClientSideMetrics.INDEX_NAME, duration,
ServiceRelationClientSideMetrics.SOURCE_SERVICE_ID,
ServiceRelationClientSideMetrics.DEST_SERVICE_ID, new ArrayList<>(0), DetectPoint.CLIENT
);
@@ -89,10 +86,9 @@ public class H2TopologyQueryDAO implements ITopologyQueryDAO {
@Override
public List<Call.CallDetail> loadInstanceRelationDetectedAtServerSide(String clientServiceId,
String serverServiceId,
- long startTB,
- long endTB) throws IOException {
+ Duration duration) throws IOException {
return loadServiceInstanceCalls(
- ServiceInstanceRelationServerSideMetrics.INDEX_NAME, startTB, endTB,
+ ServiceInstanceRelationServerSideMetrics.INDEX_NAME, duration,
ServiceInstanceRelationServerSideMetrics.SOURCE_SERVICE_ID,
ServiceInstanceRelationServerSideMetrics.DEST_SERVICE_ID, clientServiceId, serverServiceId,
DetectPoint.SERVER
@@ -102,10 +98,9 @@ public class H2TopologyQueryDAO implements ITopologyQueryDAO {
@Override
public List<Call.CallDetail> loadInstanceRelationDetectedAtClientSide(String clientServiceId,
String serverServiceId,
- long startTB,
- long endTB) throws IOException {
+ Duration duration) throws IOException {
return loadServiceInstanceCalls(
- ServiceInstanceRelationClientSideMetrics.INDEX_NAME, startTB, endTB,
+ ServiceInstanceRelationClientSideMetrics.INDEX_NAME, duration,
ServiceInstanceRelationClientSideMetrics.SOURCE_SERVICE_ID,
ServiceInstanceRelationClientSideMetrics.DEST_SERVICE_ID, clientServiceId, serverServiceId,
DetectPoint.CLIENT
@@ -113,16 +108,15 @@ public class H2TopologyQueryDAO implements ITopologyQueryDAO {
}
@Override
- public List<Call.CallDetail> loadEndpointRelation(long startTB,
- long endTB,
+ public List<Call.CallDetail> loadEndpointRelation(Duration duration,
String destEndpointId) throws IOException {
List<Call.CallDetail> calls = loadEndpointFromSide(
- EndpointRelationServerSideMetrics.INDEX_NAME, startTB, endTB,
+ EndpointRelationServerSideMetrics.INDEX_NAME, duration,
EndpointRelationServerSideMetrics.SOURCE_ENDPOINT,
EndpointRelationServerSideMetrics.DEST_ENDPOINT, destEndpointId, false
);
calls.addAll(
- loadEndpointFromSide(EndpointRelationServerSideMetrics.INDEX_NAME, startTB, endTB,
+ loadEndpointFromSide(EndpointRelationServerSideMetrics.INDEX_NAME, duration,
EndpointRelationServerSideMetrics.SOURCE_ENDPOINT,
EndpointRelationServerSideMetrics.DEST_ENDPOINT, destEndpointId, true
));
@@ -130,25 +124,24 @@ public class H2TopologyQueryDAO implements ITopologyQueryDAO {
}
@Override
- public List<Call.CallDetail> loadProcessRelationDetectedAtClientSide(String serviceInstanceId, long startTB, long endTB) throws IOException {
- return loadProcessFromSide(startTB, endTB, serviceInstanceId, DetectPoint.CLIENT);
+ public List<Call.CallDetail> loadProcessRelationDetectedAtClientSide(String serviceInstanceId, Duration duration) throws IOException {
+ return loadProcessFromSide(duration, serviceInstanceId, DetectPoint.CLIENT);
}
@Override
- public List<Call.CallDetail> loadProcessRelationDetectedAtServerSide(String serviceInstanceId, long startTB, long endTB) throws IOException {
- return loadProcessFromSide(startTB, endTB, serviceInstanceId, DetectPoint.SERVER);
+ public List<Call.CallDetail> loadProcessRelationDetectedAtServerSide(String serviceInstanceId, Duration duration) throws IOException {
+ return loadProcessFromSide(duration, serviceInstanceId, DetectPoint.SERVER);
}
private List<Call.CallDetail> loadServiceCalls(String tableName,
- long startTB,
- long endTB,
+ Duration duration,
String sourceCName,
String destCName,
List<String> serviceIds,
DetectPoint detectPoint) throws IOException {
Object[] conditions = new Object[serviceIds.size() * 2 + 2];
- conditions[0] = startTB;
- conditions[1] = endTB;
+ conditions[0] = duration.getStartTimeBucket();
+ conditions[1] = duration.getEndTimeBucket();
StringBuilder serviceIdMatchSql = new StringBuilder();
if (serviceIds.size() > 0) {
serviceIdMatchSql.append("and (");
@@ -181,16 +174,15 @@ public class H2TopologyQueryDAO implements ITopologyQueryDAO {
}
private List<Call.CallDetail> loadServiceInstanceCalls(String tableName,
- long startTB,
- long endTB,
+ Duration duration,
String sourceCName,
String descCName,
String sourceServiceId,
String destServiceId,
DetectPoint detectPoint) throws IOException {
Object[] conditions = new Object[] {
- startTB,
- endTB,
+ duration.getStartTimeBucket(),
+ duration.getEndTimeBucket(),
sourceServiceId,
destServiceId,
destServiceId,
@@ -224,15 +216,14 @@ public class H2TopologyQueryDAO implements ITopologyQueryDAO {
}
private List<Call.CallDetail> loadEndpointFromSide(String tableName,
- long startTB,
- long endTB,
+ Duration duration,
String sourceCName,
String destCName,
String id,
boolean isSourceId) throws IOException {
Object[] conditions = new Object[3];
- conditions[0] = startTB;
- conditions[1] = endTB;
+ conditions[0] = duration.getStartTimeBucket();
+ conditions[1] = duration.getEndTimeBucket();
conditions[2] = id;
List<Call.CallDetail> calls = new ArrayList<>();
try (Connection connection = h2Client.getConnection()) {
@@ -252,13 +243,12 @@ public class H2TopologyQueryDAO implements ITopologyQueryDAO {
return calls;
}
- private List<Call.CallDetail> loadProcessFromSide(long startTB,
- long endTB,
+ private List<Call.CallDetail> loadProcessFromSide(Duration duration,
String instanceId,
DetectPoint detectPoint) throws IOException {
Object[] conditions = new Object[3];
- conditions[0] = startTB;
- conditions[1] = endTB;
+ conditions[0] = duration.getStartTimeBucket();
+ conditions[1] = duration.getEndTimeBucket();
conditions[2] = instanceId;
List<Call.CallDetail> calls = new ArrayList<>();
try (Connection connection = h2Client.getConnection()) {
diff --git a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2TraceQueryDAO.java b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2TraceQueryDAO.java
index 8a93a5e3c3..89e32fc897 100644
--- a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2TraceQueryDAO.java
+++ b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2TraceQueryDAO.java
@@ -31,6 +31,7 @@ import java.util.List;
import org.apache.skywalking.oap.server.core.Const;
import org.apache.skywalking.oap.server.core.CoreModule;
import org.apache.skywalking.oap.server.core.config.ConfigService;
+import org.apache.skywalking.oap.server.core.query.input.Duration;
import org.apache.skywalking.oap.server.library.util.StringUtil;
import org.apache.skywalking.oap.server.core.analysis.IDManager;
import org.apache.skywalking.oap.server.core.analysis.manual.searchtag.Tag;
@@ -45,6 +46,8 @@ import org.apache.skywalking.oap.server.library.client.jdbc.hikaricp.JDBCHikariC
import org.apache.skywalking.oap.server.library.module.ModuleManager;
import org.apache.skywalking.oap.server.library.util.BooleanUtils;
import org.apache.skywalking.oap.server.library.util.CollectionUtils;
+
+import static java.util.Objects.nonNull;
import static org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2TableInstaller.ID_COLUMN;
public class H2TraceQueryDAO implements ITraceQueryDAO {
@@ -59,8 +62,7 @@ public class H2TraceQueryDAO implements ITraceQueryDAO {
}
@Override
- public TraceBrief queryBasicTraces(long startSecondTB,
- long endSecondTB,
+ public TraceBrief queryBasicTraces(Duration duration,
long minDuration,
long maxDuration,
String serviceId,
@@ -72,6 +74,12 @@ public class H2TraceQueryDAO implements ITraceQueryDAO {
TraceState traceState,
QueryOrder queryOrder,
final List<Tag> tags) throws IOException {
+ long startSecondTB = 0;
+ long endSecondTB = 0;
+ if (nonNull(duration)) {
+ startSecondTB = duration.getStartTimeBucketInSec();
+ endSecondTB = duration.getEndTimeBucketInSec();
+ }
if (searchableTagKeys == null) {
final ConfigService configService = manager.find(CoreModule.NAME)
.provider()
diff --git a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2ZipkinQueryDAO.java b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2ZipkinQueryDAO.java
index 42fa0e7a50..0c0d842011 100644
--- a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2ZipkinQueryDAO.java
+++ b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2ZipkinQueryDAO.java
@@ -31,6 +31,7 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.apache.skywalking.oap.server.core.query.input.Duration;
import org.apache.skywalking.oap.server.core.storage.query.IZipkinQueryDAO;
import org.apache.skywalking.oap.server.core.zipkin.ZipkinServiceRelationTraffic;
import org.apache.skywalking.oap.server.core.zipkin.ZipkinServiceSpanTraffic;
@@ -137,9 +138,9 @@ public class H2ZipkinQueryDAO implements IZipkinQueryDAO {
}
@Override
- public List<List<Span>> getTraces(final QueryRequest request) throws IOException {
- final long startTimeMillis = request.endTs() - request.lookback();
- final long endTimeMillis = request.endTs();
+ public List<List<Span>> getTraces(final QueryRequest request, Duration duration) throws IOException {
+ final long startTimeMillis = duration.getStartTimestamp();
+ final long endTimeMillis = duration.getEndTimestamp();
StringBuilder sql = new StringBuilder();
List<Object> condition = new ArrayList<>(5);
List<Map.Entry<String, String>> annotations = new ArrayList<>(request.annotationQuery().entrySet());
diff --git a/oap-server/server-tools/profile-exporter/tool-profile-snapshot-bootstrap/src/test/java/org/apache/skywalking/oap/server/tool/profile/exporter/test/ProfileTraceDAO.java b/oap-server/server-tools/profile-exporter/tool-profile-snapshot-bootstrap/src/test/java/org/apache/skywalking/oap/server/tool/profile/exporter/test/ProfileTraceDAO.java
index b127022f64..62d19cead9 100644
--- a/oap-server/server-tools/profile-exporter/tool-profile-snapshot-bootstrap/src/test/java/org/apache/skywalking/oap/server/tool/profile/exporter/test/ProfileTraceDAO.java
+++ b/oap-server/server-tools/profile-exporter/tool-profile-snapshot-bootstrap/src/test/java/org/apache/skywalking/oap/server/tool/profile/exporter/test/ProfileTraceDAO.java
@@ -25,6 +25,7 @@ import org.apache.skywalking.apm.network.language.agent.v3.SegmentObject;
import org.apache.skywalking.apm.network.language.agent.v3.SpanObject;
import org.apache.skywalking.oap.server.core.analysis.manual.searchtag.Tag;
import org.apache.skywalking.oap.server.core.analysis.manual.segment.SegmentRecord;
+import org.apache.skywalking.oap.server.core.query.input.Duration;
import org.apache.skywalking.oap.server.core.query.type.QueryOrder;
import org.apache.skywalking.oap.server.core.query.type.Span;
import org.apache.skywalking.oap.server.core.query.type.TraceBrief;
@@ -39,8 +40,7 @@ public class ProfileTraceDAO implements ITraceQueryDAO {
}
@Override
- public TraceBrief queryBasicTraces(long startSecondTB,
- long endSecondTB,
+ public TraceBrief queryBasicTraces(Duration duration,
long minDuration,
long maxDuration,
String serviceId,