Skip to content

Commit 798f64c

Browse files
authored
feat: bump deps (#568)
* feat: bump deps * fix: types for console/http patches * fix: remove unused import
1 parent 5e29f63 commit 798f64c

File tree

3 files changed

+853
-866
lines changed

3 files changed

+853
-866
lines changed

src/trace/patch-console.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import * as shimmer from "shimmer";
22
import { inspect } from "util";
33

4+
type Console = typeof console;
5+
6+
type wrappedConsole = Console & { [K in LogMethod]: { __wrapped?: boolean } };
7+
48
import { getLogLevel, LogLevel, setLogLevel } from "../utils/log";
59
import { TraceContextService } from "./trace-context-service";
610

@@ -10,7 +14,7 @@ type LogMethod = "log" | "info" | "debug" | "error" | "warn" | "trace";
1014
* Patches console output to include DataDog's trace context.
1115
* @param contextService Provides up to date tracing context.
1216
*/
13-
export function patchConsole(cnsle: Console, contextService: TraceContextService) {
17+
export function patchConsole(cnsle: wrappedConsole, contextService: TraceContextService) {
1418
patchMethod(cnsle, "log", contextService);
1519
patchMethod(cnsle, "info", contextService);
1620
patchMethod(cnsle, "debug", contextService);
@@ -31,7 +35,7 @@ export function unpatchConsole(cnsle: Console) {
3135
unpatchMethod(cnsle, "trace");
3236
}
3337

34-
function patchMethod(mod: Console, method: LogMethod, contextService: TraceContextService) {
38+
function patchMethod(mod: wrappedConsole, method: LogMethod, contextService: TraceContextService) {
3539
if (mod[method].__wrapped !== undefined) {
3640
return; // Only patch once
3741
}
@@ -81,7 +85,7 @@ function patchMethod(mod: Console, method: LogMethod, contextService: TraceConte
8185
};
8286
});
8387
}
84-
function unpatchMethod(mod: Console, method: LogMethod) {
88+
function unpatchMethod(mod: wrappedConsole, method: LogMethod) {
8589
if (mod[method].__wrapped !== undefined) {
8690
shimmer.unwrap(mod, method);
8791
}

src/trace/patch-http.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
import http from "http";
22
import https from "https";
3+
type http = typeof http;
4+
type https = typeof https;
5+
36
import * as shimmer from "shimmer";
47
import { parse, URL } from "url";
58
import { TraceContextService } from "./trace-context-service";
69
import { DatadogTraceHeaders } from "./context/extractor";
710

811
type RequestCallback = (res: http.IncomingMessage) => void;
912

13+
type wrappedHttp =
14+
| (http & { get: { __wrapped?: boolean }; request: { __wrapped?: boolean } })
15+
| (https & { get: { __wrapped?: boolean }; request: { __wrapped?: boolean } });
16+
1017
/**
1118
* Patches outgoing http calls to include DataDog's tracing headers.
1219
* @param contextService Provides up to date tracing context.
@@ -32,7 +39,7 @@ export function unpatchHttp() {
3239
unpatchMethod(https, "get");
3340
}
3441

35-
function patchMethod(mod: typeof http | typeof https, method: "get" | "request", contextService: TraceContextService) {
42+
function patchMethod(mod: wrappedHttp, method: "get" | "request", contextService: TraceContextService) {
3643
if (mod[method].__wrapped !== undefined) return; // Only patch once
3744

3845
shimmer.wrap(mod, method, (original) => {
@@ -48,7 +55,7 @@ function patchMethod(mod: typeof http | typeof https, method: "get" | "request",
4855
return fn as any;
4956
});
5057
}
51-
function unpatchMethod(mod: typeof http | typeof https, method: "get" | "request") {
58+
function unpatchMethod(mod: wrappedHttp, method: "get" | "request") {
5259
if (mod[method].__wrapped !== undefined) {
5360
shimmer.unwrap(mod, method);
5461
}

0 commit comments

Comments
 (0)