Skip to content

feat(config): instrument auto-install-extensions with timing and tracing - #7194

Draft
claude[bot] wants to merge 7 commits into
mainfrom
claude/instrument-extension-install-timing
Draft

feat(config): instrument auto-install-extensions with timing and tracing#7194
claude[bot] wants to merge 7 commits into
mainfrom
claude/instrument-extension-install-timing

Conversation

@claude

@claude claude Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Requested by Philippe Serhal · Slack thread

Summary

The account-level "auto-install required extensions" flow (handleAutoInstallExtensions() in
packages/config/src/utils/extensions/auto-install-extensions.ts) had zero timing
instrumentation, and the @netlify/config CLI process it runs in never picked up trace context
from Buildbot, so none of this work showed up in traces or duration metrics.

This PR:

  • Wraps the actual install work in an OTel span (auto-install-extensions), recording a
    duration_ms attribute and any thrown exception.
  • Wires up @netlify/opentelemetry-sdk-setup in the netlify-config CLI entrypoint
    (packages/config/src/bin/main.js), so trace context passed in by Buildbot gets picked up and
    this process's spans are correctly parented under the same trace as the rest of the build.
    Buildbot passes this as --traceId / --traceParentSpanId / --traceFlags /
    --tracingBaggageFilePath (see companion PR netlify/buildbot#4442); these are mapped onto the
    traceId / parentSpanId / traceFlags / baggageFilePath fields opentelemetry-sdk-setup
    expects.
  • Replaces the function's console.log / console.error calls with @netlify/config's own
    buffered logger (log / logWarning from src/log/logger.js). This is also a small
    correctness fix: console.log writes straight to the process's real stdout, which this CLI
    reserves for its JSON result — a raw console.log line here was landing in the same stream as
    the JSON output.

How

  • packages/config/src/utils/extensions/auto-install-extensions.ts: added a config tracer,
    wraps the install logic (past the early precondition checks) in a
    tracer.startActiveSpan('auto-install-extensions', ...), records duration_ms and
    extensions.installed_count, and swaps the raw console calls for log/logWarning.
  • packages/config/src/main.ts: threads logs through to handleAutoInstallExtensions().
  • packages/config/src/bin/main.js: parses the trace-context flags, calls
    startTracing()/stopTracing() from @netlify/opentelemetry-sdk-setup (an optional peer
    dependency, so this is a no-op if it isn't installed or no trace context is passed), and runs
    resolveConfig() inside that root context.
  • packages/config/src/bin/flags.ts: added the four hidden CLI flags Buildbot now passes.
  • packages/config/package.json: added @opentelemetry/api as a dependency and
    @netlify/opentelemetry-sdk-setup as an optional peer dependency, mirroring how
    packages/build depends on the same tracing packages.
  • packages/config/tests/extensions/tests.js: two tests that trigger an actual install now
    extract the JSON result from output rather than JSON.parse-ing it directly, since the
    install now (correctly) logs to the buffered stderr that runConfigServer prepends to
    output in these tests.

Not done / follow-ups

  • package.json/package-lock.json: the new @opentelemetry/api dependency needs a lockfile
    update; I couldn't produce a clean one in my sandbox (an unrelated pre-existing lockfile entry,
    playwright@1.61.0 under packages/build-info, is no longer resolvable from the registry
    mirror available to me, so a full npm install fails there regardless of this change). A
    regular npm install in a normal dev/CI environment should pick up the new dependency fine.

For us to review and ship your PR efficiently, please perform the following steps:

  • Read the contribution guidelines
  • Update or add tests (existing extension tests updated, all passing)
  • Update or add documentation (not applicable — internal instrumentation only)
  • Make sure the status checks below are successful

Generated by Claude Code

Adds an OTel span and duration attribute around the account-level
extension auto-install flow in @netlify/config, which previously had no
timing instrumentation at all. Also wires up @netlify/opentelemetry-sdk-setup
in the netlify-config CLI entrypoint so trace context passed in by Buildbot
(traceId/traceParentSpanId/traceFlags/baggage) gets picked up and this
process's spans are stitched into the same trace, and switches the
function's console.log/console.error calls to @netlify/config's own
buffered logger so they no longer leak onto stdout (which is reserved for
the CLI's JSON output).
@github-actions

Copy link
Copy Markdown
Contributor

This pull request adds or modifies JavaScript (.js, .cjs, .mjs) files.
Consider converting them to TypeScript.

@github-actions

Copy link
Copy Markdown
Contributor

e18e dependency analysis

No dependency warnings found.

@claude claude Bot changed the title Instrument auto-install-extensions with timing and tracing feat(config): instrument auto-install-extensions with timing and tracing Aug 19, 2026
@pkg-pr-new

pkg-pr-new Bot commented Aug 19, 2026

Copy link
Copy Markdown

Open in StackBlitz

@netlify/build

npm i https://pkg.pr.new/@netlify/build@7194

@netlify/build-info

npm i https://pkg.pr.new/@netlify/build-info@7194

@netlify/cache-utils

npm i https://pkg.pr.new/@netlify/cache-utils@7194

@netlify/config

npm i https://pkg.pr.new/@netlify/config@7194

@netlify/edge-bundler

npm i https://pkg.pr.new/@netlify/edge-bundler@7194

@netlify/functions-utils

npm i https://pkg.pr.new/@netlify/functions-utils@7194

@netlify/git-utils

npm i https://pkg.pr.new/@netlify/git-utils@7194

@netlify/headers-parser

npm i https://pkg.pr.new/@netlify/headers-parser@7194

@netlify/api

npm i https://pkg.pr.new/@netlify/api@7194

@netlify/nock-udp

npm i https://pkg.pr.new/@netlify/nock-udp@7194

@netlify/opentelemetry-sdk-setup

npm i https://pkg.pr.new/@netlify/opentelemetry-sdk-setup@7194

@netlify/opentelemetry-utils

npm i https://pkg.pr.new/@netlify/opentelemetry-utils@7194

@netlify/redirect-parser

npm i https://pkg.pr.new/@netlify/redirect-parser@7194

@netlify/run-utils

npm i https://pkg.pr.new/@netlify/run-utils@7194

@netlify/zip-it-and-ship-it

npm i https://pkg.pr.new/@netlify/zip-it-and-ship-it@7194

commit: 25b49ab

claude added 6 commits August 19, 2026 17:13
knip flags @netlify/opentelemetry-sdk-setup as an unused optional
peerDependency in packages/config because it's only resolved via a
dynamic import() at runtime (defensively, since it's optional), which
knip's static analysis can't trace. Add it to ignoreDependencies for
the packages/config workspace, matching the identical existing entry
for packages/build.
packages/config/package.json added @opentelemetry/api as a direct
dependency and @netlify/opentelemetry-sdk-setup as an optional peer
dependency, but package-lock.json was never regenerated, so npm ci
had a stale lockfile. Add the missing dependency/peerDependencies
entries to the packages/config lockfile node (the version itself was
already resolved at the root via packages/build's identical
devDependency, so no new package needed downloading).
…ension-install-timing

# Conflicts:
#	package-lock.json
The prior merge of main manually resolved a package-lock.json conflict
in a way that left it internally inconsistent: many packages'
optionalDependencies (e.g. @rollup/rollup-*, @esbuild/*, @nx/nx-*,
@oxc-parser/binding-*) referenced platform variants that had no
corresponding top-level lockfile entry. npm <11 tolerates this, but
the npm 11.x bundled with Node 24 (used across this repo's CI) treats
it as fatal ("Missing: X from lock file") and refuses `npm ci`,
breaking the formatting, knip, e2e, test, and test-build checks
identically since they all install with `npm ci` first.

Regenerated the lockfile with npm 11 via
`npm install --package-lock-only` so it is complete and consistent,
then re-merged main (which advanced again during investigation) and
regenerated once more. Verified `npm ci`, build, knip, format:ci, and
lint:ci all pass locally with npm 11.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GDdYBYHPj9CF5vG4WAX5EC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant