Skip to content

Joey/cold start enhancement #636

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "datadog-lambda-js",
"version": "10.122.0",
"version": "10.123.0",
"description": "Lambda client library that supports hybrid tracing in node js",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -29,7 +29,7 @@
"@types/node": "^20.12.10",
"@types/promise-retry": "^1.1.3",
"@types/shimmer": "^1.0.1",
"dd-trace": "^5.40.0",
"dd-trace": "^5.41.1",
"jest": "^27.0.1",
"mock-fs": "4.14.0",
"nock": "13.5.4",
Expand Down
14 changes: 9 additions & 5 deletions src/trace/cold-start-tracer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ export class ColdStartTracer {

private traceTree(reqNode: RequireNode, parentSpan: SpanWrapper | undefined): void {
if (reqNode.endTime - reqNode.startTime < this.minDuration) {
return;
console.log("[Would have been skipped]" + reqNode.filename);

Choose a reason for hiding this comment

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

🟠 Code Quality Violation

Unexpected console statement. (...read more)

Debugging with console is not considered a bad practice, but it's easy to forget about console statements and leave them in production code. There is no need to pollute production builds with debugging statements.

View in Datadog  Leave us feedback  Documentation

// return;
}

if (this.ignoreLibs.includes(reqNode.id)) {
Expand All @@ -102,11 +103,14 @@ export class ColdStartTracer {
this.tracerWrapper.startSpan(this.coldStartSpanOperationName(reqNode.filename), options),
{},
);
if (reqNode.endTime - reqNode.startTime > this.minDuration) {
for (const node of reqNode.children || []) {
this.traceTree(node, newSpan);
}
if (reqNode.endTime - reqNode.startTime < 1) {
console.log(`Duration of ${reqNode.filename} boosted to 1ms`);

Choose a reason for hiding this comment

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

🟠 Code Quality Violation

Unexpected console statement. (...read more)

Debugging with console is not considered a bad practice, but it's easy to forget about console statements and leave them in production code. There is no need to pollute production builds with debugging statements.

View in Datadog  Leave us feedback  Documentation

reqNode.endTime = reqNode.startTime + 1; // Ensure that spans have a duration of at least 1ms
}
for (const node of reqNode.children || []) {
this.traceTree(node, newSpan);
}

newSpan?.finish(reqNode.endTime);
}
}
Loading