Skip to content

Log HTTP Request and Response when Debug Switch is specified. #232

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

Merged
merged 11 commits into from
Jul 17, 2020

Conversation

georgend
Copy link
Contributor

@georgend georgend commented May 18, 2020

Hook into Signal infrastructure to capture HTTP Request and Responses for logging purposes when Debug is specified.

On Module init, hook EventHandler delegate into EventListener delegate.
Use HttpFormatter from contrib repo. Does not show the Authorization header (Access Token).

Depends on changes in autorest.powershell generator

Covers task AB#4720

… for logging purposes when Debug is specified.

On Module init, hook EventHandler into EventListener delegate.
@georgend georgend linked an issue May 18, 2020 that may be closed by this pull request
@georgend
Copy link
Contributor Author

Changes to AutoRest.Powershell have been reviewed and merged.

// Set of header fields that should not get serialized
private static readonly HashSet<string> _neverSerializedHeaderFields = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
{
"SdkVersion",
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we not Serializing SdkVersion and FeatureFlag? Or Cache-Control, or Date?

Copy link
Contributor Author

@georgend georgend Jul 12, 2020

Choose a reason for hiding this comment

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

This is legacy from the contrib project. Would it be preferable to serialize all headers, including Authorization?

Copy link
Member

Choose a reason for hiding this comment

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

We should serialize headers that are useful in tracing an issue/bug. For instance, we need SdkVersion to know which version of the SDK the customer was running, featureFlag to know which middleware handlers they have enabled e.t.c. Authorization header is not useful, and we shouldn't serialize it.

@georgend georgend requested a review from darrelmiller July 13, 2020 15:07
George and others added 2 commits July 14, 2020 05:37
use nameof in exceptions.
add appropriate license headers.
@georgend
Copy link
Contributor Author

Generated a sample module using the latest autorest.powershell that includes our code generator changes, generates correctly and -Debug emits Request and Responses accordingly.

@georgend georgend merged commit 7aec23f into dev Jul 17, 2020
@georgend georgend linked an issue Jul 18, 2020 that may be closed by this pull request
@georgend georgend deleted the httpDebugLogging branch July 22, 2020 22:58
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.

Update -debug to show complete HTTP request and response
3 participants