Skip to content
This repository was archived by the owner on Jan 21, 2026. It is now read-only.

feat: emit an error log on potential memory leak scenario#870

Merged
kjin merged 4 commits intomasterfrom
warn-leak
Oct 3, 2018
Merged

feat: emit an error log on potential memory leak scenario#870
kjin merged 4 commits intomasterfrom
warn-leak

Conversation

@kjin
Copy link
Copy Markdown
Contributor

@kjin kjin commented Sep 25, 2018

Given that the scenario #838 is likely caused by context confusion on long-running requests, this warning should help us determine whether a memory leak is due to an intrinsic design detail to the agent, or context confusion. Emitting this warning is a clear sign of the latter (the remedy would be to identify the userspace queueing mechanism that breaks context, and patch it/request that it support async resources).

@kjin kjin requested a review from a team September 25, 2018 18:33
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Sep 25, 2018
@ghost ghost assigned kjin Sep 25, 2018
@kjin kjin mentioned this pull request Sep 27, 2018
Copy link
Copy Markdown
Contributor

@soldair soldair left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm.
no test for it but the warning is pretty soft, and doesn't seem to reference properties that are likely to be undefined. so un likely to crash. 👍

Comment thread src/trace-api.ts
Copy link
Copy Markdown
Contributor

@ofrobots ofrobots left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a value in a hard limit also?

Comment thread src/config.ts Outdated
Comment thread src/trace-api.ts
// As in the previous case, a root span with a large number of child
// spans suggests a memory leak stemming from context confusion. This
// is likely due to userspace task queues or Promise implementations.
this.logger!.warn(`TraceApi#createChildSpan: [${

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@kjin kjin changed the title feat: warn more on potential memory leaks feat: emit an error log on potential memory leak scenario Sep 28, 2018
Copy link
Copy Markdown
Contributor

@ofrobots ofrobots left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code is looking fine. I left some comments about the UX.

Comment thread src/trace-api.ts
options.name}] will cause the trace with root span [${
rootSpan.span.name}] to contain more than ${
this.config!
.spansPerTraceSoftLimit} spans. This is likely a memory leak.`);

This comment was marked as spam.

This comment was marked as spam.

Comment thread src/config.ts
rootSpanNameOverride: (name: string) => name,
clsMechanism: 'auto' as CLSMechanism,
spansPerTraceSoftLimit: 200,
spansPerTraceHardLimit: 1000,

This comment was marked as spam.

This comment was marked as spam.

Comment thread src/config.ts Outdated
/**
* The maximum number of local spans per trace to allow in total. Creating
* more spans will cause the agent to log an error. (This limit does not apply
* when using RootSpan to create child spans.)

This comment was marked as spam.

@ghost ghost assigned JustinBeckwith Oct 2, 2018
@kjin kjin merged commit 0072e5f into master Oct 3, 2018
@mikelueck
Copy link
Copy Markdown

Guys the promotion of these logs from "warn" to "error" is causing problems. Specifically line 241 in trace-api.ts.
Is an error required here?

@ofrobots ofrobots deleted the warn-leak branch October 13, 2018 05:37
@ofrobots
Copy link
Copy Markdown
Contributor

@mikelueck this was a mistake. The issue is fixed in #882 and released as the latest version of the module.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants