Skip to content

Comments

Move logger handlers to opentelemetry-instrumentation-logging#4210

Draft
xrmx wants to merge 8 commits intoopen-telemetry:mainfrom
xrmx:move-logger-handlers-to-autoinstrumentation
Draft

Move logger handlers to opentelemetry-instrumentation-logging#4210
xrmx wants to merge 8 commits intoopen-telemetry:mainfrom
xrmx:move-logger-handlers-to-autoinstrumentation

Conversation

@xrmx
Copy link
Contributor

@xrmx xrmx commented Feb 17, 2026

Description

Draft PR for sketching LoggingHandler move outside of sdk.

Refs open-telemetry/opentelemetry-python#4330

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?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Test A

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

# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This file contains stuff that previously was in the sdk _logs and _configuration modules

Copy link
Member

@pmcollins pmcollins left a comment

Choose a reason for hiding this comment

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

Looks nice -- added a couple of questions.


enabled_logging_integrations = []
if (
environ.get(_OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED, "false")
Copy link
Member

Choose a reason for hiding this comment

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

Should this env var be just for the sdk version of the logging handler? That way both implementations can co-exist until the sdk one eventually gets removed. And both during the transition period and afterwards, users can control whether this handler is enabled by whether this package is installed, just like other instrumentation packages.

Copy link
Contributor Author

@xrmx xrmx Feb 18, 2026

Choose a reason for hiding this comment

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

I've ripped that code out in open-telemetry/opentelemetry-python#4919
But yeah we can add that code back but we need to disable this one if we found that the env var is set to true.

Copy link
Contributor Author

@xrmx xrmx Feb 19, 2026

Choose a reason for hiding this comment

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

Reverted the changes in core, per your suggestion.

logging = "opentelemetry.instrumentation.logging:LoggingInstrumentor"

[project.entry-points.opentelemetry_logging_integrations]
logging = "opentelemetry.instrumentation.logging.handler:_setup_logging_handler"
Copy link
Member

Choose a reason for hiding this comment

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

Should the handler entrypoints look like the instrumentor entry points? e.g. singular instead of plural and maybe refer to a class rather than a function. So since the instrumentation entry points look like this:

[project.entry-points.opentelemetry_instrumentor]
aio-pika = "opentelemetry.instrumentation.aio_pika:AioPikaInstrumentor"

log handlers could be set up like:

[project.entry-points.opentelemetry_logging_initializer]
stdlib = "opentelemetry.instrumentation.logging:LoggingHandlerInitializer"

but now I'm wondering why we need a new entrypoint group at all. I realize this was discussed in the issue, but can handler setup be done in a plain old instrumentor? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We haven't discussed that, this is a proposal :) The issue here is handling co-existence with the one in sdk in both manual and auto instrumentation scenarios.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Dropped the new entry point group and moved the setup to the instrumentor. Thanks!

@xrmx xrmx changed the title Move logger handlers to autoinstrumentation Move logger handlers to opentelemetry-instrumentation-logging Feb 20, 2026
from opentelemetry._logs import get_logger as APIGetLogger
from opentelemetry.attributes import BoundedAttributes
from opentelemetry.sdk import trace
from opentelemetry.sdk._logs import (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

FIXME

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.

2 participants