From a125882f4cdc0d9028c64ef5d157b0eb0452eff9 Mon Sep 17 00:00:00 2001 From: bozzelliandrea Date: Fri, 29 Nov 2024 15:49:19 +0100 Subject: [PATCH] feat: add support to dynamic header on legacy config --- .../src/configuration/legacy-base-configuration.ts | 2 +- .../src/configuration/shared-configuration.ts | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/experimental/packages/otlp-exporter-base/src/configuration/legacy-base-configuration.ts b/experimental/packages/otlp-exporter-base/src/configuration/legacy-base-configuration.ts index 8a36b267ddf..d00385bedef 100644 --- a/experimental/packages/otlp-exporter-base/src/configuration/legacy-base-configuration.ts +++ b/experimental/packages/otlp-exporter-base/src/configuration/legacy-base-configuration.ts @@ -14,7 +14,7 @@ * limitations under the License. */ export interface OTLPExporterConfigBase { - headers?: Record; + headers?: Record | (() => Record); url?: string; concurrencyLimit?: number; /** Maximum time the OTLP exporter will wait for each batch export. diff --git a/experimental/packages/otlp-exporter-base/src/configuration/shared-configuration.ts b/experimental/packages/otlp-exporter-base/src/configuration/shared-configuration.ts index d9d589e3699..9cfbf942560 100644 --- a/experimental/packages/otlp-exporter-base/src/configuration/shared-configuration.ts +++ b/experimental/packages/otlp-exporter-base/src/configuration/shared-configuration.ts @@ -42,12 +42,16 @@ export function validateTimeoutMillis(timeoutMillis: number) { } export function wrapStaticHeadersInFunction( - headers: Record | undefined + headers: Record | (() => Record) | undefined ): (() => Record) | undefined { if (headers == null) { return undefined; } + if (headers instanceof Function) { + return headers; + } + return () => headers; }