Skip to content

Commit 7aec655

Browse files
authored
fix(sdk): headers as an argument in initialization (#569)
1 parent 432fd1f commit 7aec655

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

packages/traceloop-sdk/src/lib/interfaces/initialize-options.interface.ts

+5
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ export interface InitializeOptions {
6464
*/
6565
exporter?: SpanExporter;
6666

67+
/**
68+
* The headers to be sent with the traces data. Optional.
69+
*/
70+
headers?: Record<string, string>;
71+
6772
/**
6873
* The OpenTelemetry SpanProcessor to be used for processing traces data. Optional.
6974
* Defaults to the BatchSpanProcessor.

packages/traceloop-sdk/src/lib/tracing/index.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,11 @@ export const startTracing = (options: InitializeOptions) => {
261261
});
262262
}
263263

264-
const headers = process.env.TRACELOOP_HEADERS
265-
? baggageUtils.parseKeyPairsIntoRecord(process.env.TRACELOOP_HEADERS)
266-
: { Authorization: `Bearer ${options.apiKey}` };
264+
const headers =
265+
options.headers ||
266+
(process.env.TRACELOOP_HEADERS
267+
? baggageUtils.parseKeyPairsIntoRecord(process.env.TRACELOOP_HEADERS)
268+
: { Authorization: `Bearer ${options.apiKey}` });
267269

268270
const traceExporter =
269271
options.exporter ??

0 commit comments

Comments
 (0)