Skip to content

Conversation

@YangJonghun
Copy link

Which problem is this PR solving?

  • Currently, when OTEL_NODE_ENABLED_INSTRUMENTATIONS is not set, users cannot enable default-excluded instrumentations (like fs) through programmatic configuration.
  • Fixes the issue where getNodeAutoInstrumentations({"@opentelemetry/instrumentation-fs": {enabled: true}}) didn't work when environment variables were not configured.

Short description of the changes

  • Establish clear configuration precedence: Environment variables > programmatic config
  • Fix fs instrumentation enabling: When env vars are unset, allow programmatic config to override default exclusions
  • Follow documented precedence: OTEL_NODE_DISABLED_INSTRUMENTATIONS overrides OTEL_NODE_ENABLED_INSTRUMENTATIONS when both are set, ensuring disabled instrumentations take absolute priority

Configuration Priority (after changes):

  1. OTEL_NODE_DISABLED_INSTRUMENTATIONS - absolute priority
  2. OTEL_NODE_ENABLED_INSTRUMENTATIONS - when set, only enable listed instrumentations
  3. Programmatic config (userConfig.enabled) - when env vars are unset
  4. Default behavior - exclude defaultExcludedInstrumentations unless explicitly enabled

@YangJonghun YangJonghun requested a review from a team as a code owner July 19, 2025 07:03
@YangJonghun YangJonghun changed the title Fix/instrumentation config priority fix(auto-instrumentations-node): enable programmatic config when environment variables are unset Jul 19, 2025
@YangJonghun YangJonghun changed the title fix(auto-instrumentations-node): enable programmatic config when environment variables are unset fix: enable programmatic config when environment variables are unset Jul 19, 2025
@dyladan dyladan added bug Something isn't working priority:p4 Bugs and spec inconsistencies which do not fall into a higher prioritization priority:p2 Bugs and spec inconsistencies which cause telemetry to be incomplete or incorrect and removed priority:p4 Bugs and spec inconsistencies which do not fall into a higher prioritization labels Aug 6, 2025
disabledInstrumentationsFromEnv.includes(name)
) {
diag.debug(`Disabling instrumentation for ${name}`);
// Configuration priority: Environment variables > programmatic config
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There isn't a clear guideline of what takes precedent (env or programmatic), but in the JS SDK we have been using
programmatic > env
so to keep consistency across the SDK, I would suggest you make the changes accordingly here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working pkg:auto-instrumentations-node priority:p2 Bugs and spec inconsistencies which cause telemetry to be incomplete or incorrect

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants