Skip to content

Commit

Permalink
fix: move adding new plugin attribute to where the others are set
Browse files Browse the repository at this point in the history
  • Loading branch information
YujohnNattrass committed Nov 22, 2024
1 parent 750cd40 commit b640875
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
8 changes: 0 additions & 8 deletions packages/build/src/core/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -125,16 +122,11 @@ export async function buildSite(flags: Partial<BuildFlags> = {}): 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({
Expand Down
9 changes: 9 additions & 0 deletions packages/build/src/error/types.ts
Original file line number Diff line number Diff line change
@@ -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<BasicErrorInfo, 'errorProps'> & {
title: string
Expand Down Expand Up @@ -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,
}
}

Expand Down

0 comments on commit b640875

Please sign in to comment.