Skip to content

feat(api-logs)!: change scopeAttributes to be of type LogAttributes#6354

Open
AnubhavPurohit691 wants to merge 1 commit intoopen-telemetry:mainfrom
AnubhavPurohit691:fix/api-logs-scope-attributes-log-attributes-type
Open

feat(api-logs)!: change scopeAttributes to be of type LogAttributes#6354
AnubhavPurohit691 wants to merge 1 commit intoopen-telemetry:mainfrom
AnubhavPurohit691:fix/api-logs-scope-attributes-log-attributes-type

Conversation

@AnubhavPurohit691
Copy link
Contributor

Which problem is this PR solving?

LoggerOptions#scopeAttributes was typed as Attributes (from the trace API). Scope attributes are part of the logs API and should use the same value space as log attributes. Using LogAttributes (AnyValueMap) is correct because:

  • Consistency: Scope attributes are associated with log telemetry; the logs API should use LogAttributes.
  • Value space: LogAttributes allows nested objects, Uint8Array, null/undefined, etc.; trace Attributes only allows primitives and arrays of primitives.
  • Stability: Changing this type later would be breaking for implementers; fixing it now avoids a future breaking change.

This PR updates the type to LogAttributes and adds tests plus a changelog entry.

Fixes #6350

Short description of the changes

  • experimental/packages/api-logs/src/types/LoggerOptions.ts: Change scopeAttributes type from Attributes to LogAttributes; import from ./LogRecord instead of @opentelemetry/api.
  • experimental/CHANGELOG.md: Add entry under Unreleased → Bug Fixes.
  • Tests: In noop-logger-provider.test.ts, add tests that getLogger accepts scopeAttributes with primitive and full LogAttribute value types. In proxy-logger.test.ts, add test that options (including scopeAttributes) are passed through to the delegate.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • NoopLoggerProvider: getLogger('logger-name', undefined, { scopeAttributes: { ... } }) with (1) primitive values and (2) full LogAttribute value types (string, number, boolean, array, nested object, Uint8Array, null). Assert returned logger is a NoopLogger.
  • ProxyLoggerProvider: getLogger('test', 'v0', { schemaUrl, scopeAttributes }) with scopeAttributes containing primitives, nested object, and Uint8Array. Assert delegate getLogger is called with the same options and scopeAttributes is forwarded.

Run: cd experimental/packages/api-logs && npm test — all 18 tests pass, including the new scopeAttributes tests.

  • Test A (NoopLoggerProvider scopeAttributes acceptance)
  • Test B (ProxyLoggerProvider scopeAttributes forwarded to delegate)

Checklist:

  • Followed the style guidelines of this project
  • Unit tests have been added

@AnubhavPurohit691 AnubhavPurohit691 requested review from a team as code owners January 29, 2026 18:26

### :bug: Bug Fixes

* fix(api-logs): use LogAttributes for LoggerOptions#scopeAttributes [#????](https://github.com/open-telemetry/opentelemetry-js/pull/????) @author
Copy link
Member

Choose a reason for hiding this comment

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

this is not a bugfix for sure, but a breaking change feature.

Copy link
Member

Choose a reason for hiding this comment

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

please move this up to breaking changes :)

Copy link
Member

@pichlermarc pichlermarc left a comment

Choose a reason for hiding this comment

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

This is pending a decision and the ticket is not yet ready to be worked on, see #6350.
Note that if we decide to do this, the PR also needs tests in sdk-logs.

@pichlermarc pichlermarc changed the title fix:api-logs feat(api-logs)!: change scopeAttributes to be of type LogAttributes Feb 16, 2026
@codecov
Copy link

codecov bot commented Feb 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.68%. Comparing base (903739c) to head (0aae902).
⚠️ Report is 27 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6354   +/-   ##
=======================================
  Coverage   95.68%   95.68%           
=======================================
  Files         313      313           
  Lines        9667     9667           
  Branches     2226     2226           
=======================================
  Hits         9250     9250           
  Misses        417      417           
🚀 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
Copy link
Member

@AnubhavPurohit691, we've decided to go ahead with this change - please address the comment and then this should be good to merge.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[api-logs] should scopeAttributes be of type LogAttributes?

2 participants

Comments