Skip to content
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

Disable content logging by default #7633

Merged
merged 3 commits into from
Sep 17, 2019

Conversation

pakrym
Copy link
Contributor

@pakrym pakrym commented Sep 16, 2019

Fixes: #7559

sdk/core/Azure.Core/src/Pipeline/DiagnosticsOptions.cs Outdated Show resolved Hide resolved

public static readonly LoggingPolicy Shared = new LoggingPolicy();
Copy link
Member

Choose a reason for hiding this comment

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

Is it worth having SharedNoContent and SharedWithContent?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I suspect it would have more parameters pretty soon

sdk/core/Azure.Core/src/Pipeline/DiagnosticsOptions.cs Outdated Show resolved Hide resolved
@@ -92,19 +98,19 @@ private static async Task ProcessAsync(HttpPipelineMessage message, ReadOnlyMemo

var textResponse = ContentTypeUtilities.TryGetTextEncoding(message.Response.Headers.ContentType, out Encoding? responseTextEncoding);

bool wrapResponseStream = message.Response.ContentStream != null && message.Response.ContentStream?.CanSeek == false && s_eventSource.ShouldLogContent(isError);
bool logResponseContent = _logContent && message.Response.ContentStream != null;
bool wrapResponseContent = logResponseContent && message.Response.ContentStream?.CanSeek == false && s_eventSource.ShouldLogContent(isError);
Copy link
Member

Choose a reason for hiding this comment

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

You can check the generated IL, but at least when targeting net45 my old code base had to change a lot of this syntax not to use the Elvis operator when comparing against value types. It causes extra allocations. Just separate check if ContentStream != null prior.

In a frequent code path, this could add up (it did in our case).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I checked, the Elvis doesn't result in allocation and produces almost identical IL and asm

@pakrym pakrym merged commit bd6c1aa into Azure:master Sep 17, 2019
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.

Disable content logging by default and add a flag
4 participants