Skip to content

Commit

Permalink
feat: add support to dynamic header on legacy config
Browse files Browse the repository at this point in the history
  • Loading branch information
bozzelliandrea committed Nov 29, 2024
1 parent fc94e46 commit a125882
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/
export interface OTLPExporterConfigBase {
headers?: Record<string, string>;
headers?: Record<string, string> | (() => Record<string, string>);
url?: string;
concurrencyLimit?: number;
/** Maximum time the OTLP exporter will wait for each batch export.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,16 @@ export function validateTimeoutMillis(timeoutMillis: number) {
}

export function wrapStaticHeadersInFunction(
headers: Record<string, string> | undefined
headers: Record<string, string> | (() => Record<string, string>) | undefined
): (() => Record<string, string>) | undefined {
if (headers == null) {
return undefined;
}

if (headers instanceof Function) {
return headers;

Check warning on line 52 in experimental/packages/otlp-exporter-base/src/configuration/shared-configuration.ts

View check run for this annotation

Codecov / codecov/patch

experimental/packages/otlp-exporter-base/src/configuration/shared-configuration.ts#L52

Added line #L52 was not covered by tests
}

return () => headers;
}

Expand Down

0 comments on commit a125882

Please sign in to comment.