Skip to content

fix: add product context fallback for subchannels#129

Merged
hectorhdzg merged 4 commits into
microsoft:mainfrom
fpfp100:fix/product-context-fallback-subchannel
May 12, 2026
Merged

fix: add product context fallback for subchannels#129
hectorhdzg merged 4 commits into
microsoft:mainfrom
fpfp100:fix/product-context-fallback-subchannel

Conversation

@fpfp100
Copy link
Copy Markdown
Contributor

@fpfp100 fpfp100 commented May 11, 2026

fix: add product context fallback for subchannels

Ports the subchannel fallback from SDK PR: microsoft/Agent365-python#252.
Additionally, extracted a shared resolve_sub_channel helper in utils.py
and applied the same fallback to _derive_channel() in output_logging_middleware.py,
which was still reading sub_channel directly without the productContext fallback.

Also fixed a pre-existing mypy error by widening parse_retry_after type hint
from dict[str, str] to Mapping[str, str].

jsl517 and others added 4 commits May 11, 2026 13:41
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…_derive_channel

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@fpfp100 fpfp100 marked this pull request as ready for review May 11, 2026 23:37
Copilot AI review requested due to automatic review settings May 11, 2026 23:37
Copy link
Copy Markdown
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 PR fixes channel “subchannel” resolution across A365 hosting instrumentation by adding a productContext fallback (from activity.channel_data) when ChannelId.sub_channel is missing, and reuses the same resolution logic in both baggage propagation and output logging.

Changes:

  • Added a shared resolve_sub_channel(activity) helper that falls back to channel_data["productContext"] (including JSON-string channel_data).
  • Updated OutputLoggingMiddleware’s _derive_channel() to use the shared subchannel resolver rather than reading sub_channel directly.
  • Fixed a mypy typing issue by widening parse_retry_after from dict[str, str] to Mapping[str, str], and added tests covering the new fallback behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/a365/hosting/middleware/test_output_logging_middleware.py Adds tests verifying _derive_channel() uses productContext as a fallback and respects sub_channel precedence.
tests/a365/hosting/middleware/test_baggage_middleware.py Adds tests ensuring baggage channel link extraction uses productContext fallback (dict + JSON string) and handles invalid JSON gracefully.
src/microsoft/opentelemetry/a365/hosting/scope_helpers/utils.py Introduces resolve_sub_channel() and routes get_channel_pairs() through it.
src/microsoft/opentelemetry/a365/hosting/middleware/output_logging_middleware.py Applies the shared resolve_sub_channel() logic to output logging channel derivation.
src/microsoft/opentelemetry/a365/core/exporters/utils.py Widens parse_retry_after parameter type to Mapping[str, str] to satisfy type checking.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@hectorhdzg hectorhdzg merged commit 765aee9 into microsoft:main May 12, 2026
11 of 12 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.

8 participants