Skip to content

feat(sdk-logs)!: move environment variable configuration to sdk-node#6325

Merged
pichlermarc merged 1 commit intoopen-telemetry:mainfrom
dynatrace-oss-contrib:feat/sdk-logs-env-var-config
Jan 28, 2026
Merged

feat(sdk-logs)!: move environment variable configuration to sdk-node#6325
pichlermarc merged 1 commit intoopen-telemetry:mainfrom
dynatrace-oss-contrib:feat/sdk-logs-env-var-config

Conversation

@pichlermarc
Copy link
Copy Markdown
Member

@pichlermarc pichlermarc commented Jan 21, 2026

Which problem is this PR solving?

Moves env var configuration to a sdk-node. LoggerProvider, BatchLogRecordProcessor do not read environment variables anymore, aligning with sdk-metrics.

This is done in preparation for Logs GA, as well as to prepare for declarative config (create using file config has to use BatchLogRecordProcessor and LoggerProvider constructors eventually, by not reading environment variables in the SDK implementation, it makes it easier to adhere to this specification later on, which requires us to ignore env var config when file config is used).

To retain env var config for these components, users have to use @opentelemetry/sdk-node's NodeSDK instead.

It also adds additional validation to avoid negative numbers.

Closes #6074

Type of change

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

How Has This Been Tested?

  • Unit tests

@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.58%. Comparing base (0fd543c) to head (7a06090).
⚠️ Report is 11 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6325      +/-   ##
==========================================
- Coverage   95.58%   95.58%   -0.01%     
==========================================
  Files         314      313       -1     
  Lines        9590     9576      -14     
  Branches     2221     2210      -11     
==========================================
- Hits         9167     9153      -14     
  Misses        423      423              
Files with missing lines Coverage Δ
...imental/packages/opentelemetry-sdk-node/src/sdk.ts 95.85% <100.00%> (ø)
...ental/packages/opentelemetry-sdk-node/src/utils.ts 95.06% <100.00%> (+0.28%) ⬆️
...perimental/packages/sdk-logs/src/LoggerProvider.ts 100.00% <100.00%> (ø)
...sdk-logs/src/export/BatchLogRecordProcessorBase.ts 92.22% <100.00%> (-0.92%) ⬇️
...sdk-logs/src/internal/LoggerProviderSharedState.ts 96.66% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pichlermarc pichlermarc force-pushed the feat/sdk-logs-env-var-config branch from 0bd6d2c to 6ce2187 Compare January 22, 2026 10:01
@pichlermarc pichlermarc force-pushed the feat/sdk-logs-env-var-config branch from 6ce2187 to 7a06090 Compare January 22, 2026 10:04
@pichlermarc pichlermarc changed the title feat(sdk-logs)!: move environment variable code to separate function feat(sdk-logs)!: move environment variable configuration to sdk-node Jan 22, 2026
@pichlermarc pichlermarc marked this pull request as ready for review January 26, 2026 13:12
@pichlermarc pichlermarc requested a review from a team as a code owner January 26, 2026 13:12
Comment on lines +48 to +51
this._maxExportBatchSize = config?.maxExportBatchSize ?? 512;
this._maxQueueSize = config?.maxQueueSize ?? 2048;
this._scheduledDelayMillis = config?.scheduledDelayMillis ?? 5000;
this._exportTimeoutMillis = config?.exportTimeoutMillis ?? 30000;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Comment on lines +39 to +43
logRecordLimits: {
attributeCountLimit: config.logRecordLimits?.attributeCountLimit ?? 128,
attributeValueLengthLimit:
config.logRecordLimits?.attributeValueLengthLimit ?? Infinity,
},
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

}

// disable all registered SDK components
context.disable();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

just being curious. Was this giving any issue?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

just logspam in the raw test output - when overriding existing API globals, the API logs an error that looks like the test may be failing, see:

if (!allowOverride && api[type]) {
// already registered an API of this type
const err = new Error(
`@opentelemetry/api: Attempted duplicate registration of API: ${type}`
);
diag.error(err.stack || err.message);
return false;
}

It's not solving any issue other than that for now, but it may avoid problems later when we're testing registration here. 🙂

@pichlermarc pichlermarc added this pull request to the merge queue Jan 28, 2026
Merged via the queue into open-telemetry:main with commit 536fd55 Jan 28, 2026
39 of 42 checks passed
@pichlermarc pichlermarc deleted the feat/sdk-logs-env-var-config branch January 28, 2026 12:21
Comment thread experimental/CHANGELOG.md

### :boom: Breaking Changes

* feat(sdk-logs)!: move environment variable configuration to `@opentelemetry/sdk-node` [#????](https://github.com/open-telemetry/opentelemetry-js/pull/????) @pichlermarc
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It looks like this landed with the question marks still in place for the issue number.

'Long attribute should be truncated to 10 characters'
);

await sdk.shutdown();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

if any of the assertions here fail, does it matter that the SDK won't be shutdown?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In general, it probably can matter (i.e. impact subsequent tests), so this isn't ideal.

trentm added a commit to trentm/opentelemetry-js that referenced this pull request Feb 3, 2026
…rocessor config

PR open-telemetry#6325 accidentally changed a couple envvar names when moving their
usage from sdk-logs to sdk-node. The correct names, from the spec, are
OTEL_BLRP_SCHEDULE_DELAY and OTEL_BLRP_EXPORT_TIMEOUT.

Refs: open-telemetry#6325
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.

[sdk-logs] remove env var configuration from @opentelemetry/sdk-logs

4 participants