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

adding headers and query parms for logging #22537

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class DocumentTranslationClientOptions : ClientOptions
public DocumentTranslationClientOptions(ServiceVersion version = LatestVersion)
{
Version = version;
AddLoggedHeadersAndQueryParameters();
}

internal string GetVersionString()
Expand All @@ -52,5 +53,31 @@ public enum ServiceVersion
/// </summary>
V1_0 = 1
}

/// <summary>
/// Add headers and query parameters that are considered safe for logging or including in
/// error messages by default.
/// </summary>
private void AddLoggedHeadersAndQueryParameters()
{
Diagnostics.LoggedHeaderNames.Add("Operation-Location");
Diagnostics.LoggedHeaderNames.Add("Content-Encoding");
Diagnostics.LoggedHeaderNames.Add("Vary");
Diagnostics.LoggedHeaderNames.Add("apim-request-id");
Diagnostics.LoggedHeaderNames.Add("X-RequestId");
Diagnostics.LoggedHeaderNames.Add("Set-Cookie");
Diagnostics.LoggedHeaderNames.Add("X-Powered-By");
Diagnostics.LoggedHeaderNames.Add("Strict-Transport-Security");
Diagnostics.LoggedHeaderNames.Add("x-content-type-options");

Diagnostics.LoggedQueryParameters.Add("$top");
Diagnostics.LoggedQueryParameters.Add("$skip");
Diagnostics.LoggedQueryParameters.Add("$maxpagesize");
Diagnostics.LoggedQueryParameters.Add("ids");
Diagnostics.LoggedQueryParameters.Add("statuses");
Diagnostics.LoggedQueryParameters.Add("createdDateTimeUtcStart");
Diagnostics.LoggedQueryParameters.Add("createdDateTimeUtcEnd");
Diagnostics.LoggedQueryParameters.Add("$orderBy");
}
}
}