Skip to content

Commit 21cabbf

Browse files
authored
Merge pull request #52 from DataDog/stephenf/fix-http-patching
Don't unpatch HTTP lib if the Datadog tracer is initialized
2 parents 291ff1d + 577c32e commit 21cabbf

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "datadog-lambda-js",
3-
"version": "2.16.0",
3+
"version": "2.17.0",
44
"description": "Lambda client library that supports hybrid tracing in node js",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/trace/listener.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export class TraceListener {
5050
logDebug("Didn't patch console output with trace context");
5151
}
5252

53+
// If the DD tracer is initialized then it's doing http patching so we don't again here
5354
if (this.config.autoPatchHTTP && !tracerInitialized) {
5455
logDebug("Patching HTTP libraries");
5556
patchHttp(this.contextService);
@@ -63,7 +64,9 @@ export class TraceListener {
6364
}
6465

6566
public async onCompleteInvocation() {
66-
if (this.config.autoPatchHTTP) {
67+
// If the DD tracer is initialized it manages patching of the http lib on its own
68+
const tracerInitialized = this.tracerWrapper.isTracerAvailable;
69+
if (this.config.autoPatchHTTP && !tracerInitialized) {
6770
logDebug("Unpatching HTTP libraries");
6871
unpatchHttp();
6972
}

0 commit comments

Comments
 (0)