Remove `total` field in Alarm, Browser Logs, and Alarm query (#9102)

This commit is contained in:
mrproliu 2022-05-19 23:04:44 +08:00 committed by GitHub
parent 490a1c41a9
commit e451052357
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 9 additions and 93 deletions

View File

@ -59,7 +59,7 @@
* Storage(ElasticSearch): add search options to tolerate inexisting indices.
* Fix the problem that `MQ` has the wrong `Layer` type.
* Fix NoneStream model has wrong downsampling(was Second, should be Minute).
* [Breaking Change] Remove `total` field in Trace and Logs list query.
* [Breaking Change] Remove `total` field in Trace, Log, Event, Browser log, and alarm list query.
#### UI

View File

@ -21,14 +21,11 @@ package org.apache.skywalking.oap.server.core.query.type;
import java.util.ArrayList;
import java.util.List;
import lombok.Getter;
import lombok.Setter;
@Getter
public class Alarms {
private final List<AlarmMessage> msgs;
@Setter
private int total;
public Alarms() {
this.msgs = new ArrayList<>();

View File

@ -20,13 +20,10 @@ package org.apache.skywalking.oap.server.core.query.type;
import java.util.ArrayList;
import java.util.List;
import lombok.Getter;
import lombok.Setter;
@Getter
public class BrowserErrorLogs {
private final List<BrowserErrorLog> logs;
@Setter
private int total;
public BrowserErrorLogs() {
this.logs = new ArrayList<>();

View File

@ -25,6 +25,4 @@ import lombok.Data;
@Data
public class Events {
private List<Event> events = new ArrayList<>();
private long total;
}

View File

@ -43,6 +43,7 @@ import org.apache.skywalking.oap.server.core.query.type.event.Source;
import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine;
import org.apache.skywalking.oap.server.core.storage.query.IEventQueryDAO;
import org.apache.skywalking.oap.server.library.module.ModuleManager;
import org.apache.skywalking.oap.server.library.util.CollectionUtils;
import static com.google.common.base.Strings.isNullOrEmpty;
import static java.util.Objects.isNull;
@ -112,7 +113,7 @@ public class AlarmQuery implements GraphQLQueryResolver {
final EventQueryCondition.EventQueryConditionBuilder conditionPrototype
) throws Exception {
if (alarms.getTotal() < 1) {
if (CollectionUtils.isEmpty(alarms.getMsgs())) {
return alarms;
}

@ -1 +1 @@
Subproject commit 6f9d1721048a2703b4a0f0a96bee70660b9ff628
Subproject commit 3adb9f68649b1a03fa3fa664192ff4bd7523f18b

View File

@ -102,7 +102,6 @@ public class BanyanDBEventQueryDAO extends AbstractBanyanDBDAO implements IEvent
if (resp.size() == 0) {
return events;
}
events.setTotal(resp.size());
for (final DataPoint dataPoint : resp.getDataPoints()) {
events.getEvents().add(buildEventView(dataPoint));
}
@ -116,8 +115,6 @@ public class BanyanDBEventQueryDAO extends AbstractBanyanDBDAO implements IEvent
for (final EventQueryCondition cond : conditionList) {
final Events singleEvents = this.queryEvents(cond);
totalEvents.getEvents().addAll(singleEvents.getEvents());
// TODO: a simple sum but may not be accurate
totalEvents.setTotal(totalEvents.getTotal() + singleEvents.getTotal());
}
return totalEvents;
}

View File

@ -83,7 +83,6 @@ public class BanyanDBAlarmQueryDAO extends AbstractBanyanDBDAO implements IAlarm
});
Alarms alarms = new Alarms();
alarms.setTotal(resp.size());
for (final RowEntity rowEntity : resp.getElements()) {
AlarmRecord.Builder builder = new AlarmRecord.Builder();

View File

@ -83,7 +83,6 @@ public class BanyanDBBrowserLogQueryDAO extends AbstractBanyanDBDAO implements I
});
BrowserErrorLogs logs = new BrowserErrorLogs();
logs.setTotal(resp.size());
for (final RowEntity rowEntity : resp.getElements()) {
final byte[] dataBinary = rowEntity.getTagValue(BrowserErrorLogRecord.DATA_BINARY);

View File

@ -82,7 +82,6 @@ public class AlarmQueryEsDAO extends EsDAO implements IAlarmQueryDAO {
SearchResponse response = getClient().search(index, search.build());
Alarms alarms = new Alarms();
alarms.setTotal(response.getHits().getTotal());
for (SearchHit searchHit : response.getHits().getHits()) {
AlarmRecord.Builder builder = new AlarmRecord.Builder();

View File

@ -87,7 +87,6 @@ public class BrowserLogQueryEsDAO extends EsDAO implements IBrowserLogQueryDAO {
);
BrowserErrorLogs logs = new BrowserErrorLogs();
logs.setTotal(response.getHits().getTotal());
for (SearchHit searchHit : response.getHits().getHits()) {
final String dataBinaryBase64 =

View File

@ -70,7 +70,6 @@ public class ESEventQueryDAO extends EsDAO implements IEventQueryDAO {
IndexController.LogicIndicesRegister.getPhysicalTableName(Event.INDEX_NAME);
final SearchResponse response = getClient().search(index, searchBuilder.build());
final Events events = new Events();
events.setTotal(response.getHits().getTotal());
events.setEvents(response.getHits().getHits().stream()
.map(this::parseSearchHit)
.collect(Collectors.toList()));

View File

@ -114,13 +114,6 @@ public class H2AlarmQueryDAO implements IAlarmQueryDAO {
Alarms alarms = new Alarms();
try (Connection connection = client.getConnection()) {
try (ResultSet resultSet = client.executeQuery(connection, buildCountStatement(sql.toString()), parameters
.toArray(new Object[0]))) {
while (resultSet.next()) {
alarms.setTotal(resultSet.getInt("total"));
}
}
this.buildLimit(sql, from, limit);
try (ResultSet resultSet = client.executeQuery(connection, "select * " + sql.toString(), parameters.toArray(new Object[0]))) {
@ -146,10 +139,6 @@ public class H2AlarmQueryDAO implements IAlarmQueryDAO {
return alarms;
}
protected String buildCountStatement(String sql) {
return "select count(1) total from (select 1 " + sql + " )";
}
protected void buildLimit(StringBuilder sql, int from, int limit) {
sql.append(" LIMIT ").append(limit);
sql.append(" OFFSET ").append(from);

View File

@ -83,13 +83,6 @@ public class H2BrowserLogQueryDAO implements IBrowserLogQueryDAO {
BrowserErrorLogs logs = new BrowserErrorLogs();
try (Connection connection = h2Client.getConnection()) {
try (ResultSet resultSet = h2Client.executeQuery(connection, buildCountStatement(sql.toString()), parameters
.toArray(new Object[0]))) {
while (resultSet.next()) {
logs.setTotal(resultSet.getInt("total"));
}
}
buildLimit(sql, from, limit);
try (ResultSet resultSet = h2Client.executeQuery(
@ -110,10 +103,6 @@ public class H2BrowserLogQueryDAO implements IBrowserLogQueryDAO {
return logs;
}
protected String buildCountStatement(String sql) {
return "select count(1) total from (select 1 " + sql + " )";
}
protected void buildLimit(StringBuilder sql, int from, int limit) {
sql.append(" limit ").append(limit);
sql.append(" offset ").append(from);

View File

@ -59,20 +59,9 @@ public class H2EventQueryDAO implements IEventQueryDAO {
final Events result = new Events();
try (final Connection connection = client.getConnection()) {
String sql = "select count(1) total from " + Event.INDEX_NAME + whereClause;
if (log.isDebugEnabled()) {
log.debug("Count SQL: {}, parameters: {}", sql, parameters);
}
try (final ResultSet resultSet = client.executeQuery(connection, sql, parameters)) {
if (!resultSet.next()) {
return result;
}
result.setTotal(resultSet.getInt("total"));
}
final Order queryOrder = isNull(condition.getOrder()) ? Order.DES : condition.getOrder();
final PaginationUtils.Page page = PaginationUtils.INSTANCE.exchange(condition.getPaging());
sql = "select * from " + Event.INDEX_NAME + whereClause;
String sql = "select * from " + Event.INDEX_NAME + whereClause;
if (Order.DES.equals(queryOrder)) {
sql += " order by " + Event.START_TIME + " desc";
} else {
@ -108,21 +97,10 @@ public class H2EventQueryDAO implements IEventQueryDAO {
final Events result = new Events();
try (final Connection connection = client.getConnection()) {
String sql = "select count(1) total from " + Event.INDEX_NAME + whereClause;
if (log.isDebugEnabled()) {
log.debug("Count SQL: {}, parameters: {}", sql, parameters);
}
try (final ResultSet resultSet = client.executeQuery(connection, sql, parameters)) {
if (!resultSet.next()) {
return result;
}
result.setTotal(resultSet.getInt("total"));
}
EventQueryCondition condition = conditions.get(0);
final Order queryOrder = isNull(condition.getOrder()) ? Order.DES : condition.getOrder();
final PaginationUtils.Page page = PaginationUtils.INSTANCE.exchange(condition.getPaging());
sql = "select * from " + Event.INDEX_NAME + whereClause;
String sql = "select * from " + Event.INDEX_NAME + whereClause;
if (Order.DES.equals(queryOrder)) {
sql += " order by " + Event.START_TIME + " desc";
} else {

View File

@ -35,8 +35,4 @@ public class MySQLAlarmQueryDAO extends H2AlarmQueryDAO {
sql.append(" LIMIT ").append(from).append(", ").append(limit);
}
@Override
protected String buildCountStatement(String sql) {
return "select count(1) total " + sql;
}
}

View File

@ -25,11 +25,6 @@ public class MysqlBrowserLogQueryDAO extends H2BrowserLogQueryDAO {
super(h2Client);
}
@Override
protected String buildCountStatement(String sql) {
return "select count(1) total " + sql;
}
@Override
protected void buildLimit(StringBuilder sql, int from, int limit) {
sql.append(" limit ").append(from).append(", ").append(limit);

View File

@ -36,8 +36,4 @@ public class PostgreSQLAlarmQueryDAO extends MySQLAlarmQueryDAO {
sql.append(" OFFSET ").append(from);
}
@Override
protected String buildCountStatement(String sql) {
return "select count(*) total from (select 1 " + sql + " ) tempTable ";
}
}

View File

@ -27,8 +27,4 @@ public class PostgreSQLBrowserLogQueryDAO extends H2BrowserLogQueryDAO {
super(h2Client);
}
@Override
protected String buildCountStatement(String sql) {
return "select count(*) total from (select 1 " + sql + " ) tempTable ";
}
}

@ -1 +1 @@
Subproject commit b953904c71fabfc019353895ad247a448ef37dc6
Subproject commit b544decbbbb5c656118f2d45564dbea59c96d7e7

View File

@ -64,4 +64,3 @@ msgs:
layer: GENERAL
{{- end }}
{{- end }}
total: {{ gt .total 1 }}

View File

@ -64,4 +64,3 @@ msgs:
layer: GENERAL
{{- end }}
{{- end }}
total: {{ gt .total 1 }}

View File

@ -40,4 +40,3 @@ msgs:
layer: GENERAL
{{- end }}
{{- end }}
total: 1

View File

@ -40,4 +40,3 @@ msgs:
layer: GENERAL
{{- end }}
{{- end }}
total: 1

View File

@ -26,5 +26,4 @@ logs:
stack: ""
errorurl: http://testui/
firstreportederror: {{ .firstreportederror }}
{{- end }}
total: {{ gt .total 0 }}
{{- end }}

View File

@ -34,5 +34,4 @@ events:
endtime: {{ gt .endtime 0 }}
layer: GENERAL
{{- end }}
total: 1

View File

@ -48,4 +48,3 @@ events:
endtime: {{ gt .endtime 0 }}
layer: GENERAL
{{- end }}
total: {{ gt .total 0 }}

View File

@ -48,4 +48,3 @@ events:
endtime: {{ gt .endtime 0 }}
layer: GENERAL
{{- end }}
total: {{ gt .total 0 }}

View File

@ -24,4 +24,4 @@ SW_AGENT_CLIENT_JS_TEST_COMMIT=4f1eb1dcdbde3ec4a38534bf01dded4ab5d2f016
SW_KUBERNETES_COMMIT_SHA=0f3ec68e5a7e1608cec8688716b848ed15e971e5
SW_ROVER_COMMIT=90c93c706743aac1f5853b677730edae8cc32a2c
SW_CTL_COMMIT=48238c6d380df52b46bd6f67798ff572fb5723ed
SW_CTL_COMMIT=219876daf985fd474955834ef0b65013f0890e96