Merge pull request #3945 from mp-loki/feature/max-debug-symbols
Max Debug Event symbols configurable
This commit is contained in:
commit
b765556390
@ -757,6 +757,10 @@ queue:
|
|||||||
notifications_topic: "${TB_QUEUE_TRANSPORT_NOTIFICATIONS_TOPIC:tb_transport.notifications}"
|
notifications_topic: "${TB_QUEUE_TRANSPORT_NOTIFICATIONS_TOPIC:tb_transport.notifications}"
|
||||||
poll_interval: "${TB_QUEUE_TRANSPORT_NOTIFICATIONS_POLL_INTERVAL_MS:25}"
|
poll_interval: "${TB_QUEUE_TRANSPORT_NOTIFICATIONS_POLL_INTERVAL_MS:25}"
|
||||||
|
|
||||||
|
event:
|
||||||
|
debug:
|
||||||
|
max-symbols: "${TB_MAX_DEBUG_EVENT_SYMBOLS:4096}"
|
||||||
|
|
||||||
service:
|
service:
|
||||||
type: "${TB_SERVICE_TYPE:monolith}" # monolith or tb-core or tb-rule-engine
|
type: "${TB_SERVICE_TYPE:monolith}" # monolith or tb-core or tb-rule-engine
|
||||||
# Unique id for this service (autogenerated if empty)
|
# Unique id for this service (autogenerated if empty)
|
||||||
|
|||||||
@ -20,6 +20,7 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.thingsboard.server.common.data.Event;
|
import org.thingsboard.server.common.data.Event;
|
||||||
import org.thingsboard.server.common.data.id.EntityId;
|
import org.thingsboard.server.common.data.id.EntityId;
|
||||||
@ -37,7 +38,8 @@ import java.util.Optional;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class BaseEventService implements EventService {
|
public class BaseEventService implements EventService {
|
||||||
|
|
||||||
private static final int MAX_DEBUG_EVENT_SYMBOLS = 4 * 1024;
|
@Value("${event.debug.max-symbols:4096}")
|
||||||
|
private int maxDebugEventSymbols;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public EventDao eventDao;
|
public EventDao eventDao;
|
||||||
@ -69,8 +71,8 @@ public class BaseEventService implements EventService {
|
|||||||
if (event.getType().startsWith("DEBUG") && event.getBody() != null && event.getBody().has("data")) {
|
if (event.getType().startsWith("DEBUG") && event.getBody() != null && event.getBody().has("data")) {
|
||||||
String dataStr = event.getBody().get("data").asText();
|
String dataStr = event.getBody().get("data").asText();
|
||||||
int length = dataStr.length();
|
int length = dataStr.length();
|
||||||
if (length > MAX_DEBUG_EVENT_SYMBOLS) {
|
if (length > maxDebugEventSymbols) {
|
||||||
((ObjectNode) event.getBody()).put("data", dataStr.substring(0, MAX_DEBUG_EVENT_SYMBOLS) + "...[truncated " + (length - MAX_DEBUG_EVENT_SYMBOLS) + " symbols]");
|
((ObjectNode) event.getBody()).put("data", dataStr.substring(0, maxDebugEventSymbols) + "...[truncated " + (length - maxDebugEventSymbols) + " symbols]");
|
||||||
log.trace("[{}] Event was truncated: {}", event.getId(), dataStr);
|
log.trace("[{}] Event was truncated: {}", event.getId(), dataStr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user