@netlify/build 29.31.3 → 29.31.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/core/build.d.ts +0 -1
- package/lib/core/build.js +3 -5
- package/lib/core/flags.d.ts +0 -59
- package/lib/core/flags.js +0 -59
- package/lib/core/main.js +5 -5
- package/lib/core/normalize_flags.d.ts +1 -2
- package/lib/core/normalize_flags.js +0 -1
- package/lib/core/types.d.ts +0 -18
- package/lib/error/report.js +2 -2
- package/lib/steps/error.js +3 -2
- package/lib/steps/run_step.js +1 -1
- package/lib/tracing/main.d.ts +1 -25
- package/lib/tracing/main.js +5 -131
- package/package.json +7 -7
package/lib/core/build.d.ts
CHANGED
package/lib/core/build.js
CHANGED
|
@@ -12,7 +12,6 @@ import { reportStatuses } from '../status/report.js';
|
|
|
12
12
|
import { getDevSteps, getSteps } from '../steps/get.js';
|
|
13
13
|
import { runSteps } from '../steps/run_steps.js';
|
|
14
14
|
import { initTimers, measureDuration } from '../time/main.js';
|
|
15
|
-
import { startTracing } from '../tracing/main.js';
|
|
16
15
|
import { getConfigOpts, loadConfig } from './config.js';
|
|
17
16
|
import { getConstants } from './constants.js';
|
|
18
17
|
import { doDryRun } from './dry.js';
|
|
@@ -28,10 +27,9 @@ export const startBuild = function (flags) {
|
|
|
28
27
|
if (!flags.quiet) {
|
|
29
28
|
logBuildStart(logs);
|
|
30
29
|
}
|
|
31
|
-
const { bugsnagKey,
|
|
32
|
-
const errorMonitor = startErrorMonitor({ flags: {
|
|
33
|
-
|
|
34
|
-
return { ...flagsA, rootTracingContext, debug, systemLogFile, errorMonitor, logs, timers };
|
|
30
|
+
const { bugsnagKey, debug, systemLogFile, ...flagsA } = normalizeFlags(flags, logs);
|
|
31
|
+
const errorMonitor = startErrorMonitor({ flags: { debug, systemLogFile, ...flagsA }, logs, bugsnagKey });
|
|
32
|
+
return { ...flagsA, debug, systemLogFile, errorMonitor, logs, timers };
|
|
35
33
|
};
|
|
36
34
|
const tExecBuild = async function ({ config, defaultConfig, cachedConfig, cachedConfigPath, outputConfigPath, cwd, packagePath, repositoryRoot, apiHost, token, siteId, context, branch, baseRelDir, env: envOpt, debug, systemLogFile, verbose, nodePath, functionsDistDir, edgeFunctionsDistDir, cacheDir, dry, mode, offline, deployId, buildId, testOpts, errorMonitor, errorParams, logs, timers, buildbotServerSocket, sendStatus, saveConfig, featureFlags, timeline, devCommand, quiet, framework, explicitSecretKeys, edgeFunctionsBootstrapURL, eventHandlers, }) {
|
|
37
35
|
const configOpts = getConfigOpts({
|
package/lib/core/flags.d.ts
CHANGED
|
@@ -160,65 +160,6 @@ export const FLAGS: {
|
|
|
160
160
|
describe: string;
|
|
161
161
|
hidden: boolean;
|
|
162
162
|
};
|
|
163
|
-
tracing: {
|
|
164
|
-
describe: string;
|
|
165
|
-
hidden: boolean;
|
|
166
|
-
};
|
|
167
|
-
'tracing.enabled': {
|
|
168
|
-
boolean: boolean;
|
|
169
|
-
describe: string;
|
|
170
|
-
hidden: boolean;
|
|
171
|
-
};
|
|
172
|
-
'tracing.preloadingEnabled': {
|
|
173
|
-
boolean: boolean;
|
|
174
|
-
describe: string;
|
|
175
|
-
hidden: boolean;
|
|
176
|
-
};
|
|
177
|
-
'tracing.apiKey': {
|
|
178
|
-
string: boolean;
|
|
179
|
-
describe: string;
|
|
180
|
-
hidden: boolean;
|
|
181
|
-
};
|
|
182
|
-
'tracing.httpProtocol': {
|
|
183
|
-
string: boolean;
|
|
184
|
-
describe: string;
|
|
185
|
-
hidden: boolean;
|
|
186
|
-
};
|
|
187
|
-
'tracing.host': {
|
|
188
|
-
string: boolean;
|
|
189
|
-
describe: string;
|
|
190
|
-
hidden: boolean;
|
|
191
|
-
};
|
|
192
|
-
'tracing.port': {
|
|
193
|
-
number: boolean;
|
|
194
|
-
describe: string;
|
|
195
|
-
hidden: boolean;
|
|
196
|
-
};
|
|
197
|
-
'tracing.traceId': {
|
|
198
|
-
string: boolean;
|
|
199
|
-
describe: string;
|
|
200
|
-
hidden: boolean;
|
|
201
|
-
};
|
|
202
|
-
'tracing.parentSpanId': {
|
|
203
|
-
string: boolean;
|
|
204
|
-
describe: string;
|
|
205
|
-
hidden: boolean;
|
|
206
|
-
};
|
|
207
|
-
'tracing.sampleRate': {
|
|
208
|
-
number: boolean;
|
|
209
|
-
describe: string;
|
|
210
|
-
hidden: boolean;
|
|
211
|
-
};
|
|
212
|
-
'tracing.traceFlags': {
|
|
213
|
-
number: boolean;
|
|
214
|
-
describe: string;
|
|
215
|
-
hidden: boolean;
|
|
216
|
-
};
|
|
217
|
-
'tracing.baggageFilePath': {
|
|
218
|
-
string: boolean;
|
|
219
|
-
describe: string;
|
|
220
|
-
hidden: boolean;
|
|
221
|
-
};
|
|
222
163
|
offline: {
|
|
223
164
|
boolean: boolean;
|
|
224
165
|
describe: string;
|
package/lib/core/flags.js
CHANGED
|
@@ -193,65 +193,6 @@ Default: false`,
|
|
|
193
193
|
describe: 'Statsd port',
|
|
194
194
|
hidden: true,
|
|
195
195
|
},
|
|
196
|
-
tracing: {
|
|
197
|
-
describe: 'Tracing related options',
|
|
198
|
-
hidden: true,
|
|
199
|
-
},
|
|
200
|
-
'tracing.enabled': {
|
|
201
|
-
boolean: true,
|
|
202
|
-
describe: 'Enable distributed tracing for build',
|
|
203
|
-
hidden: true,
|
|
204
|
-
},
|
|
205
|
-
'tracing.preloadingEnabled': {
|
|
206
|
-
boolean: true,
|
|
207
|
-
describe: 'Enable distributed tracing for build via module preloading, to be removed once fully rolled out',
|
|
208
|
-
hidden: true,
|
|
209
|
-
},
|
|
210
|
-
'tracing.apiKey': {
|
|
211
|
-
string: true,
|
|
212
|
-
describe: 'API Key for the tracing backend provider',
|
|
213
|
-
hidden: true,
|
|
214
|
-
},
|
|
215
|
-
'tracing.httpProtocol': {
|
|
216
|
-
string: true,
|
|
217
|
-
describe: 'Traces backend protocol. HTTP or HTTPS.',
|
|
218
|
-
hidden: true,
|
|
219
|
-
},
|
|
220
|
-
'tracing.host': {
|
|
221
|
-
string: true,
|
|
222
|
-
describe: 'Traces backend host',
|
|
223
|
-
hidden: true,
|
|
224
|
-
},
|
|
225
|
-
'tracing.port': {
|
|
226
|
-
number: true,
|
|
227
|
-
describe: 'Traces backend port',
|
|
228
|
-
hidden: true,
|
|
229
|
-
},
|
|
230
|
-
'tracing.traceId': {
|
|
231
|
-
string: true,
|
|
232
|
-
describe: 'Trace ID used to stitch the emited traces to',
|
|
233
|
-
hidden: true,
|
|
234
|
-
},
|
|
235
|
-
'tracing.parentSpanId': {
|
|
236
|
-
string: true,
|
|
237
|
-
describe: 'Parent Span ID used to stitch the root parent span to',
|
|
238
|
-
hidden: true,
|
|
239
|
-
},
|
|
240
|
-
'tracing.sampleRate': {
|
|
241
|
-
number: true,
|
|
242
|
-
describe: 'Trace sample rate for the given trace ID',
|
|
243
|
-
hidden: true,
|
|
244
|
-
},
|
|
245
|
-
'tracing.traceFlags': {
|
|
246
|
-
number: true,
|
|
247
|
-
describe: 'Trace flags containing the trace settings for the given trace ID',
|
|
248
|
-
hidden: true,
|
|
249
|
-
},
|
|
250
|
-
'tracing.baggageFilePath': {
|
|
251
|
-
string: true,
|
|
252
|
-
describe: '',
|
|
253
|
-
hidden: true,
|
|
254
|
-
},
|
|
255
196
|
offline: {
|
|
256
197
|
boolean: true,
|
|
257
198
|
describe: `Do not send requests to the Netlify API to retrieve site settings.
|
package/lib/core/main.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { setMultiSpanAttributes, getGlobalContext } from '@netlify/opentelemetry-utils';
|
|
1
2
|
import { trace, context } from '@opentelemetry/api';
|
|
2
3
|
import { handleBuildError } from '../error/handle.js';
|
|
3
4
|
import { reportError } from '../error/report.js';
|
|
@@ -5,7 +6,6 @@ import { getSystemLogger } from '../log/logger.js';
|
|
|
5
6
|
import { logTimer, logBuildSuccess } from '../log/messages/core.js';
|
|
6
7
|
import { trackBuildComplete } from '../telemetry/main.js';
|
|
7
8
|
import { reportTimers } from '../time/report.js';
|
|
8
|
-
import { stopTracing, setMultiSpanAttributes } from '../tracing/main.js';
|
|
9
9
|
import { execBuild, startBuild } from './build.js';
|
|
10
10
|
import { reportMetrics } from './report_metrics.js';
|
|
11
11
|
import { getSeverity } from './severity.js';
|
|
@@ -17,7 +17,7 @@ const tracer = trace.getTracer('core');
|
|
|
17
17
|
* @param flags - build configuration CLI flags
|
|
18
18
|
*/
|
|
19
19
|
export async function buildSite(flags = {}) {
|
|
20
|
-
const { errorMonitor, framework, mode, logs, debug, systemLogFile, testOpts, statsdOpts, dry, telemetry, buildId, deployId,
|
|
20
|
+
const { errorMonitor, framework, mode, logs, debug, systemLogFile, testOpts, statsdOpts, dry, telemetry, buildId, deployId, eventHandlers, ...flagsA } = startBuild(flags);
|
|
21
21
|
const errorParams = { errorMonitor, mode, logs, debug, testOpts };
|
|
22
22
|
const systemLog = getSystemLogger(logs, debug, systemLogFile);
|
|
23
23
|
const attributes = {
|
|
@@ -27,7 +27,9 @@ export async function buildSite(flags = {}) {
|
|
|
27
27
|
'site.id': flagsA.siteId,
|
|
28
28
|
'build.info.primary_framework': framework,
|
|
29
29
|
};
|
|
30
|
-
|
|
30
|
+
// Gets the initial root context passed to the build process and adds a series of attributes we're going to use across
|
|
31
|
+
// the trace
|
|
32
|
+
const rootCtx = context.with(getGlobalContext(), () => setMultiSpanAttributes(attributes));
|
|
31
33
|
return await tracer.startActiveSpan('exec-build', {}, rootCtx, async (span) => {
|
|
32
34
|
try {
|
|
33
35
|
const { pluginsOptions, netlifyConfig: netlifyConfigA, siteInfo, userNodeVersion, stepsCount, timers, durationNs, configMutations, metrics, } = await execBuild({
|
|
@@ -103,8 +105,6 @@ export async function buildSite(flags = {}) {
|
|
|
103
105
|
}
|
|
104
106
|
finally {
|
|
105
107
|
span.end();
|
|
106
|
-
// Ensure we flush the resulting spans
|
|
107
|
-
await stopTracing();
|
|
108
108
|
}
|
|
109
109
|
});
|
|
110
110
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BuildFlags, Mode, TestOptions
|
|
1
|
+
import type { BuildFlags, Mode, TestOptions } from './types.js';
|
|
2
2
|
export type ResolvedFlags = {
|
|
3
3
|
env: Record<string, unknown>;
|
|
4
4
|
token: string;
|
|
@@ -32,7 +32,6 @@ export type ResolvedFlags = {
|
|
|
32
32
|
};
|
|
33
33
|
bugsnagKey?: string;
|
|
34
34
|
systemLogFile?: number;
|
|
35
|
-
tracingOpts: TracingOptions;
|
|
36
35
|
};
|
|
37
36
|
/** Normalize CLI flags */
|
|
38
37
|
export declare const normalizeFlags: (flags: Partial<BuildFlags>, logs: any) => ResolvedFlags;
|
|
@@ -22,7 +22,6 @@ export const normalizeFlags = function (flags, logs) {
|
|
|
22
22
|
...rawFlags,
|
|
23
23
|
...telemetryFlag,
|
|
24
24
|
statsdOpts: { ...defaultFlags.statsd, ...rawFlags.statsd },
|
|
25
|
-
tracingOpts: { ...defaultFlags.tracing, ...rawFlags.tracing },
|
|
26
25
|
featureFlags: { ...defaultFlags.featureFlags, ...rawFlags.featureFlags },
|
|
27
26
|
};
|
|
28
27
|
const normalizedFlags = removeFalsy(mergedFlags);
|
package/lib/core/types.d.ts
CHANGED
|
@@ -19,8 +19,6 @@ export type BuildCLIFlags = {
|
|
|
19
19
|
/** The invoking service of netlify build */
|
|
20
20
|
mode: Mode;
|
|
21
21
|
telemetry: boolean;
|
|
22
|
-
/** Distributed tracing properties for this build*/
|
|
23
|
-
tracing: TracingOptions;
|
|
24
22
|
/**
|
|
25
23
|
* Buffer output instead of printing it
|
|
26
24
|
* @default false
|
|
@@ -76,20 +74,4 @@ export type ErrorParam = {
|
|
|
76
74
|
childEnv?: any;
|
|
77
75
|
netlifyConfig?: NetlifyConfig;
|
|
78
76
|
};
|
|
79
|
-
export type TracingOptions = {
|
|
80
|
-
enabled: boolean;
|
|
81
|
-
preloadingEnabled: boolean;
|
|
82
|
-
httpProtocol: string;
|
|
83
|
-
host: string;
|
|
84
|
-
port: number;
|
|
85
|
-
/** API Key used for a dedicated trace provider */
|
|
86
|
-
apiKey: string;
|
|
87
|
-
/** Sample rate being used for this trace, this allows for consistent probability sampling */
|
|
88
|
-
sampleRate: number;
|
|
89
|
-
/** Properties of the root span and trace id used to stitch context */
|
|
90
|
-
traceId: string;
|
|
91
|
-
traceFlags: number;
|
|
92
|
-
parentSpanId: string;
|
|
93
|
-
baggageFilePath: string;
|
|
94
|
-
};
|
|
95
77
|
export {};
|
package/lib/error/report.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isNetlifyMaintainedPlugin } from '../plugins/internal.js';
|
|
2
2
|
import { closeClient, formatTags, normalizeTagName, startClient, validateStatsDOptions, } from '../report/statsd.js';
|
|
3
|
-
import {
|
|
3
|
+
import { addBuildErrorToActiveSpan } from '../tracing/main.js';
|
|
4
4
|
import { getErrorInfo } from './info.js';
|
|
5
5
|
const TOP_PARENT_TAG = 'run_netlify_build';
|
|
6
6
|
/**
|
|
@@ -8,7 +8,7 @@ const TOP_PARENT_TAG = 'run_netlify_build';
|
|
|
8
8
|
* Sends to statsd daemon.
|
|
9
9
|
*/
|
|
10
10
|
export const reportError = async function (error, statsdOpts, framework) {
|
|
11
|
-
|
|
11
|
+
addBuildErrorToActiveSpan(error);
|
|
12
12
|
if (!validateStatsDOptions(statsdOpts)) {
|
|
13
13
|
return;
|
|
14
14
|
}
|
package/lib/steps/error.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { addEventToActiveSpan } from '@netlify/opentelemetry-utils';
|
|
1
2
|
import { cancelBuild } from '../error/cancel.js';
|
|
2
3
|
import { handleBuildError } from '../error/handle.js';
|
|
3
4
|
import { getFullErrorInfo, parseErrorInfo } from '../error/parse/parse.js';
|
|
4
5
|
import { serializeErrorStatus } from '../error/parse/serialize_status.js';
|
|
5
6
|
import { isPluginLocation } from '../error/types.js';
|
|
6
7
|
import { isSoftFailEvent } from '../plugins/events.js';
|
|
7
|
-
import {
|
|
8
|
+
import { addBuildErrorToActiveSpan } from '../tracing/main.js';
|
|
8
9
|
import { isTrustedPlugin } from './plugin.js';
|
|
9
10
|
/**
|
|
10
11
|
* Handle build command errors and plugin errors:
|
|
@@ -16,7 +17,7 @@ import { isTrustedPlugin } from './plugin.js';
|
|
|
16
17
|
* This also computes error statuses that are sent to the API.
|
|
17
18
|
*/
|
|
18
19
|
export const handleStepError = function ({ event, newError, childEnv, mode, api, errorMonitor, deployId, coreStep, netlifyConfig, logs, debug, testOpts, }) {
|
|
19
|
-
|
|
20
|
+
addBuildErrorToActiveSpan(newError);
|
|
20
21
|
// Core steps do not report error statuses
|
|
21
22
|
if (coreStep !== undefined) {
|
|
22
23
|
return { newError };
|
package/lib/steps/run_step.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { setMultiSpanAttributes } from '@netlify/opentelemetry-utils';
|
|
1
2
|
import { trace } from '@opentelemetry/api';
|
|
2
3
|
import { addMutableConstants } from '../core/constants.js';
|
|
3
4
|
import { logStepStart } from '../log/messages/steps.js';
|
|
4
5
|
import { runsAlsoOnBuildFailure, runsOnlyOnBuildFailure } from '../plugins/events.js';
|
|
5
6
|
import { normalizeTagName } from '../report/statsd.js';
|
|
6
7
|
import { measureDuration } from '../time/main.js';
|
|
7
|
-
import { setMultiSpanAttributes } from '../tracing/main.js';
|
|
8
8
|
import { fireCoreStep } from './core_step.js';
|
|
9
9
|
import { firePluginStep } from './plugin.js';
|
|
10
10
|
import { getStepReturn } from './return.js';
|
package/lib/tracing/main.d.ts
CHANGED
|
@@ -1,29 +1,5 @@
|
|
|
1
|
-
import { Context } from '@opentelemetry/api';
|
|
2
|
-
import type { TracingOptions } from '../core/types.js';
|
|
3
|
-
/**
|
|
4
|
-
* Gets the global context to be used when initialising our root span
|
|
5
|
-
* TODO this will move to a shared package (opentelemetry-utils) to scope the usage of this global property there
|
|
6
|
-
*/
|
|
7
|
-
export declare const getGlobalContext: () => Context;
|
|
8
|
-
/**
|
|
9
|
-
* Sets global context to be used when initialising our root span
|
|
10
|
-
* TODO this will move to a shared package (opentelemetry-utils) to scope the usage of this global property there
|
|
11
|
-
*/
|
|
12
|
-
export declare const setGlobalContext: (ctx: Context) => void;
|
|
13
|
-
/** Starts the tracing SDK, if there's already a tracing service this will be a no-op */
|
|
14
|
-
export declare const startTracing: (options: TracingOptions, logger: (...args: any[]) => void) => Context | undefined;
|
|
15
|
-
/** Stops the tracing service if there's one running. This will flush any ongoing events */
|
|
16
|
-
export declare const stopTracing: () => Promise<void>;
|
|
17
|
-
/** Sets attributes to be propagated across child spans under the current active context */
|
|
18
|
-
export declare const setMultiSpanAttributes: (attributes: {
|
|
19
|
-
[key: string]: string;
|
|
20
|
-
}) => Context;
|
|
21
1
|
/** Add error information to the current active span (if any) */
|
|
22
|
-
export declare const
|
|
23
|
-
export declare const addEventToActiveSpan: (eventName: string, attributes?: {
|
|
24
|
-
[key: string]: string;
|
|
25
|
-
} | undefined) => void;
|
|
26
|
-
export declare const loadBaggageFromFile: (baggageFilePath: string) => Context;
|
|
2
|
+
export declare const addBuildErrorToActiveSpan: (error: Error) => void;
|
|
27
3
|
/** Attributes used for the root span of our execution */
|
|
28
4
|
export type RootExecutionAttributes = {
|
|
29
5
|
'build.id': string;
|
package/lib/tracing/main.js
CHANGED
|
@@ -1,141 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { HoneycombSDK } from '@honeycombio/opentelemetry-node';
|
|
3
|
-
import { context, trace, propagation, SpanStatusCode, diag, DiagLogLevel, } from '@opentelemetry/api';
|
|
4
|
-
import { parseKeyPairsIntoRecord } from '@opentelemetry/core/build/src/baggage/utils.js';
|
|
1
|
+
import { addErrorToActiveSpan } from '@netlify/opentelemetry-utils';
|
|
5
2
|
import { isBuildError } from '../error/info.js';
|
|
6
3
|
import { parseErrorInfo } from '../error/parse/parse.js';
|
|
7
4
|
import { buildErrorToTracingAttributes } from '../error/types.js';
|
|
8
|
-
import { ROOT_PACKAGE_JSON } from '../utils/json.js';
|
|
9
|
-
let sdk;
|
|
10
|
-
/** Given a simple logging function return a `DiagLogger`. Used to setup our system logger as the diag logger.*/
|
|
11
|
-
const getOtelLogger = function (logger) {
|
|
12
|
-
const otelLogger = (...args) => {
|
|
13
|
-
// Debug log msgs can be an array of 1 or 2 elements with the second element being an array fo multiple elements
|
|
14
|
-
const msgs = args.flat(1);
|
|
15
|
-
logger('[otel-traces]', ...msgs);
|
|
16
|
-
};
|
|
17
|
-
return {
|
|
18
|
-
debug: otelLogger,
|
|
19
|
-
info: otelLogger,
|
|
20
|
-
error: otelLogger,
|
|
21
|
-
verbose: otelLogger,
|
|
22
|
-
warn: otelLogger,
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* Gets the global context to be used when initialising our root span
|
|
27
|
-
* TODO this will move to a shared package (opentelemetry-utils) to scope the usage of this global property there
|
|
28
|
-
*/
|
|
29
|
-
export const getGlobalContext = function () {
|
|
30
|
-
if (global['NETLIFY_GLOBAL_CONTEXT'] === undefined) {
|
|
31
|
-
return context.active();
|
|
32
|
-
}
|
|
33
|
-
return global['NETLIFY_GLOBAL_CONTEXT'];
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Sets global context to be used when initialising our root span
|
|
37
|
-
* TODO this will move to a shared package (opentelemetry-utils) to scope the usage of this global property there
|
|
38
|
-
*/
|
|
39
|
-
export const setGlobalContext = function (ctx) {
|
|
40
|
-
global['NETLIFY_GLOBAL_CONTEXT'] = ctx;
|
|
41
|
-
};
|
|
42
|
-
/** Starts the tracing SDK, if there's already a tracing service this will be a no-op */
|
|
43
|
-
export const startTracing = function (options, logger) {
|
|
44
|
-
// As we roll out the new way to initialise the SDK, if we detect preloading is enabled,
|
|
45
|
-
// it means we're using `@netlify/opentelemetry-sdk-setup` so we must get the initial context from the global store
|
|
46
|
-
if (options.preloadingEnabled) {
|
|
47
|
-
return getGlobalContext();
|
|
48
|
-
}
|
|
49
|
-
if (!options.enabled)
|
|
50
|
-
return;
|
|
51
|
-
if (sdk)
|
|
52
|
-
return;
|
|
53
|
-
sdk = new HoneycombSDK({
|
|
54
|
-
serviceName: ROOT_PACKAGE_JSON.name,
|
|
55
|
-
protocol: 'grpc',
|
|
56
|
-
apiKey: options.apiKey,
|
|
57
|
-
endpoint: `${options.httpProtocol}://${options.host}:${options.port}`,
|
|
58
|
-
sampleRate: options.sampleRate,
|
|
59
|
-
// Turn off auto resource detection so that we fully control the attributes we export
|
|
60
|
-
autoDetectResources: false,
|
|
61
|
-
});
|
|
62
|
-
// Set the diagnostics logger to our system logger. We also need to suppress the override msg
|
|
63
|
-
// in case there's a default console logger already registered (it would log a msg to it)
|
|
64
|
-
diag.setLogger(getOtelLogger(logger), { logLevel: DiagLogLevel.INFO, suppressOverrideMessage: true });
|
|
65
|
-
sdk.start();
|
|
66
|
-
// Loads the contents of the passed baggageFilePath into the baggage
|
|
67
|
-
const baggageCtx = loadBaggageFromFile(options.baggageFilePath);
|
|
68
|
-
// Sets the current trace ID and span ID based on the options received
|
|
69
|
-
// this is used as a way to propagate trace context from Buildbot
|
|
70
|
-
const ctx = trace.setSpanContext(baggageCtx, {
|
|
71
|
-
traceId: options.traceId,
|
|
72
|
-
spanId: options.parentSpanId,
|
|
73
|
-
traceFlags: options.traceFlags,
|
|
74
|
-
isRemote: true,
|
|
75
|
-
});
|
|
76
|
-
return ctx;
|
|
77
|
-
};
|
|
78
|
-
/** Stops the tracing service if there's one running. This will flush any ongoing events */
|
|
79
|
-
export const stopTracing = async function () {
|
|
80
|
-
if (!sdk)
|
|
81
|
-
return;
|
|
82
|
-
try {
|
|
83
|
-
// The shutdown method might return an error if we fail to flush the traces
|
|
84
|
-
// We handle it and use our diagnostics logger
|
|
85
|
-
await sdk.shutdown();
|
|
86
|
-
sdk = undefined;
|
|
87
|
-
}
|
|
88
|
-
catch (e) {
|
|
89
|
-
diag.error(e);
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
/** Sets attributes to be propagated across child spans under the current active context */
|
|
93
|
-
export const setMultiSpanAttributes = function (attributes) {
|
|
94
|
-
const currentBaggage = propagation.getBaggage(context.active());
|
|
95
|
-
// Create a baggage if there's none
|
|
96
|
-
let baggage = currentBaggage === undefined ? propagation.createBaggage() : currentBaggage;
|
|
97
|
-
Object.entries(attributes).forEach(([key, value]) => {
|
|
98
|
-
baggage = baggage.setEntry(key, { value });
|
|
99
|
-
});
|
|
100
|
-
return propagation.setBaggage(context.active(), baggage);
|
|
101
|
-
};
|
|
102
5
|
/** Add error information to the current active span (if any) */
|
|
103
|
-
export const
|
|
104
|
-
|
|
105
|
-
if (!span)
|
|
106
|
-
return;
|
|
6
|
+
export const addBuildErrorToActiveSpan = function (error) {
|
|
7
|
+
let buildErrorAttributes;
|
|
107
8
|
if (isBuildError(error)) {
|
|
108
9
|
const buildError = parseErrorInfo(error);
|
|
109
10
|
if (buildError.severity == 'none')
|
|
110
11
|
return;
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
span.recordException(error);
|
|
114
|
-
span.setStatus({
|
|
115
|
-
code: SpanStatusCode.ERROR,
|
|
116
|
-
message: error.message,
|
|
117
|
-
});
|
|
118
|
-
};
|
|
119
|
-
export const addEventToActiveSpan = function (eventName, attributes) {
|
|
120
|
-
const span = trace.getActiveSpan();
|
|
121
|
-
if (!span)
|
|
122
|
-
return;
|
|
123
|
-
span.addEvent(eventName, attributes);
|
|
124
|
-
};
|
|
125
|
-
//** Loads the baggage attributes from a baggabe file which follows W3C Baggage specification */
|
|
126
|
-
export const loadBaggageFromFile = function (baggageFilePath) {
|
|
127
|
-
if (baggageFilePath.length === 0) {
|
|
128
|
-
diag.warn('Empty baggage file path provided, no context loaded');
|
|
129
|
-
return context.active();
|
|
130
|
-
}
|
|
131
|
-
let baggageString;
|
|
132
|
-
try {
|
|
133
|
-
baggageString = readFileSync(baggageFilePath, 'utf-8');
|
|
134
|
-
}
|
|
135
|
-
catch (error) {
|
|
136
|
-
diag.error(error);
|
|
137
|
-
return context.active();
|
|
12
|
+
buildErrorAttributes = buildErrorToTracingAttributes(buildError);
|
|
138
13
|
}
|
|
139
|
-
|
|
140
|
-
return setMultiSpanAttributes(parsedBaggage);
|
|
14
|
+
addErrorToActiveSpan(error, buildErrorAttributes);
|
|
141
15
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/build",
|
|
3
|
-
"version": "29.31.
|
|
3
|
+
"version": "29.31.4",
|
|
4
4
|
"description": "Netlify build module",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./lib/index.js",
|
|
@@ -65,19 +65,18 @@
|
|
|
65
65
|
"license": "MIT",
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"@bugsnag/js": "^7.0.0",
|
|
68
|
-
"@honeycombio/opentelemetry-node": "^0.5.0",
|
|
69
68
|
"@netlify/blobs": "^6.3.1",
|
|
70
69
|
"@netlify/cache-utils": "^5.1.5",
|
|
71
|
-
"@netlify/config": "^20.10.
|
|
70
|
+
"@netlify/config": "^20.10.1",
|
|
72
71
|
"@netlify/edge-bundler": "10.1.3",
|
|
73
72
|
"@netlify/framework-info": "^9.8.10",
|
|
74
73
|
"@netlify/functions-utils": "^5.2.46",
|
|
75
74
|
"@netlify/git-utils": "^5.1.1",
|
|
75
|
+
"@netlify/opentelemetry-utils": "^1.0.1",
|
|
76
76
|
"@netlify/plugins-list": "^6.73.0",
|
|
77
77
|
"@netlify/run-utils": "^5.1.1",
|
|
78
78
|
"@netlify/zip-it-and-ship-it": "9.28.2",
|
|
79
|
-
"@opentelemetry/api": "
|
|
80
|
-
"@opentelemetry/core": "^1.17.1",
|
|
79
|
+
"@opentelemetry/api": "~1.6.0",
|
|
81
80
|
"@sindresorhus/slugify": "^2.0.0",
|
|
82
81
|
"ansi-escapes": "^6.0.0",
|
|
83
82
|
"chalk": "^5.0.0",
|
|
@@ -126,6 +125,7 @@
|
|
|
126
125
|
},
|
|
127
126
|
"devDependencies": {
|
|
128
127
|
"@netlify/nock-udp": "^3.1.2",
|
|
128
|
+
"@opentelemetry/sdk-trace-base": "^1.18.1",
|
|
129
129
|
"@types/node": "^14.18.53",
|
|
130
130
|
"atob": "^2.1.2",
|
|
131
131
|
"ava": "^4.0.0",
|
|
@@ -147,7 +147,7 @@
|
|
|
147
147
|
"yarn": "^1.22.4"
|
|
148
148
|
},
|
|
149
149
|
"peerDependencies": {
|
|
150
|
-
"@netlify/opentelemetry-sdk-setup": "^1.0.
|
|
150
|
+
"@netlify/opentelemetry-sdk-setup": "^1.0.2"
|
|
151
151
|
},
|
|
152
152
|
"peerDependenciesMeta": {
|
|
153
153
|
"@netlify/opentelemetry-sdk-setup": {
|
|
@@ -157,5 +157,5 @@
|
|
|
157
157
|
"engines": {
|
|
158
158
|
"node": "^14.16.0 || >=16.0.0"
|
|
159
159
|
},
|
|
160
|
-
"gitHead": "
|
|
160
|
+
"gitHead": "9c4fb7ba7f7cecedfbeced71de24e01ef0828b90"
|
|
161
161
|
}
|