Skip to content

Commit

Permalink
feat: expose flag to set baggageFilePath
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Climent committed Oct 24, 2023
1 parent cd7d0d6 commit 1955ea5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions packages/build/src/core/flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,11 @@ Default: false`,
describe: 'Trace flags containing the trace settings for the given trace ID',
hidden: true,
},
'tracing.baggageFilePath': {
string: true,
describe: '',
hidden: true,
},
offline: {
boolean: true,
describe: `Do not send requests to the Netlify API to retrieve site settings.
Expand Down
1 change: 1 addition & 0 deletions packages/build/src/core/normalize_flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ const getDefaultFlags = function ({ env: envOpt = {} }, combinedEnv) {
sampleRate: 1,
httpProtocol: DEFAULT_OTEL_ENDPOINT_PROTOCOL,
port: DEFAULT_OTEL_TRACING_PORT,
baggageFilePath: '',
},
timeline: 'build',
quiet: false,
Expand Down
1 change: 1 addition & 0 deletions packages/build/src/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,5 @@ export type TracingOptions = {
traceId: string
traceFlags: number
parentSpanId: string
baggageFilePath: string
}
7 changes: 6 additions & 1 deletion packages/build/src/tracing/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,17 @@ export const startTracing = function (options: TracingOptions, logger: (...args:

// Sets the current trace ID and span ID based on the options received
// this is used as a way to propagate trace context from Buildbot
return trace.setSpanContext(context.active(), {
const ctx = trace.setSpanContext(context.active(), {
traceId: options.traceId,
spanId: options.parentSpanId,
traceFlags: options.traceFlags,
isRemote: true,
})

// Loads the contents of the passed baggageFilePath into the baggage
loadBaggageFromFile(options.baggageFilePath)

return ctx
}

/** Stops the tracing service if there's one running. This will flush any ongoing events */
Expand Down

0 comments on commit 1955ea5

Please sign in to comment.