Skip to content

Commit 7e99c26

Browse files
feat(build): Add trace attribute to track builds failing from Netlify maintained extensions (#5914)
* feat(build): track netlify owned extensions * feat: add if plugin is maintained by netlify * fix: move adding new plugin attribute to where the others are set * fix: update netlify maintained extension names * chore: cleanup * chore: remove unused trace attribute * chore: add debug logs * update console.log * chore: log integrations * fix: fix debug log * chore: add extension author to trace * fix: add auth and slug to trace correctly * chore: add slug and author to trace * chore: add debug logs * chore: add extensionMetadata to attributes * chore: clean up * fix: fix unused var error * chore: add types for extension metadata * chore: remove debug log * chore: update test --------- Co-authored-by: NikAiyer <nick.aiyer@gmail.com>
1 parent c22be64 commit 7e99c26

File tree

7 files changed

+42
-3
lines changed

7 files changed

+42
-3
lines changed

packages/build/src/error/types.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,14 @@ type PluginInfo = {
8181
pluginPackageJson: {
8282
version?: string
8383
}
84+
extensionMetadata?: {
85+
slug: string
86+
name: string
87+
version: string
88+
has_build: boolean
89+
has_connector: boolean
90+
author?: string
91+
}
8492
}
8593

8694
export type BuildCommandLocation = {
@@ -201,9 +209,12 @@ const errorLocationToTracingAttributes = function (location: ErrorLocation): Att
201209
const pluginDataToTracingAttributes = function (pluginInfo?: PluginInfo): Attributes {
202210
const pluginAttributePrefix = `${buildErrorAttributePrefix}.plugin`
203211
if (typeof pluginInfo === 'undefined') return {}
212+
204213
return {
205214
[`${pluginAttributePrefix}.name`]: pluginInfo?.packageName,
206215
[`${pluginAttributePrefix}.version`]: pluginInfo?.pluginPackageJson?.version,
216+
[`${pluginAttributePrefix}.extensionAuthor`]: pluginInfo?.extensionMetadata?.author,
217+
[`${pluginAttributePrefix}.extensionSlug`]: pluginInfo?.extensionMetadata?.slug,
207218
}
208219
}
209220

packages/build/src/plugins/load.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,16 @@ const loadAllPlugins = measureDuration(tLoadAllPlugins, 'load_plugins')
7575
// Retrieve plugin steps for one plugin.
7676
// Do it by executing the plugin `load` event handler.
7777
const loadPlugin = async function (
78-
{ packageName, pluginPackageJson, pluginPackageJson: { version } = {}, pluginPath, inputs, loadedFrom, origin },
78+
{
79+
packageName,
80+
pluginPackageJson,
81+
pluginPackageJson: { version } = {},
82+
pluginPath,
83+
inputs,
84+
loadedFrom,
85+
origin,
86+
integration,
87+
},
7988
{ childProcesses, index, packageJson, logs, debug, verbose, netlifyConfig, featureFlags, systemLog },
8089
) {
8190
const { childProcess } = childProcesses[index]
@@ -97,6 +106,7 @@ const loadPlugin = async function (
97106
origin,
98107
pluginPackageJson,
99108
childProcess,
109+
extensionMetadata: integration,
100110
}))
101111
return pluginSteps
102112
} catch (error) {
@@ -106,7 +116,11 @@ const loadPlugin = async function (
106116
}
107117

108118
addErrorInfo(error, {
109-
plugin: { packageName, pluginPackageJson },
119+
plugin: {
120+
packageName,
121+
pluginPackageJson,
122+
extensionMetadata: integration,
123+
},
110124
location: { event: loadEvent, packageName, loadedFrom, origin },
111125
})
112126
addPluginLoadErrorStatus({ error, packageName, version, debug })

packages/build/src/steps/plugin.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export const firePluginStep = async function ({
3939
featureFlags,
4040
debug,
4141
verbose,
42+
extensionMetadata,
4243
}) {
4344
const standardStreams = getStandardStreams(outputFlusher)
4445
const listeners = pipePluginOutput(childProcess, logs, standardStreams)
@@ -103,7 +104,7 @@ export const firePluginStep = async function ({
103104
const errorType = getPluginErrorType(newError, loadedFrom, packageName)
104105
addErrorInfo(newError, {
105106
...errorType,
106-
plugin: { pluginPackageJson, packageName },
107+
plugin: { pluginPackageJson, packageName, extensionMetadata },
107108
location: { event, packageName, loadedFrom, origin },
108109
})
109110
return { newError }

packages/build/src/steps/run_step.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export const runStep = async function ({
6969
userNodeVersion,
7070
explicitSecretKeys,
7171
edgeFunctionsBootstrapURL,
72+
extensionMetadata,
7273
}) {
7374
// Add relevant attributes to the upcoming span context
7475
const attributes: StepExecutionAttributes = {
@@ -144,6 +145,7 @@ export const runStep = async function ({
144145
durationNs,
145146
metrics,
146147
} = await fireStep({
148+
extensionMetadata,
147149
defaultConfig,
148150
event,
149151
childProcess,
@@ -349,6 +351,7 @@ const tFireStep = function ({
349351
explicitSecretKeys,
350352
edgeFunctionsBootstrapURL,
351353
deployId,
354+
extensionMetadata,
352355
}) {
353356
if (coreStep !== undefined) {
354357
return fireCoreStep({
@@ -414,5 +417,6 @@ const tFireStep = function ({
414417
featureFlags,
415418
debug,
416419
verbose,
420+
extensionMetadata,
417421
})
418422
}

packages/build/src/steps/run_steps.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ export const runSteps = async function ({
7676
event,
7777
childProcess,
7878
packageName,
79+
extensionMetadata,
7980
coreStep,
8081
coreStepId,
8182
coreStepName,
@@ -103,6 +104,7 @@ export const runSteps = async function ({
103104
event,
104105
childProcess,
105106
packageName,
107+
extensionMetadata,
106108
coreStep,
107109
coreStepId,
108110
coreStepName,

packages/build/tests/error/tests.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ const testMatrixAttributeTracing = [
145145
pluginPackageJson: {
146146
version: '1.2.1',
147147
},
148+
extensionMetadata: {
149+
slug: 'test-extension-slug',
150+
author: 'test-extension-author',
151+
},
148152
},
149153
},
150154
severity: 'error',
@@ -159,6 +163,8 @@ const testMatrixAttributeTracing = [
159163
'build.error.location.plugin.package_name': 'test-package',
160164
'build.error.location.plugin.loaded_from': 'test-loaded-from',
161165
'build.error.location.plugin.origin': 'test-origin',
166+
'build.error.plugin.extensionAuthor': 'test-extension-author',
167+
'build.error.plugin.extensionSlug': 'test-extension-slug',
162168
'build.error.plugin.name': 'test-package',
163169
'build.error.plugin.version': '1.2.1',
164170
},

packages/config/src/types/integrations.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ export type Integration = {
55
dev?: {
66
path: string
77
}
8+
author?: string
89
}

0 commit comments

Comments
 (0)