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

Add LogLevel Hooks to HttpLogOptions and HttpLoggingPolicy #16088

Merged
merged 26 commits into from
Jul 15, 2021

Conversation

alzimmermsft
Copy link
Member

@alzimmermsft alzimmermsft commented Oct 8, 2020

Fixes #11477

This PR adds two new interfaces HttpRequestLogger and HttpResponseLogger to handle logging requests and responses in HttpLoggingPolicy. The interfaces function similarly where they have a method that determines the logging level for a request/response and a method that logs the request/response if the ClientLogger is capable of logging at the expected logging level.

HttpLogOptions has been updated with two new getters and setters to configure the HttpRequestLogger and HttpResponseLogger that will be used by HttpLoggingPolicy. Each property will have a default if it isn't set which is the current logic that HttpLoggingPolicy uses, LogLevel.INFORMATIONAL for default log level and its implementation functions for logging requests and responses.

With the new changes HttpLoggingPolicy can be configured to log with specific goals in mind, the following are a few scenarios:

  • When responses take longer than expected to return the log level for the response can be escalated. For example, if the response takes more than 5 seconds to return it will be logged at the warning level, if the response takes more than 15 seconds to return it will be logged at the error level.

  • You have a nightly job which copies log files from your application servers and performs processing on the logs. This requires specific information to be logged in a well known format. The request and response logging functions can be customized to ensure the logging format complies with the processing requirements.

@alzimmermsft alzimmermsft added the Client This issue points to a problem in the data-plane of the library. label Oct 8, 2020
@alzimmermsft alzimmermsft self-assigned this Oct 8, 2020
@ghost ghost added the Azure.Core azure-core label Oct 8, 2020
@alzimmermsft alzimmermsft changed the title Add functions to HttpLogOptions to determine the log level for reques… Add LogLevel Hooks to HttpLogOptions and HttpLoggingPolicy Oct 8, 2020
… a default interface method, removed defaultLogLevel from HttpLogOptions
…uest or response, made HttpPipelineCallContext's Context property accessible via getContext
@alzimmermsft alzimmermsft requested a review from srnagar October 22, 2020 20:56
@check-enforcer
Copy link

check-enforcer bot commented Feb 2, 2021

This pull request is protected by Check Enforcer.

What is Check Enforcer?

Check Enforcer helps ensure all pull requests are covered by at least one check-run (typically an Azure Pipeline). When all check-runs associated with this pull request pass then Check Enforcer itself will pass.

Why am I getting this message?

You are getting this message because Check Enforcer did not detect any check-runs being associated with this pull request within five minutes. This may indicate that your pull request is not covered by any pipelines and so Check Enforcer is correctly blocking the pull request being merged.

What should I do now?

If the check-enforcer check-run is not passing and all other check-runs associated with this PR are passing (excluding license-cla) then you could try telling Check Enforcer to evaluate your pull request again. You can do this by adding a comment to this pull request as follows:
/check-enforcer evaluate
Typically evaulation only takes a few seconds. If you know that your pull request is not covered by a pipeline and this is expected you can override Check Enforcer using the following command:
/check-enforcer override
Note that using the override command triggers alerts so that follow-up investigations can occur (PRs still need to be approved as normal).

What if I am onboarding a new service?

Often, new services do not have validation pipelines associated with them, in order to bootstrap pipelines for a new service, you can issue the following command as a pull request comment:
/azp run prepare-pipelines
This will run a pipeline that analyzes the source tree and creates the pipelines necessary to build and validate your pull request. Once the pipeline has been created you can trigger the pipeline using the following comment:
/azp run java - [service] - ci

@alzimmermsft alzimmermsft requested a review from lmolkova as a code owner June 15, 2021 17:10
@alzimmermsft alzimmermsft enabled auto-merge (squash) July 15, 2021 21:58
@alzimmermsft alzimmermsft merged commit 7a28de3 into Azure:main Jul 15, 2021
@alzimmermsft alzimmermsft deleted the AzCore_AddHttpLoggingHooks branch July 15, 2021 23:23
openapi-sdkautomation bot pushed a commit to AzureSDKAutomation/azure-sdk-for-java that referenced this pull request Oct 1, 2021
Merging ConnectedVMwarevSphere changes from azure-rest-api-specs-pr private repo... (Azure#16088)

* Merging connectedvmware swagger from pr branch

* minor updates

* minor update

* fixing lint warnings

* updates

* sync latest from private repo

* copy examples from private repo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Azure.Core azure-core Client This issue points to a problem in the data-plane of the library.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Add Request and Response Logging Hooks to HttpLoggingPolicy
3 participants