From 6b41d55bd3e651f1c575f8dde9f88dd807563aa0 Mon Sep 17 00:00:00 2001 From: melikhov Date: Tue, 19 Sep 2023 20:38:02 +0300 Subject: [PATCH 1/2] feat: add requestId --- src/lib/context.ts | 3 ++- src/types.ts | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/lib/context.ts b/src/lib/context.ts index 0e30fe9..0e316a3 100644 --- a/src/lib/context.ts +++ b/src/lib/context.ts @@ -214,7 +214,8 @@ export class AppContext { getMetadata() { if (this.span) { - const metadata = {}; + const requestId = this.get('requestId'); + const metadata = {requestId}; this.tracer.inject(this.span, FORMAT_HTTP_HEADERS, metadata); return metadata; } else { diff --git a/src/types.ts b/src/types.ts index b849edd..3c29700 100644 --- a/src/types.ts +++ b/src/types.ts @@ -42,7 +42,9 @@ export interface AppConfig { appTelemetryChMirrorToLogs?: boolean; } -export interface AppContextParams {} +export interface AppContextParams { + requestId?: string; +} export interface AppDynamicConfig {} From 1ff5cc354640c9efbb1d79f64bb2e72301a3edff Mon Sep 17 00:00:00 2001 From: Andrey Melikhov Date: Tue, 19 Sep 2023 21:16:26 +0300 Subject: [PATCH 2/2] Update context.ts Co-authored-by: Gadzhi Gadzhiev --- src/lib/context.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/context.ts b/src/lib/context.ts index 0e316a3..35cbeaa 100644 --- a/src/lib/context.ts +++ b/src/lib/context.ts @@ -215,7 +215,7 @@ export class AppContext { getMetadata() { if (this.span) { const requestId = this.get('requestId'); - const metadata = {requestId}; + const metadata = requestId ? {requestId} : {}; this.tracer.inject(this.span, FORMAT_HTTP_HEADERS, metadata); return metadata; } else {