Skip to content

Filter duplicate logs out of some logger's logs that might otherwise endlessly log #4695

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

DylanRussell
Copy link
Contributor

@DylanRussell DylanRussell commented Jul 21, 2025

Description

Filter duplicate logs out of some logger's logs on the export logs path that might otherwise endlessly log or cause a recursion depth exceeded issue in cases where logging itself results in an exception.

Fixes #4688
Fixes #2701
Fixes #4323

Type of change

Please delete options that are not relevant.

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

How Has This Been Tested?

Unit tests

Does This PR Require a Contrib Repo Change?

  • [x ] No.

Checklist:

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

@DylanRussell DylanRussell requested a review from a team as a code owner July 21, 2025 17:04
DylanRussell and others added 5 commits July 22, 2025 13:28
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
…metry/exporter/otlp/proto/common/_internal/__init__.py

Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
Copy link
Member

@emdneto emdneto left a comment

Choose a reason for hiding this comment

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

Left comment

@@ -39,6 +39,26 @@
from opentelemetry.util._once import Once


class DuplicateFilter(logging.Filter):
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@DylanRussell DylanRussell Jul 23, 2025

Choose a reason for hiding this comment

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

I don't think we want to suppress it entirely.. just stop it from endlessly logging // going into the recursive loop...

Also how does that suppression key work exactly ? I couldn't figure it out, and I'm not sure it covers all the scenarios..

Copy link
Member

Choose a reason for hiding this comment

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

Isn't the issue about "telemetry-induced-telemetry", where the act of exporting a telemetry triggers the creation of another telemetry? If yes, contextual suppression would be the best solution from my understanding..

(Sorry I am not familiar with this repo, but working on similar problem in other OTel languages, and found this PR!)

Copy link
Contributor Author

@DylanRussell DylanRussell Jul 23, 2025

Choose a reason for hiding this comment

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

Currently in auto instrumentation any call to the logging module in python gets picked up the OTLP root logging handler and exported as a OTLP LogRecord. There is an environment variable to disable that behavior entirely: _OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED

But the issue reported that I am fixing is when we internally invoke the logging module because the logs exporter is down / failed, and that results in an endless stream of logs or a recursive overflow.. I think we do generally want our own internal calling of the logging module to result in an OTLP log export..

Copy link
Member

Choose a reason for hiding this comment

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

If we suppress, there won't be any feedback to the user

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants