Skip to content

opentelemetry-instrumentation-logging: add ability to configure scope attributes for LoggingHandler#4688

Open
herin049 wants to merge 2 commits into
open-telemetry:mainfrom
herin049:feat/logging-handler-scope-attrs
Open

opentelemetry-instrumentation-logging: add ability to configure scope attributes for LoggingHandler#4688
herin049 wants to merge 2 commits into
open-telemetry:mainfrom
herin049:feat/logging-handler-scope-attrs

Conversation

@herin049

Copy link
Copy Markdown
Contributor

Description

Adds ability to configure scope attributes for the internal SDK logger used by the LoggingHandler in opentelemetry-instrumentation-logging.

Fixes opentelemetry-python#4060

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

uv run tox -e py314-test-instrumentation-logging

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@herin049 herin049 requested a review from a team as a code owner June 12, 2026 01:47
@herin049 herin049 moved this to Ready for review in Python PR digest Jun 12, 2026
record.name, logger_provider=self._logger_provider
record.name,
logger_provider=self._logger_provider,
attributes=self._scope_attributes,

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.

Looks like a possible perfromance regression here. Passing attributes to get_logger bypasses the _get_logger_cached path every time. So emit() will always allocate a brand new Logger + InstrumentationScope. Possibly update the caching logic.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, we might just want to add an internal cache inside of the LoggingHandler itself.

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

Labels

None yet

Projects

Status: Ready for review

Development

Successfully merging this pull request may close these issues.

Allow configuration of inner SDK Logger using LoggingHandler

2 participants