Skip to content

Conversation

@rads-1996
Copy link
Member

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 instead

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

…d init with trace_id, span_id, and/or trace_flags is deprecated since 1.35.0. Use context instead
Copilot AI review requested due to automatic review settings November 17, 2025 22:30
@github-actions github-actions bot added the Monitor - Exporter Monitor OpenTelemetry Exporter label Nov 17, 2025
Copilot finished reviewing on behalf of rads-1996 November 17, 2025 22:33
Copy link
Contributor

Copilot AI left a 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 LogRecord instantiations to use context parameter with properly constructed SpanContext objects
  • Added necessary imports (set_span_in_context, SpanContext, NonRecordingSpan) to support the new context-based approach
  • Removed mock context objects in favor of real SpanContext instances 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

Copy link
Member

@JacksonWeber JacksonWeber left a comment

Choose a reason for hiding this comment

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

LGTM

@rads-1996 rads-1996 merged commit 5268f45 into Azure:main Nov 17, 2025
20 checks passed
@rads-1996 rads-1996 deleted the fix-context-warnings branch November 17, 2025 23:41
msyyc pushed a commit that referenced this pull request Nov 25, 2025
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Monitor - Exporter Monitor OpenTelemetry Exporter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants