@netlify/build 29.25.0 → 29.26.0
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/steps/error.js +8 -2
- package/lib/tracing/main.d.ts +3 -0
- package/lib/tracing/main.js +14 -0
- package/package.json +2 -2
package/lib/steps/error.js
CHANGED
|
@@ -3,7 +3,7 @@ import { handleBuildError } from '../error/handle.js';
|
|
|
3
3
|
import { getFullErrorInfo, parseErrorInfo } from '../error/parse/parse.js';
|
|
4
4
|
import { serializeErrorStatus } from '../error/parse/serialize_status.js';
|
|
5
5
|
import { isSoftFailEvent } from '../plugins/events.js';
|
|
6
|
-
import { addErrorToActiveSpan } from '../tracing/main.js';
|
|
6
|
+
import { addErrorToActiveSpan, addEventToActiveSpan } from '../tracing/main.js';
|
|
7
7
|
// Handle build command errors and plugin errors:
|
|
8
8
|
// - usually, propagate the error to make the build stop.
|
|
9
9
|
// - `utils.build.cancelBuild()` also cancels the build by calling the API
|
|
@@ -18,7 +18,7 @@ export const handleStepError = function ({ event, newError, childEnv, mode, api,
|
|
|
18
18
|
return { newError };
|
|
19
19
|
}
|
|
20
20
|
const fullErrorInfo = getFullErrorInfo({ error: newError, colors: false, debug });
|
|
21
|
-
const { type } = fullErrorInfo;
|
|
21
|
+
const { errorInfo: { location: { packageName } = {} }, message, title, type, } = fullErrorInfo;
|
|
22
22
|
if (type === 'failPlugin' || isSoftFailEvent(event)) {
|
|
23
23
|
return handleFailPlugin({
|
|
24
24
|
fullErrorInfo,
|
|
@@ -33,6 +33,12 @@ export const handleStepError = function ({ event, newError, childEnv, mode, api,
|
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
if (type === 'cancelBuild') {
|
|
36
|
+
const cancellationAttributes = {
|
|
37
|
+
'build.cancellation.title': title,
|
|
38
|
+
'build.cancellation.message': message,
|
|
39
|
+
'build.cancellation.packageName': packageName,
|
|
40
|
+
};
|
|
41
|
+
addEventToActiveSpan('build.cancelled', cancellationAttributes);
|
|
36
42
|
return handleCancelBuild({ fullErrorInfo, newError, api, deployId });
|
|
37
43
|
}
|
|
38
44
|
return handleFailBuild({ fullErrorInfo, newError });
|
package/lib/tracing/main.d.ts
CHANGED
|
@@ -9,6 +9,9 @@ export declare const setMultiSpanAttributes: (attributes: {
|
|
|
9
9
|
}) => import("@opentelemetry/api").Context;
|
|
10
10
|
/** Add error information to the current active span (if any) */
|
|
11
11
|
export declare const addErrorToActiveSpan: (error: Error) => void;
|
|
12
|
+
export declare const addEventToActiveSpan: (eventName: string, attributes?: {
|
|
13
|
+
[key: string]: string;
|
|
14
|
+
} | undefined) => void;
|
|
12
15
|
export declare const loadBaggageFromFile: (baggageFilePath: string) => import("@opentelemetry/api").Context;
|
|
13
16
|
/** Attributes used for the root span of our execution */
|
|
14
17
|
export type RootExecutionAttributes = {
|
package/lib/tracing/main.js
CHANGED
|
@@ -2,6 +2,8 @@ import { readFileSync } from 'node:fs';
|
|
|
2
2
|
import { HoneycombSDK } from '@honeycombio/opentelemetry-node';
|
|
3
3
|
import { context, trace, propagation, SpanStatusCode, diag, DiagLogLevel } from '@opentelemetry/api';
|
|
4
4
|
import { parseKeyPairsIntoRecord } from '@opentelemetry/core/build/src/baggage/utils.js';
|
|
5
|
+
import { isBuildError } from '../error/info.js';
|
|
6
|
+
import { parseErrorInfo } from '../error/parse/parse.js';
|
|
5
7
|
import { ROOT_PACKAGE_JSON } from '../utils/json.js';
|
|
6
8
|
let sdk;
|
|
7
9
|
/** Given a simple logging function return a `DiagLogger`. Used to setup our system logger as the diag logger.*/
|
|
@@ -79,12 +81,24 @@ export const addErrorToActiveSpan = function (error) {
|
|
|
79
81
|
const span = trace.getActiveSpan();
|
|
80
82
|
if (!span)
|
|
81
83
|
return;
|
|
84
|
+
if (isBuildError(error)) {
|
|
85
|
+
const { severity, type } = parseErrorInfo(error);
|
|
86
|
+
if (severity == 'none')
|
|
87
|
+
return;
|
|
88
|
+
span.setAttributes({ severity, type });
|
|
89
|
+
}
|
|
82
90
|
span.recordException(error);
|
|
83
91
|
span.setStatus({
|
|
84
92
|
code: SpanStatusCode.ERROR,
|
|
85
93
|
message: error.message,
|
|
86
94
|
});
|
|
87
95
|
};
|
|
96
|
+
export const addEventToActiveSpan = function (eventName, attributes) {
|
|
97
|
+
const span = trace.getActiveSpan();
|
|
98
|
+
if (!span)
|
|
99
|
+
return;
|
|
100
|
+
span.addEvent(eventName, attributes);
|
|
101
|
+
};
|
|
88
102
|
//** Loads the baggage attributes from a baggabe file which follows W3C Baggage specification */
|
|
89
103
|
export const loadBaggageFromFile = function (baggageFilePath) {
|
|
90
104
|
if (baggageFilePath.length === 0) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/build",
|
|
3
|
-
"version": "29.
|
|
3
|
+
"version": "29.26.0",
|
|
4
4
|
"description": "Netlify build module",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./lib/index.js",
|
|
@@ -146,5 +146,5 @@
|
|
|
146
146
|
"engines": {
|
|
147
147
|
"node": "^14.16.0 || >=16.0.0"
|
|
148
148
|
},
|
|
149
|
-
"gitHead": "
|
|
149
|
+
"gitHead": "147c3b3639a47b840490e6c0888f99812d8d8c6b"
|
|
150
150
|
}
|