Skip to content

Commit daae23b

Browse files
authored
opentelemetry-sdk: be less picky about deprecated LogRecord interface (#4762)
All code that is emitting API LogRecords will emit this warnings because the conversion code need to pass the deprecated fields because of Event still using these fields. In the meantime we cleanup that warn only if we are not already using context.
1 parent da15594 commit daae23b

File tree

1 file changed

+7
-7
lines changed
  • opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal

1 file changed

+7
-7
lines changed

opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -234,16 +234,16 @@ def __init__( # pylint:disable=too-many-locals
234234
limits: LogLimits | None = None,
235235
event_name: str | None = None,
236236
):
237-
if trace_id or span_id or trace_flags:
238-
warnings.warn(
239-
"LogRecord init with `trace_id`, `span_id`, and/or `trace_flags` is deprecated since 1.35.0. Use `context` instead.",
240-
LogDeprecatedInitWarning,
241-
stacklevel=2,
242-
)
243-
244237
if not context:
245238
context = get_current()
246239

240+
if trace_id or span_id or trace_flags:
241+
warnings.warn(
242+
"LogRecord init with `trace_id`, `span_id`, and/or `trace_flags` is deprecated since 1.35.0. Use `context` instead.",
243+
LogDeprecatedInitWarning,
244+
stacklevel=2,
245+
)
246+
247247
span = get_current_span(context)
248248
span_context = span.get_span_context()
249249

0 commit comments

Comments
 (0)