-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Fixes LogDeprecated warnings - LogDeprecatedInitWarning: LogRecord init with trace_id, span_id, and/or trace_flags is deprecated since 1.35.0. Use context instead
#44090
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
Conversation
…d init with trace_id, span_id, and/or trace_flags is deprecated since 1.35.0. Use context instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request addresses deprecation warnings in the OpenTelemetry logging API by updating LogRecord initialization calls to use the context parameter instead of the deprecated trace_id, span_id, and trace_flags parameters.
- Updated all
LogRecordinstantiations to usecontextparameter with properly constructedSpanContextobjects - Added necessary imports (
set_span_in_context,SpanContext,NonRecordingSpan) to support the new context-based approach - Removed mock context objects in favor of real
SpanContextinstances in test cases
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 17 comments.
| File | Description |
|---|---|
| sdk/monitor/azure-monitor-opentelemetry-exporter/tests/logs/test_processor.py | Refactored test methods to create proper SpanContext and context objects instead of using deprecated trace_id/span_id/trace_flags parameters in LogRecord |
| sdk/monitor/azure-monitor-opentelemetry-exporter/tests/logs/test_logs.py | Updated LogRecord instantiations in test setup and individual tests to use context parameter with properly constructed SpanContext objects |
| sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md | Added entry documenting the fix for LogDeprecated warnings |
sdk/monitor/azure-monitor-opentelemetry-exporter/tests/logs/test_logs.py
Outdated
Show resolved
Hide resolved
sdk/monitor/azure-monitor-opentelemetry-exporter/tests/logs/test_logs.py
Outdated
Show resolved
Hide resolved
sdk/monitor/azure-monitor-opentelemetry-exporter/tests/logs/test_logs.py
Outdated
Show resolved
Hide resolved
sdk/monitor/azure-monitor-opentelemetry-exporter/tests/logs/test_logs.py
Outdated
Show resolved
Hide resolved
sdk/monitor/azure-monitor-opentelemetry-exporter/tests/logs/test_logs.py
Show resolved
Hide resolved
sdk/monitor/azure-monitor-opentelemetry-exporter/tests/logs/test_logs.py
Outdated
Show resolved
Hide resolved
sdk/monitor/azure-monitor-opentelemetry-exporter/tests/logs/test_logs.py
Outdated
Show resolved
Hide resolved
sdk/monitor/azure-monitor-opentelemetry-exporter/tests/logs/test_logs.py
Outdated
Show resolved
Hide resolved
sdk/monitor/azure-monitor-opentelemetry-exporter/tests/logs/test_logs.py
Outdated
Show resolved
Hide resolved
JacksonWeber
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…nit with trace_id, span_id, and/or trace_flags is deprecated since 1.35.0. Use context instead` (#44090) * Fixes the LogDeprecated warnings - LogDeprecatedInitWarning: LogRecord init with trace_id, span_id, and/or trace_flags is deprecated since 1.35.0. Use context instead * Update CHANGELOG * Fix space issue
Description
Fixes the LogDeprecated warnings -
LogDeprecatedInitWarning: LogRecord init with trace_id, span_id, and/or trace_flags is deprecated since 1.35.0. Use context insteadAll SDK Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines