fix: add product context fallback for subchannels#129
Merged
hectorhdzg merged 4 commits intoMay 12, 2026
Conversation
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>
Contributor
There was a problem hiding this comment.
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 tochannel_data["productContext"](including JSON-string channel_data). - Updated OutputLoggingMiddleware’s
_derive_channel()to use the shared subchannel resolver rather than readingsub_channeldirectly. - Fixed a mypy typing issue by widening
parse_retry_afterfromdict[str, str]toMapping[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
approved these changes
May 11, 2026
rads-1996
approved these changes
May 11, 2026
JacksonWeber
approved these changes
May 11, 2026
MattB-msft
approved these changes
May 12, 2026
nikhilNava
approved these changes
May 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix: add product context fallback for subchannels
Ports the subchannel fallback from SDK PR: microsoft/Agent365-python#252.
Additionally, extracted a shared
resolve_sub_channelhelper inutils.pyand applied the same fallback to
_derive_channel()inoutput_logging_middleware.py,which was still reading
sub_channeldirectly without theproductContextfallback.Also fixed a pre-existing mypy error by widening
parse_retry_aftertype hintfrom
dict[str, str]toMapping[str, str].