Skip to content

Config inner sdk logger #5261

Open
vivek378521 wants to merge 2 commits into
open-telemetry:mainfrom
vivek378521:config-inner-sdk-logger-main
Open

Config inner sdk logger #5261
vivek378521 wants to merge 2 commits into
open-telemetry:mainfrom
vivek378521:config-inner-sdk-logger-main

Conversation

@vivek378521
Copy link
Copy Markdown
Contributor

Description

Add a way to configure the InstrumentationScope used by the SDK logger created internally by LoggingHandler.

LoggingHandler currently creates SDK loggers internally, so users cannot populate the instrumentation scope values the same way they can when creating tracers or meters directly. This change allows callers to provide an explicit instrumentation scope to LoggingHandler.

The default behavior is preserved: when no instrumentation scope is provided, LoggingHandler continues to use the logging record name as the logger/scope name. Existing logger providers that do not accept the new optional argument continue to work when the new argument is not supplied.

Fixes #4060

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • Added unit coverage for LoggerProvider.get_logger with an explicit instrumentation scope.
  • Added unit coverage for LoggingHandler to verify exported LogData uses the provided instrumentation scope.
  • Added API proxy compatibility coverage for old-style logger providers that do not accept the new argument.
  • Rebasing conflicts were avoided by recreating the branch from the latest upstream main and reapplying the change.

Reproduced with:

.tox/py312-test-opentelemetry-api/bin/pytest opentelemetry-api/tests/logs/test_proxy.py -q
.tox/py312-test-opentelemetry-sdk/bin/pytest opentelemetry-sdk/tests/logs/test_logs.py opentelemetry-sdk/tests/logs/test_export.py -q

Results:

  • API logs proxy tests: 4 passed.
  • SDK logs/export tests: 45 passed.

Does This PR Require a Contrib Repo Change?

  • No.

Checklist:

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

@vivek378521 vivek378521 requested a review from a team as a code owner May 31, 2026 06:50
@vivek378521 vivek378521 force-pushed the config-inner-sdk-logger-main branch from b2b850f to 130e0ba Compare May 31, 2026 07:06
@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented May 31, 2026

CLA Signed
The committers listed above are authorized under a signed CLA.

@vivek378521 vivek378521 force-pushed the config-inner-sdk-logger-main branch from 130e0ba to fa46880 Compare May 31, 2026 07:14
@vivek378521 vivek378521 force-pushed the config-inner-sdk-logger-main branch from fa46880 to 54f2ebd Compare May 31, 2026 07:17
@vivek378521
Copy link
Copy Markdown
Contributor Author

@emdneto

Hi I was gone for a long time, but I had this PR which was closed due to inactivity. I wanted to complete it, so I have done the changes on a freshly pulled main and added the change, tested it. (Used AI to write test cases, as the older PR only had 1)

If anyone can review it then it would be awesome!

All checks are passing.

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

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Allow configuration of inner SDK Logger using LoggingHandler

1 participant