Add configurable `event_hooks` for the `httpx` layer for observability or `logging`
- Lingua principale
- Python
- Stelle
- 17
- Fork
- 2
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
**Is your feature request related to a problem? Please describe.**
While thinking about this problem for another platform we maintain, I came across [event_hooks](https://www.python-httpx.org/advanced/event-hooks/) in `httpx`.
We should make this configurable for the `gallagher` clients in case the user wants to add observability or `logging` for their implementation.
I don't believe the library should bother implementing the logging as a solution, it can provide reference implementations but not a solution.
**Describe the solution you'd like**
Modify the API so the developer can pass hooks into the initialisation which are called by the `httpx` layer upon requests placed and responses received.
In the case of `httpx` these work as interceptors where the developer can add additional headers etc.
Note that we will have to find a reliable mechanism to identify requests so we can perform operations like logging the body against other metadata, see also #2
**Describe alternatives you've considered**
NA
**Additional context**
For example the OpenAI python client allows you to pass in a configured `httpx` client
```python
import httpx
client = openai.OpenAI(
http_client=httpx.Client(
event_hooks={
"request": [print],
"response": [print]
}
)
)
```
we could follow a similar pattern and allow the developer to configure their `gallagher` API client and let them handle the result of the `request` and `responses`
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Valutazione
Questa issue non è ancora stata valutata.