Skip to content

Commit d4bd334

Browse files
authored
Merge branch 'main' into fix-class-loader-type-cache-oom
2 parents 6c1c619 + d1af3f6 commit d4bd334

File tree

4 files changed

+15
-0
lines changed

4 files changed

+15
-0
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Release Notes.
1414
* Bump up cli to the 0.15.0-dev.latest(77b4c49e89c9c000278f44e62729d534f2ec842e) in e2e.
1515
* Bump up apache parent pom to v35.
1616
* Update Maven to 3.6.3 in mvnw.
17+
* Fix OOM due to too many span logs.
1718

1819
All issues and pull requests are [here](https://github.com/apache/skywalking/milestone/242?closed=1)
1920

apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/Config.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ public static class Agent {
9797
*/
9898
public static int TRACE_SEGMENT_REF_LIMIT_PER_SPAN = 500;
9999

100+
/**
101+
* The max number of logs in a single span to keep memory cost estimatable.
102+
*/
103+
public static int LOG_LIMIT_PER_SPAN = 300;
104+
100105
/**
101106
* The max number of spans in a single segment. Through this config item, SkyWalking keep your application
102107
* memory cost estimated.

apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/trace/AbstractTracingSpan.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ public AbstractTracingSpan log(Throwable t) {
175175
if (!errorOccurred && ServiceManager.INSTANCE.findService(StatusCheckService.class).isError(t)) {
176176
errorOccurred();
177177
}
178+
if (logs.size() >= Config.Agent.LOG_LIMIT_PER_SPAN) {
179+
return this;
180+
}
178181
logs.add(new LogDataEntity.Builder().add(new KeyValuePair("event", "error"))
179182
.add(new KeyValuePair("error.kind", t.getClass().getName()))
180183
.add(new KeyValuePair("message", t.getMessage()))
@@ -196,6 +199,9 @@ public AbstractTracingSpan log(long timestampMicroseconds, Map<String, ?> fields
196199
if (logs == null) {
197200
logs = new LinkedList<>();
198201
}
202+
if (logs.size() >= Config.Agent.LOG_LIMIT_PER_SPAN) {
203+
return this;
204+
}
199205
LogDataEntity.Builder builder = new LogDataEntity.Builder();
200206
for (Map.Entry<String, ?> entry : fields.entrySet()) {
201207
builder.add(new KeyValuePair(entry.getKey(), entry.getValue().toString()));

apm-sniffer/config/agent.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ agent.authentication=${SW_AGENT_AUTHENTICATION:}
3636
# The max number of TraceSegmentRef in a single span to keep memory cost estimatable.
3737
agent.trace_segment_ref_limit_per_span=${SW_TRACE_SEGMENT_LIMIT:500}
3838

39+
# The max number of logs in a single span to keep memory cost estimatable.
40+
agent.log_limit_per_span=${SW_LOG_LIMIT_PER_SPAN:500}
41+
3942
# The max amount of spans in a single segment.
4043
# Through this config item, SkyWalking keep your application memory cost estimated.
4144
agent.span_limit_per_segment=${SW_AGENT_SPAN_LIMIT:300}

0 commit comments

Comments
 (0)