-
Notifications
You must be signed in to change notification settings - Fork 11
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 HTTP Request and Response Logging #380
base: main
Are you sure you want to change the base?
Conversation
This PR introduces a new logging feature for HTTP requests and responses. It adds a new abstract logger interface in the abstractions package, implements it in the HTTP package, and integrates it with the HttpxRequestAdapter. Changes: 1. Add new abstract RequestResponseLogger class 2. Implement HttpxRequestResponseLogger in HTTP package 3. Integrate logger in HttpxRequestAdapter 4. Add JSON formatting support for log messages 5. Update relevant tests Files changed: - /packages/abstractions/kiota_abstractions/request_response_logger.py (new file) - /packages/http/httpx/kiota_http/httpx_request_response_logger.py (new file) - /packages/http/httpx/kiota_http/httpx_request_adapter.py - /packages/serialization/json/kiota_serialization_json/json_serialization_writer.py - /packages/http/httpx/tests/test_httpx_request_adapter.py
Quality Gate failedFailed conditions See analysis details on SonarCloud Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution!
I did leave a couple of questions and suggestions for improvements in the implementation.
Let us know if you have any additional comments or questions.
@@ -525,6 +528,20 @@ async def get_http_response_message( | |||
|
|||
self.set_base_url_for_request_information(request_info) | |||
|
|||
self.logger.log_request({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is the logging logic here instead of in a middleware handler?
@@ -387,6 +387,10 @@ def get_serialized_content(self) -> bytes: | |||
stream = json_string.encode('utf-8') | |||
return stream | |||
|
|||
@staticmethod |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we avoid expanding the API surface and look into an alternative here please?
from abc import ABC, abstractmethod | ||
from typing import Any, Dict | ||
|
||
class RequestResponseLogger(ABC): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we look into an alternative that does not expand the public API surface here please?
I will take a look |
This pull request has conflicting changes, the author must resolve the conflicts before this pull request can be merged. |
This PR introduces a new logging feature for HTTP requests and responses. It adds a new abstract logger interface in the abstractions package, implements it in the HTTP package, and integrates it with the HttpxRequestAdapter.
Changes:
Files changed: