Skip to content

Commit

Permalink
Update the timestamp field type for LogQuery (#6335)
Browse files Browse the repository at this point in the history
  • Loading branch information
arugal committed Feb 7, 2021
1 parent 5e8f1eb commit ba6d49a
Show file tree
Hide file tree
Showing 15 changed files with 30 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Release Notes.
* Metrics combination API supports abandoning results.
* Add a new concept "Event" and its implementations to collect events.
* Add some defensive codes for NPE and bump up Kubernetes client version to expose exception stack trace.
* Update the `timestamp` field type for `LogQuery`.

#### UI
Update selector scroller to show in all pages.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class Log {
private String endpointId;
private String endpointName;
private String traceId;
private String timestamp;
private Long timestamp;
private ContentType contentType = ContentType.NONE;
private String content;
private final List<KeyValue> tags;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public Logs queryLogs(final String serviceId,
log.setEndpointId((String) searchHit.getSourceAsMap().get(AbstractLogRecord.ENDPOINT_ID));
log.setEndpointName((String) searchHit.getSourceAsMap().get(AbstractLogRecord.ENDPOINT_NAME));
log.setTraceId((String) searchHit.getSourceAsMap().get(AbstractLogRecord.TRACE_ID));
log.setTimestamp(searchHit.getSourceAsMap().get(AbstractLogRecord.TIMESTAMP).toString());
log.setTimestamp(((Number) searchHit.getSourceAsMap().get(AbstractLogRecord.TIMESTAMP)).longValue());
log.setContentType(ContentType.instanceOf(
((Number) searchHit.getSourceAsMap().get(AbstractLogRecord.CONTENT_TYPE)).intValue()));
log.setContent((String) searchHit.getSourceAsMap().get(AbstractLogRecord.CONTENT));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public Logs queryLogs(final String serviceId,
log.setEndpointId((String) searchHit.getSourceAsMap().get(AbstractLogRecord.ENDPOINT_ID));
log.setEndpointName((String) searchHit.getSourceAsMap().get(AbstractLogRecord.ENDPOINT_NAME));
log.setTraceId((String) searchHit.getSourceAsMap().get(AbstractLogRecord.TRACE_ID));
log.setTimestamp(searchHit.getSourceAsMap().get(AbstractLogRecord.TIMESTAMP).toString());
log.setTimestamp(((Number) searchHit.getSourceAsMap().get(AbstractLogRecord.TIMESTAMP)).longValue());
log.setContentType(ContentType.instanceOf(
((Number) searchHit.getSourceAsMap().get(AbstractLogRecord.CONTENT_TYPE)).intValue()));
log.setContent((String) searchHit.getSourceAsMap().get(AbstractLogRecord.CONTENT));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public Logs queryLogs(final String serviceId,
log.setEndpointId((String) data.get(ENDPOINT_ID));
log.setEndpointName((String) data.get(ENDPOINT_NAME));
log.setTraceId((String) data.get(TRACE_ID));
log.setTimestamp(data.get(TIMESTAMP).toString());
log.setTimestamp(((Number) data.get(TIMESTAMP)).longValue());
log.setContentType(
ContentType.instanceOf(((Number) data.get(AbstractLogRecord.CONTENT_TYPE)).intValue()));
log.setContent((String) data.get(AbstractLogRecord.CONTENT));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public Logs queryLogs(String serviceId,
log.setEndpointId(resultSet.getString(ENDPOINT_ID));
log.setEndpointName(resultSet.getString(ENDPOINT_NAME));
log.setTraceId(resultSet.getString(TRACE_ID));
log.setTimestamp(resultSet.getString(TIMESTAMP));
log.setTimestamp(resultSet.getLong(TIMESTAMP));
log.setContentType(ContentType.instanceOf(resultSet.getInt(CONTENT_TYPE)));
log.setContent(resultSet.getString(CONTENT));
String dataBinaryBase64 = resultSet.getString(TAGS_RAW_DATA);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ public void verify(final BrowserErrorLog log) {
}

if (nonNull(getLine())) {
doVerify(getLine(), String.valueOf(log.getLine()));
doVerify(getLine(), log.getLine());
}

if (nonNull(getCol())) {
doVerify(getCol(), String.valueOf(log.getCol()));
doVerify(getCol(), log.getCol());
}

if (nonNull(getStack())) {
Expand All @@ -88,7 +88,7 @@ public void verify(final BrowserErrorLog log) {
}

if (nonNull(getFirstReportedError())) {
doVerify(getFirstReportedError(), String.valueOf(log.isFirstReportedError()));
doVerify(getFirstReportedError(), log.isFirstReportedError());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void verify(final DashboardConfiguration configuration) {
doVerify(this.name, configuration.getName());
doVerify(this.type, String.valueOf(configuration.getType()));
doVerify(this.configuration, configuration.getConfiguration());
doVerify(this.activated, String.valueOf(configuration.isActivated()));
doVerify(this.disabled, String.valueOf(configuration.isDisabled()));
doVerify(this.activated, configuration.isActivated());
doVerify(this.disabled, configuration.isDisabled());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class Log {
private String endpointName;
private String endpointId;
private String traceId;
private String timestamp;
private Long timestamp;
private String contentType;
private String content;
private List<KeyValue> tags;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private void verifyEndpointName(Trace trace) {

private void verifyDuration(Trace trace) {
final String expected = this.getDuration();
final String actual = String.valueOf(trace.getDuration());
final int actual = trace.getDuration();

doVerify(expected, actual);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ public abstract class AbstractMatcher<T> {

public abstract void verify(T t);

protected void doVerify(String expected, int actual) {
this.doVerify(expected, String.valueOf(actual));
}

protected void doVerify(String expected, long actual) {
this.doVerify(expected, String.valueOf(actual));
}

protected void doVerify(String expected, boolean actual) {
this.doVerify(expected, String.valueOf(actual));
}

protected void doVerify(String expected, String actual) {
Matcher matcher = NN_MATCHER.matcher(expected);
if (matcher.find()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void shouldSuccess() {
.setEndpointName("/traffic")
.setEndpointId("ZTJl.1_L3RyYWZmaWM=")
.setTraceId("ac81b308-0d66-4c69-a7af-a023a536bd3e")
.setTimestamp("1609665785987")
.setTimestamp(1609665785987L)
.setContentType("TEXT")
.setContent("log")
.setTags(
Expand All @@ -63,7 +63,7 @@ public void shouldSuccess() {
.setEndpointName("/traffic")
.setEndpointId("ZTJl.1_L3RyYWZmaWM=")
.setTraceId("ac81b308-0d66-4c69-a7af-a023a536bd3e")
.setTimestamp("1609665785987")
.setTimestamp(1609665785987L)
.setContentType("TEXT")
.setContent("log")
.setTags(
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/e2e-data/src/test/resources/log.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ logs:
endpointName: /traffic
endpointId: not null
traceId: "ac81b308-0d66-4c69-a7af-a023a536bd3e"
timestamp: not null
timestamp: gt 0
contentType: TEXT
content: log
tags:
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/e2e-test/src/test/resources/expected/log/logs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ logs:
serviceInstanceName: not null
serviceInstanceId: not null
traceId: not null
timestamp: not null
timestamp: gt 0
contentType: TEXT
content: not null
tags:
Expand Down

0 comments on commit ba6d49a

Please sign in to comment.