Skip to content

Conversation

xrmx
Copy link
Member

@xrmx xrmx commented Oct 2, 2025

What does this pull request do?

This is a followup of #90 where the newer OTel sdks introduced a warning everytime you emit a LogRecord:

opentelemetry/sdk/_logs/_internal/__init__.py:338: LogDeprecatedInitWarning: LogRecord init with `trace_id`, `span_id`, and/or `trace_flags` is deprecated since 1.35.0. Use `context` instead.
  return cls(

Related issues

@xrmx xrmx requested a review from a team as a code owner October 2, 2025 15:29
@xrmx xrmx requested a review from anuraaga October 2, 2025 15:30
@xrmx xrmx force-pushed the try-to-silence-deprecation-warnings branch from 40e398c to 79c66bd Compare October 3, 2025 09:46
xrmx added 2 commits October 3, 2025 11:48
Pass the full context instead of the deprecated trace_id, span_id and
trace_flags.
Unfortunately the deprecation raises everytime we emit a message event
because of internal sdk code even if we don't pass the deprecated
parameters ourselves. So silence it.
@xrmx xrmx force-pushed the try-to-silence-deprecation-warnings branch from 79c66bd to bea6915 Compare October 3, 2025 09:48
try:
from opentelemetry.sdk._logs._internal import LogDeprecatedInitWarning

warnings.simplefilter("ignore", LogDeprecatedInitWarning)
Copy link
Contributor

Choose a reason for hiding this comment

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

To confirm, even though we updated to the new form we still need to suppress it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, all the code that is emitting API LogRecords will get these warnings because the LogRecord conversion code need to pass these deprecated fields to not break the Event API that is still using these fields.

@xrmx xrmx merged commit 6e912f1 into main Oct 3, 2025
14 checks passed
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