Open satodaiki opened 2 years ago
In your example, aren't you planning to use the params from the context to set the request_id/request_start_time? I don't see how a constant would be of use to you...
However, since the context_factory is regenerated with each request, putting "hide_request_body_urls" in TraceConfigModel is not the preferred implementation.
I really don't see why you don't just put a reference in the class:
HIDE_REQUEST_BODY_URLS = ("https://httpstat.us/200",)
class TraceConfigModelFactory:
def __init__(self, **kwargs):
self._hide_request_body_urls = HIDE_REQUEST_BODY_URLS
or
class TraceConfigModelFactory:
hide_request_body_urls = ("https://httpstat.us/200",)
Is your feature request related to a problem?
hi, there.
In the current TraceConfig configuration, context_factory can be set, but no other values can be set. This is a little inconvenient when hiding bodies that you don't want to be output.
example:
(I'm using pydantic for readability.)
When you do this, you will see the hidden body on the standard output. However, since the context_factory is regenerated with each request, putting "hide_request_body_urls" in TraceConfigModel is not the preferred implementation. I thought it would be better to have it as a constant when creating the TraceConfig instance if possible.
Describe the solution you'd like
The easiest way to use it is to add an argument for the constant to the TraceConfig initialization argument. Or you can add that to the ClientSession side.
example:
(The variable names could be a bit better.)
Describe alternatives you've considered
As a workaround at the moment, it is possible to use dependency injection to get around this. We use python_dependency_injector for this.
example
Related component
Client
Additional context
No response
Code of Conduct