From b64087545ca592ced8c778abc6ca8979237952b9 Mon Sep 17 00:00:00 2001 From: Yujohn Nattrass Date: Fri, 22 Nov 2024 10:39:59 -0800 Subject: [PATCH] fix: move adding new plugin attribute to where the others are set --- packages/build/src/core/main.ts | 8 -------- packages/build/src/error/types.ts | 9 +++++++++ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/build/src/core/main.ts b/packages/build/src/core/main.ts index 8786861fba..5f171e0ac9 100644 --- a/packages/build/src/core/main.ts +++ b/packages/build/src/core/main.ts @@ -2,13 +2,10 @@ import { setMultiSpanAttributes, getGlobalContext } from '@netlify/opentelemetry import { trace, context } from '@opentelemetry/api' import { handleBuildError } from '../error/handle.js' -import { getErrorInfo } from '../error/info.js' import { reportError } from '../error/report.js' import { getSystemLogger } from '../log/logger.js' import type { BufferedLogs } from '../log/logger.js' import { logTimer, logBuildSuccess } from '../log/messages/core.js' -import { isNetlifyMaintainedPlugin } from '../plugins/internal.js' -import { normalizeTagName } from '../report/statsd.js' import { trackBuildComplete } from '../telemetry/main.js' import { reportTimers } from '../time/report.js' import { RootExecutionAttributes } from '../tracing/main.js' @@ -125,16 +122,11 @@ export async function buildSite(flags: Partial = {}): Promise<{ const { severity } = await handleBuildError(error, errorParams as any) const { pluginsOptions, siteInfo, userNodeVersion }: any = errorParams const { success, severityCode, status } = getSeverity(severity) - const [errorInfo] = getErrorInfo(error) - const pluginName = errorInfo.plugin ? normalizeTagName(errorInfo.plugin.packageName) : null - - const isNetlifyMaintained = pluginName && isNetlifyMaintainedPlugin(pluginName) ? '1' : '0' span.setAttributes({ 'build.execution.success': success, 'build.execution.code': severityCode, 'build.execution.status': status, - 'build.execution.isNetlifyMaintained': isNetlifyMaintained, }) await telemetryReport({ diff --git a/packages/build/src/error/types.ts b/packages/build/src/error/types.ts index 1d6974e104..1a5a806b45 100644 --- a/packages/build/src/error/types.ts +++ b/packages/build/src/error/types.ts @@ -1,5 +1,8 @@ import { Attributes } from '@opentelemetry/api' +import { isNetlifyMaintainedPlugin } from '../plugins/internal.js' +import { normalizeTagName } from '../report/statsd.js' + // We override errorProps and title through getTitle and getErrorProps export type BuildError = Omit & { title: string @@ -201,9 +204,15 @@ const errorLocationToTracingAttributes = function (location: ErrorLocation): Att const pluginDataToTracingAttributes = function (pluginInfo?: PluginInfo): Attributes { const pluginAttributePrefix = `${buildErrorAttributePrefix}.plugin` if (typeof pluginInfo === 'undefined') return {} + + const pluginName = pluginInfo?.packageName ? normalizeTagName(pluginInfo?.packageName) : null + const isNetlifyMaintained = pluginName && isNetlifyMaintainedPlugin(pluginName) ? '1' : '0' + return { [`${pluginAttributePrefix}.name`]: pluginInfo?.packageName, [`${pluginAttributePrefix}.version`]: pluginInfo?.pluginPackageJson?.version, + [`${pluginAttributePrefix}.pluginName`]: pluginName ?? 'missing', + [`${pluginAttributePrefix}.isNetlifyMaintained`]: isNetlifyMaintained, } }