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 2023/07/01 14:38:42 UTC
[skywalking] branch fix-event created (now 5e7092b075)
This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a change to branch fix-event
in repository https://gitbox.apache.org/repos/asf/skywalking.git
at 5e7092b075 Tolerate parameter value in illegal JSON format.
This branch includes the following new commits:
new 5e7092b075 Tolerate parameter value in illegal JSON format.
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[skywalking] 01/01: Tolerate parameter value in illegal JSON format.
Posted by wu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch fix-event
in repository https://gitbox.apache.org/repos/asf/skywalking.git
commit 5e7092b075c6045820d2d199e7b61055e0d4c482
Author: Wu Sheng <wu...@foxmail.com>
AuthorDate: Sat Jul 1 16:38:34 2023 +0200
Tolerate parameter value in illegal JSON format.
---
docs/en/changes/changes.md | 2 ++
.../oap/server/core/analysis/metrics/Event.java | 2 +-
.../oap/server/core/query/type/event/Event.java | 19 +++++++++++++++----
3 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/docs/en/changes/changes.md b/docs/en/changes/changes.md
index cc984da4b2..1abfcd1817 100644
--- a/docs/en/changes/changes.md
+++ b/docs/en/changes/changes.md
@@ -33,6 +33,8 @@
* Fix wrong environment variable name `SW_OTEL_RECEIVER_ENABLED_OTEL_RULES` to right `SW_OTEL_RECEIVER_ENABLED_OTEL_METRICS_RULES`.
* Fix instance query in JDBC implementation.
* Set the `SW_QUERY_MAX_QUERY_COMPLEXITY` default value to 3000(was 1000).
+* Accept `length=4000` parameter value of the event. It was 2000.
+* Tolerate parameter value in illegal JSON format.
#### UI
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/Event.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/Event.java
index 59555b8b10..73ad0e27f6 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/Event.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/Event.java
@@ -74,7 +74,7 @@ public class Event extends Metrics {
public static final String LAYER = "layer";
- private static final int PARAMETER_MAX_LENGTH = 2000;
+ private static final int PARAMETER_MAX_LENGTH = 4000;
@Override
protected StorageID id0() {
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/type/event/Event.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/type/event/Event.java
index d3ecde438d..94417099cb 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/type/event/Event.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/query/type/event/Event.java
@@ -19,13 +19,15 @@
package org.apache.skywalking.oap.server.core.query.type.event;
import com.google.gson.Gson;
+import com.google.gson.JsonSyntaxException;
import com.google.gson.reflect.TypeToken;
+import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import lombok.Data;
-import org.apache.skywalking.oap.server.library.util.StringUtil;
import org.apache.skywalking.oap.server.core.query.type.KeyValue;
+import org.apache.skywalking.oap.server.library.util.StringUtil;
@Data
public class Event {
@@ -55,9 +57,18 @@ public class Event {
public void setParameters(final String json) {
if (StringUtil.isNotEmpty(json)) {
- final Map<String, String> map = GSON.fromJson(json, new TypeToken<Map<String, String>>() {
- }.getType());
- this.parameters = map.entrySet().stream().map(e -> new KeyValue(e.getKey(), e.getValue())).collect(Collectors.toList());
+ try {
+ final Map<String, String> map
+ = GSON.fromJson(json, new TypeToken<Map<String, String>>() {}.getType());
+ this.parameters = map.entrySet()
+ .stream()
+ .map(e -> new KeyValue(e.getKey(), e.getValue()))
+ .collect(Collectors.toList());
+ } catch (JsonSyntaxException e) {
+ this.parameters = new ArrayList<>(2);
+ this.parameters.add(new KeyValue("json_parse", "false"));
+ this.parameters.add(new KeyValue("raw_parameters", json));
+ }
}
}
}