@netlify/build 29.15.0 → 29.15.1
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.js +2 -2
- package/lib/core/flags.js +10 -0
- package/lib/core/main.js +3 -3
- package/lib/core/normalize_flags.js +9 -1
- package/lib/steps/run_step.js +3 -2
- package/lib/tracing/main.js +11 -11
- package/package.json +5 -7
package/lib/core/build.js
CHANGED
|
@@ -30,8 +30,8 @@ export const startBuild = function (flags) {
|
|
|
30
30
|
}
|
|
31
31
|
const { bugsnagKey, tracingOpts, debug, systemLogFile, ...flagsA } = normalizeFlags(flags, logs);
|
|
32
32
|
const errorMonitor = startErrorMonitor({ flags: { tracingOpts, debug, systemLogFile, ...flagsA }, logs, bugsnagKey });
|
|
33
|
-
startTracing(tracingOpts, getSystemLogger(logs, debug, systemLogFile));
|
|
34
|
-
return { ...flagsA, debug, systemLogFile, errorMonitor, logs, timers };
|
|
33
|
+
const rootTracingContext = startTracing(tracingOpts, getSystemLogger(logs, debug, systemLogFile));
|
|
34
|
+
return { ...flagsA, rootTracingContext, debug, systemLogFile, errorMonitor, logs, timers };
|
|
35
35
|
};
|
|
36
36
|
const tExecBuild = async function ({ config, defaultConfig, cachedConfig, cachedConfigPath, outputConfigPath, cwd, 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, }) {
|
|
37
37
|
const configOpts = getConfigOpts({
|
package/lib/core/flags.js
CHANGED
|
@@ -198,6 +198,16 @@ Default: false`,
|
|
|
198
198
|
describe: 'Enable distributed tracing for build',
|
|
199
199
|
hidden: true,
|
|
200
200
|
},
|
|
201
|
+
'tracing.apiKey': {
|
|
202
|
+
string: true,
|
|
203
|
+
describe: 'API Key for the tracing backend provider',
|
|
204
|
+
hidden: true,
|
|
205
|
+
},
|
|
206
|
+
'tracing.httpProtocol': {
|
|
207
|
+
string: true,
|
|
208
|
+
describe: 'Traces backend protocol. HTTP or HTTPS.',
|
|
209
|
+
hidden: true,
|
|
210
|
+
},
|
|
201
211
|
'tracing.host': {
|
|
202
212
|
string: true,
|
|
203
213
|
describe: 'Traces backend host',
|
package/lib/core/main.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { trace } from '@opentelemetry/api';
|
|
1
|
+
import { trace, context } from '@opentelemetry/api';
|
|
2
2
|
import { handleBuildError } from '../error/handle.js';
|
|
3
3
|
import { reportError } from '../error/report.js';
|
|
4
4
|
import { getSystemLogger } from '../log/logger.js';
|
|
@@ -19,7 +19,7 @@ const tracer = trace.getTracer('core');
|
|
|
19
19
|
* @param flags - build configuration CLI flags
|
|
20
20
|
*/
|
|
21
21
|
export default async function buildSite(flags = {}) {
|
|
22
|
-
const { errorMonitor, framework, mode, logs, debug, systemLogFile, testOpts, statsdOpts, dry, telemetry, buildId, deployId, ...flagsA } = startBuild(flags);
|
|
22
|
+
const { errorMonitor, framework, mode, logs, debug, systemLogFile, testOpts, statsdOpts, dry, telemetry, buildId, deployId, rootTracingContext, ...flagsA } = startBuild(flags);
|
|
23
23
|
const errorParams = { errorMonitor, mode, logs, debug, testOpts };
|
|
24
24
|
const systemLog = getSystemLogger(logs, debug, systemLogFile);
|
|
25
25
|
const attributes = {
|
|
@@ -28,7 +28,7 @@ export default async function buildSite(flags = {}) {
|
|
|
28
28
|
'deploy.context': flagsA.context,
|
|
29
29
|
'site.id': flagsA.siteId,
|
|
30
30
|
};
|
|
31
|
-
const rootCtx = setMultiSpanAttributes(attributes);
|
|
31
|
+
const rootCtx = context.with(rootTracingContext, () => setMultiSpanAttributes(attributes));
|
|
32
32
|
return await tracer.startActiveSpan('exec-build', {}, rootCtx, async (span) => {
|
|
33
33
|
try {
|
|
34
34
|
const { pluginsOptions, netlifyConfig: netlifyConfigA, siteInfo, userNodeVersion, stepsCount, timers, durationNs, configMutations, metrics, } = await execBuild({
|
|
@@ -8,6 +8,7 @@ const DEFAULT_FUNCTIONS_DIST = '.netlify/functions/';
|
|
|
8
8
|
const DEFAULT_CACHE_DIR = '.netlify/cache/';
|
|
9
9
|
const DEFAULT_STATSD_PORT = 8125;
|
|
10
10
|
const DEFAULT_OTEL_TRACING_PORT = 4317;
|
|
11
|
+
const DEFAULT_OTEL_ENDPOINT_PROTOCOL = 'http';
|
|
11
12
|
/** Normalize CLI flags */
|
|
12
13
|
export const normalizeFlags = function (flags, logs) {
|
|
13
14
|
const rawFlags = removeFalsy(flags);
|
|
@@ -53,7 +54,14 @@ const getDefaultFlags = function ({ env: envOpt = {} }, combinedEnv) {
|
|
|
53
54
|
testOpts: {},
|
|
54
55
|
featureFlags: DEFAULT_FEATURE_FLAGS,
|
|
55
56
|
statsd: { port: DEFAULT_STATSD_PORT },
|
|
56
|
-
tracing
|
|
57
|
+
// tracing.apiKey defaults to '-' else we'll get warning logs if not using
|
|
58
|
+
// honeycomb directly - https://github.com/honeycombio/honeycomb-opentelemetry-node/issues/201
|
|
59
|
+
tracing: {
|
|
60
|
+
enabled: false,
|
|
61
|
+
apiKey: '-',
|
|
62
|
+
httpProtocol: DEFAULT_OTEL_ENDPOINT_PROTOCOL,
|
|
63
|
+
port: DEFAULT_OTEL_TRACING_PORT,
|
|
64
|
+
},
|
|
57
65
|
timeline: 'build',
|
|
58
66
|
quiet: false,
|
|
59
67
|
};
|
package/lib/steps/run_step.js
CHANGED
|
@@ -14,7 +14,6 @@ export const runStep = async function ({ event, childProcess, packageName, coreS
|
|
|
14
14
|
// Add relevant attributes to the upcoming span context
|
|
15
15
|
const attributes = {
|
|
16
16
|
'build.execution.step.name': coreStepName,
|
|
17
|
-
'build.execution.step.description': coreStepDescription,
|
|
18
17
|
'build.execution.step.package_name': packageName,
|
|
19
18
|
'build.execution.step.id': coreStepId,
|
|
20
19
|
'build.execution.step.loaded_from': loadedFrom,
|
|
@@ -22,7 +21,9 @@ export const runStep = async function ({ event, childProcess, packageName, coreS
|
|
|
22
21
|
'build.execution.step.event': event,
|
|
23
22
|
};
|
|
24
23
|
const spanCtx = setMultiSpanAttributes(attributes);
|
|
25
|
-
|
|
24
|
+
// If there's no `coreStepId` then this is a plugin execution
|
|
25
|
+
const spanName = `run-step-${coreStepId || 'plugin'}`;
|
|
26
|
+
return tracer.startActiveSpan(spanName, {}, spanCtx, async (span) => {
|
|
26
27
|
const constantsA = await addMutableConstants({ constants, buildDir, netlifyConfig });
|
|
27
28
|
const shouldRun = await shouldRunStep({
|
|
28
29
|
event,
|
package/lib/tracing/main.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
import { HoneycombSDK } from '@honeycombio/opentelemetry-node';
|
|
1
2
|
import { context, trace, propagation, SpanStatusCode, diag, DiagLogLevel } from '@opentelemetry/api';
|
|
2
|
-
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-grpc';
|
|
3
|
-
import { HttpInstrumentation } from '@opentelemetry/instrumentation-http';
|
|
4
|
-
import { NodeSDK } from '@opentelemetry/sdk-node';
|
|
5
3
|
import { ROOT_PACKAGE_JSON } from '../utils/json.js';
|
|
6
4
|
let sdk;
|
|
7
5
|
/** Given a simple logging function return a `DiagLogger`. Used to setup our system logger as the diag logger.*/
|
|
8
6
|
const getOtelLogger = function (logger) {
|
|
9
|
-
const otelLogger = (...args) =>
|
|
7
|
+
const otelLogger = (...args) => {
|
|
8
|
+
// Debug log msgs can be an array of 1 or 2 elements with the second element being an array fo multiple elements
|
|
9
|
+
const msgs = args.flat(1);
|
|
10
|
+
logger('[otel-traces]', ...msgs);
|
|
11
|
+
};
|
|
10
12
|
return {
|
|
11
13
|
debug: otelLogger,
|
|
12
14
|
info: otelLogger,
|
|
@@ -21,13 +23,11 @@ export const startTracing = function (options, logger) {
|
|
|
21
23
|
return;
|
|
22
24
|
if (sdk)
|
|
23
25
|
return;
|
|
24
|
-
|
|
25
|
-
url: `http://${options.host}:${options.port}`,
|
|
26
|
-
});
|
|
27
|
-
sdk = new NodeSDK({
|
|
26
|
+
sdk = new HoneycombSDK({
|
|
28
27
|
serviceName: ROOT_PACKAGE_JSON.name,
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
protocol: 'grpc',
|
|
29
|
+
apiKey: options.apiKey,
|
|
30
|
+
endpoint: `${options.httpProtocol}://${options.host}:${options.port}`,
|
|
31
31
|
});
|
|
32
32
|
// Set the diagnostics logger to our system logger. We also need to suppress the override msg
|
|
33
33
|
// in case there's a default console logger already registered (it would log a msg to it)
|
|
@@ -35,7 +35,7 @@ export const startTracing = function (options, logger) {
|
|
|
35
35
|
sdk.start();
|
|
36
36
|
// Sets the current trace ID and span ID based on the options received
|
|
37
37
|
// this is used as a way to propagate trace context from Buildbot
|
|
38
|
-
trace.setSpanContext(context.active(), {
|
|
38
|
+
return trace.setSpanContext(context.active(), {
|
|
39
39
|
traceId: options.traceId,
|
|
40
40
|
spanId: options.parentSpanId,
|
|
41
41
|
traceFlags: options.traceFlags,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/build",
|
|
3
|
-
"version": "29.15.
|
|
3
|
+
"version": "29.15.1",
|
|
4
4
|
"description": "Netlify build module",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./lib/core/main.js",
|
|
@@ -64,19 +64,17 @@
|
|
|
64
64
|
"license": "MIT",
|
|
65
65
|
"dependencies": {
|
|
66
66
|
"@bugsnag/js": "^7.0.0",
|
|
67
|
+
"@honeycombio/opentelemetry-node": "^0.4.0",
|
|
67
68
|
"@netlify/cache-utils": "^5.1.5",
|
|
68
69
|
"@netlify/config": "^20.5.1",
|
|
69
70
|
"@netlify/edge-bundler": "8.16.2",
|
|
70
71
|
"@netlify/framework-info": "^9.8.10",
|
|
71
|
-
"@netlify/functions-utils": "^5.2.
|
|
72
|
+
"@netlify/functions-utils": "^5.2.15",
|
|
72
73
|
"@netlify/git-utils": "^5.1.1",
|
|
73
74
|
"@netlify/plugins-list": "^6.68.0",
|
|
74
75
|
"@netlify/run-utils": "^5.1.1",
|
|
75
|
-
"@netlify/zip-it-and-ship-it": "9.
|
|
76
|
+
"@netlify/zip-it-and-ship-it": "9.12.0",
|
|
76
77
|
"@opentelemetry/api": "^1.4.1",
|
|
77
|
-
"@opentelemetry/exporter-trace-otlp-grpc": "^0.40.0",
|
|
78
|
-
"@opentelemetry/instrumentation-http": "^0.40.0",
|
|
79
|
-
"@opentelemetry/sdk-node": "^0.40.0",
|
|
80
78
|
"@sindresorhus/slugify": "^2.0.0",
|
|
81
79
|
"ansi-escapes": "^6.0.0",
|
|
82
80
|
"chalk": "^5.0.0",
|
|
@@ -151,5 +149,5 @@
|
|
|
151
149
|
"module": "commonjs"
|
|
152
150
|
}
|
|
153
151
|
},
|
|
154
|
-
"gitHead": "
|
|
152
|
+
"gitHead": "8710be74e31adad1729680e7202f77fb72e0d2a4"
|
|
155
153
|
}
|