未验证 提交 03824477 编写于 作者: H hailin0 提交者: GitHub

Fix tags store of log and trace on h2/mysql/pg storage (#6505)

上级 d9617cbe
...@@ -46,6 +46,7 @@ Release Notes. ...@@ -46,6 +46,7 @@ Release Notes.
* Fix wrong `service_instance_sla` setting in the `topology-instance.yml`. * Fix wrong `service_instance_sla` setting in the `topology-instance.yml`.
* Fix wrong metrics name setting in the `self-observability.yml`. * Fix wrong metrics name setting in the `self-observability.yml`.
* Add telemetry data about metrics in, metrics scraping and trace in metrics to zipkin receiver. * Add telemetry data about metrics in, metrics scraping and trace in metrics to zipkin receiver.
* Fix tags store of log and trace on h2/mysql/pg storage.
#### UI #### UI
* Update selector scroller to show in all pages. * Update selector scroller to show in all pages.
......
...@@ -50,8 +50,8 @@ public abstract class AbstractSearchTagBuilder<T extends Record> implements Stor ...@@ -50,8 +50,8 @@ public abstract class AbstractSearchTagBuilder<T extends Record> implements Stor
int tagInx = 0; int tagInx = 0;
final String tagExpression = tag.toString(); final String tagExpression = tag.toString();
for (int i = 0; i < numOfSearchableValuesPerTag; i++) { for (int i = 0; i < numOfSearchableValuesPerTag; i++) {
tagInx = index + numOfSearchableValuesPerTag + i; tagInx = index * numOfSearchableValuesPerTag + i;
final String previousValue = (String) dbMap.get(tagColumn); final String previousValue = (String) dbMap.get(tagColumn + "_" + tagInx);
if (previousValue == null) { if (previousValue == null) {
// Still have at least one available slot, add directly. // Still have at least one available slot, add directly.
shouldAdd = true; shouldAdd = true;
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
package org.apache.skywalking.e2e; package org.apache.skywalking.e2e;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.io.Resources; import com.google.common.io.Resources;
import java.net.URI; import java.net.URI;
import java.net.URL; import java.net.URL;
...@@ -75,6 +76,7 @@ import org.springframework.web.client.RestTemplate; ...@@ -75,6 +76,7 @@ import org.springframework.web.client.RestTemplate;
@Slf4j @Slf4j
public class SimpleQueryClient { public class SimpleQueryClient {
protected final RestTemplate restTemplate = new RestTemplate(); protected final RestTemplate restTemplate = new RestTemplate();
protected final ObjectMapper objectMapper = new ObjectMapper();
protected final String endpointUrl; protected final String endpointUrl;
...@@ -99,7 +101,8 @@ public class SimpleQueryClient { ...@@ -99,7 +101,8 @@ public class SimpleQueryClient {
.replace("{pageNum}", query.pageNum()) .replace("{pageNum}", query.pageNum())
.replace("{pageSize}", query.pageSize()) .replace("{pageSize}", query.pageSize())
.replace("{needTotal}", query.needTotal()) .replace("{needTotal}", query.needTotal())
.replace("{queryOrder}", query.queryOrder()); .replace("{queryOrder}", query.queryOrder())
.replace("{tags}", objectMapper.writeValueAsString(query.tags()));
final ResponseEntity<GQLResponse<TracesData>> responseEntity = restTemplate.exchange( final ResponseEntity<GQLResponse<TracesData>> responseEntity = restTemplate.exchange(
new RequestEntity<>(queryString, HttpMethod.POST, URI.create(endpointUrl)), new RequestEntity<>(queryString, HttpMethod.POST, URI.create(endpointUrl)),
new ParameterizedTypeReference<GQLResponse<TracesData>>() { new ParameterizedTypeReference<GQLResponse<TracesData>>() {
...@@ -415,7 +418,8 @@ public class SimpleQueryClient { ...@@ -415,7 +418,8 @@ public class SimpleQueryClient {
.replace("{needTotal}", query.needTotal()) .replace("{needTotal}", query.needTotal())
.replace("{keywordsOfContent}", query.keywordsOfContent()) .replace("{keywordsOfContent}", query.keywordsOfContent())
.replace( .replace(
"{excludingKeywordsOfContent}", query.excludingKeywordsOfContent()); "{excludingKeywordsOfContent}", query.excludingKeywordsOfContent())
.replace("{tags}", objectMapper.writeValueAsString(query.tags()));
LOGGER.info("Query: {}", queryString); LOGGER.info("Query: {}", queryString);
final ResponseEntity<GQLResponse<LogData>> responseEntity = restTemplate.exchange( final ResponseEntity<GQLResponse<LogData>> responseEntity = restTemplate.exchange(
new RequestEntity<>(queryString, HttpMethod.POST, URI.create(endpointUrl)), new RequestEntity<>(queryString, HttpMethod.POST, URI.create(endpointUrl)),
......
...@@ -19,6 +19,12 @@ package org.apache.skywalking.e2e.log; ...@@ -19,6 +19,12 @@ package org.apache.skywalking.e2e.log;
import org.apache.skywalking.e2e.AbstractQuery; import org.apache.skywalking.e2e.AbstractQuery;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class LogsQuery extends AbstractQuery<LogsQuery> { public class LogsQuery extends AbstractQuery<LogsQuery> {
private String serviceId; private String serviceId;
...@@ -29,6 +35,7 @@ public class LogsQuery extends AbstractQuery<LogsQuery> { ...@@ -29,6 +35,7 @@ public class LogsQuery extends AbstractQuery<LogsQuery> {
private String needTotal = "true"; private String needTotal = "true";
private String keywordsOfContent = ""; private String keywordsOfContent = "";
private String excludingKeywordsOfContent = ""; private String excludingKeywordsOfContent = "";
private List<Map<String, String>> tags = Collections.emptyList();
public String serviceId() { public String serviceId() {
return serviceId; return serviceId;
...@@ -109,4 +116,24 @@ public class LogsQuery extends AbstractQuery<LogsQuery> { ...@@ -109,4 +116,24 @@ public class LogsQuery extends AbstractQuery<LogsQuery> {
} }
return String.join(",", keywords); return String.join(",", keywords);
} }
public List<Map<String, String>> tags() {
return tags;
}
public LogsQuery tags(List<Map<String, String>> tags) {
this.tags = tags;
return this;
}
public LogsQuery addTag(String key, String value) {
if (Collections.EMPTY_LIST.equals(tags)) {
tags = new ArrayList<>();
}
Map<String, String> tag = new HashMap<>();
tag.put("key", key);
tag.put("value", value);
tags.add(tag);
return this;
}
} }
...@@ -20,12 +20,19 @@ package org.apache.skywalking.e2e.trace; ...@@ -20,12 +20,19 @@ package org.apache.skywalking.e2e.trace;
import org.apache.skywalking.e2e.AbstractQuery; import org.apache.skywalking.e2e.AbstractQuery;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class TracesQuery extends AbstractQuery<TracesQuery> { public class TracesQuery extends AbstractQuery<TracesQuery> {
private String traceState = "ALL"; private String traceState = "ALL";
private String pageNum = "1"; private String pageNum = "1";
private String pageSize = "15"; private String pageSize = "15";
private String needTotal = "true"; private String needTotal = "true";
private String queryOrder = "BY_DURATION"; private String queryOrder = "BY_DURATION";
private List<Map<String, String>> tags = Collections.emptyList();
public String traceState() { public String traceState() {
return traceState; return traceState;
...@@ -59,6 +66,11 @@ public class TracesQuery extends AbstractQuery<TracesQuery> { ...@@ -59,6 +66,11 @@ public class TracesQuery extends AbstractQuery<TracesQuery> {
return this; return this;
} }
public TracesQuery pageSize(int pageSize) {
this.pageSize = String.valueOf(pageSize);
return this;
}
public String needTotal() { public String needTotal() {
return needTotal; return needTotal;
} }
...@@ -87,8 +99,23 @@ public class TracesQuery extends AbstractQuery<TracesQuery> { ...@@ -87,8 +99,23 @@ public class TracesQuery extends AbstractQuery<TracesQuery> {
return this; return this;
} }
public TracesQuery pageSize(int pageSize) { public List<Map<String, String>> tags() {
this.pageSize = String.valueOf(pageSize); return tags;
}
public TracesQuery tags(List<Map<String, String>> tags) {
this.tags = tags;
return this;
}
public TracesQuery addTag(String key, String value) {
if (Collections.EMPTY_LIST.equals(tags)) {
tags = new ArrayList<>();
}
Map<String, String> tag = new HashMap<>();
tag.put("key", key);
tag.put("value", value);
tags.add(tag);
return this; return this;
} }
} }
...@@ -53,7 +53,8 @@ ...@@ -53,7 +53,8 @@
"pageNum": {pageNum}, "pageNum": {pageNum},
"pageSize": {pageSize}, "pageSize": {pageSize},
"needTotal": {needTotal} "needTotal": {needTotal}
} },
"tags": {tags}
} }
} }
} }
...@@ -35,7 +35,8 @@ ...@@ -35,7 +35,8 @@
"pageSize": {pageSize}, "pageSize": {pageSize},
"needTotal": {needTotal} "needTotal": {needTotal}
}, },
"queryOrder": "{queryOrder}" "queryOrder": "{queryOrder}",
"tags": {tags}
} }
} }
} }
...@@ -94,7 +94,8 @@ public class LogE2E extends SkyWalkingTestAdapter { ...@@ -94,7 +94,8 @@ public class LogE2E extends SkyWalkingTestAdapter {
public void verifyLog4jLog() throws Exception { public void verifyLog4jLog() throws Exception {
LogsQuery logsQuery = new LogsQuery().serviceId("WW91cl9BcHBsaWNhdGlvbk5hbWU=.1") LogsQuery logsQuery = new LogsQuery().serviceId("WW91cl9BcHBsaWNhdGlvbk5hbWU=.1")
.start(startTime) .start(startTime)
.end(Times.now()); .end(Times.now())
.addTag("level", "INFO");
if (graphql.supportQueryLogsByKeywords()) { if (graphql.supportQueryLogsByKeywords()) {
logsQuery.keywordsOfContent("log4j message"); logsQuery.keywordsOfContent("log4j message");
} }
...@@ -108,7 +109,8 @@ public class LogE2E extends SkyWalkingTestAdapter { ...@@ -108,7 +109,8 @@ public class LogE2E extends SkyWalkingTestAdapter {
public void verifyLog4j2Log() throws Exception { public void verifyLog4j2Log() throws Exception {
LogsQuery logsQuery = new LogsQuery().serviceId("WW91cl9BcHBsaWNhdGlvbk5hbWU=.1") LogsQuery logsQuery = new LogsQuery().serviceId("WW91cl9BcHBsaWNhdGlvbk5hbWU=.1")
.start(startTime) .start(startTime)
.end(Times.now()); .end(Times.now())
.addTag("level", "INFO");
if (graphql.supportQueryLogsByKeywords()) { if (graphql.supportQueryLogsByKeywords()) {
logsQuery.keywordsOfContent("log4j2 message"); logsQuery.keywordsOfContent("log4j2 message");
} }
...@@ -122,7 +124,8 @@ public class LogE2E extends SkyWalkingTestAdapter { ...@@ -122,7 +124,8 @@ public class LogE2E extends SkyWalkingTestAdapter {
public void verifyLogbackLog() throws Exception { public void verifyLogbackLog() throws Exception {
LogsQuery logsQuery = new LogsQuery().serviceId("WW91cl9BcHBsaWNhdGlvbk5hbWU=.1") LogsQuery logsQuery = new LogsQuery().serviceId("WW91cl9BcHBsaWNhdGlvbk5hbWU=.1")
.start(startTime) .start(startTime)
.end(Times.now()); .end(Times.now())
.addTag("level", "INFO");
if (graphql.supportQueryLogsByKeywords()) { if (graphql.supportQueryLogsByKeywords()) {
logsQuery.keywordsOfContent("logback message"); logsQuery.keywordsOfContent("logback message");
} }
......
...@@ -147,7 +147,11 @@ public class StorageE2E extends SkyWalkingTestAdapter { ...@@ -147,7 +147,11 @@ public class StorageE2E extends SkyWalkingTestAdapter {
@RetryableTest @RetryableTest
void traces() throws Exception { void traces() throws Exception {
final List<Trace> traces = graphql.traces(new TracesQuery().start(startTime).end(now()).orderByDuration()); final TracesQuery query = new TracesQuery().start(startTime)
.end(now())
.orderByDuration()
.addTag("http.method", "POST");
final List<Trace> traces = graphql.traces(query);
LOGGER.info("traces: {}", traces); LOGGER.info("traces: {}", traces);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册