Add HTTP call completion logging for exceptions and non-success status codes#1501
Open
Add HTTP call completion logging for exceptions and non-success status codes#1501
Conversation
…status codes - StreamableHttpClientSessionTransport: Add logging for POST failures and non-success, GET SSE request failures and non-success, DELETE request failures and non-success - SseClientSessionTransport: Add logging for GET SSE non-success status codes, upgrade LogRejectedPost to Warning level, remove unused LogAcceptedPost - ClientOAuthProvider: Add logging for auth server metadata non-success, token refresh failure, token exchange failure, protected resource metadata non-success, and dynamic client registration failure Agent-Logs-Url: https://github.com/modelcontextprotocol/csharp-sdk/sessions/d9f395f7-797a-47f1-a07f-1788d91811c4 Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
stephentoub
April 3, 2026 13:20
View session
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.
Summary
Ensures all HTTP calls in the client transport layer log when operations complete with either an exception or a non-success status code. This makes it much easier to diagnose connectivity and protocol issues from logs alone.
All logging follows existing patterns using the
[LoggerMessage]source generator attribute. Problem conditions (exceptions, unexpected non-success status codes) useWarninglevel, while expected conditions (e.g., DELETE getting 405 because server support is optional) useInformationlevel.Changes
StreamableHttpClientSessionTransportSendHttpRequestAsync): Log exceptions (Warning) and non-success status codes (Warning)SendGetSseRequestWithRetriesAsync): LogHttpRequestExceptionon retry (Warning), server errors 5xx on retry (Warning), and non-retryable non-success status codes (Warning)SendDeleteRequest): Log exceptions (Warning) and non-success status codes (Information— since server support for DELETE is optional per MCP spec)SseClientSessionTransportReceiveMessagesAsync): Log non-success status codes (Warning)LogRejectedPost): Upgraded fromInformationtoWarninglevel since a rejected POST is a problemLogAcceptedPostmethod (was defined but never called)ClientOAuthProviderGetAuthServerMetadataAsync): Log non-success status codes when trying well-known endpoints (Warning)RefreshTokensAsync): Log non-success status codes on silent refresh failure (Warning)ExchangeCodeForTokenAsync): Log non-success status codes before throwing (Warning)FetchProtectedResourceMetadataAsync): Log non-success status codes (Warning)PerformDynamicClientRegistrationAsync): Log non-success status codes before throwing (Warning)Testing