-
Notifications
You must be signed in to change notification settings - Fork 87
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
Document HTTPX kwargs #668
Conversation
Deploying logfire-docs with Cloudflare Pages
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #668 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 137 137
Lines 10750 10750
Branches 1473 1473
=========================================
Hits 10750 10750 ☔ View full report in Codecov by Sentry. |
From #655 (comment):
I think the desire was for |
So... Should we create the |
But I mean, this PR may not solve any issue, but I think it's still a valid improvement on the docs. |
attributes: defaultdict[str, str] = defaultdict(list) | ||
for key, value in headers.items(): | ||
key = key.lower() | ||
attributes[f'http.request.header.{key}'].append(value) |
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.
I started working on capturing headers. Currently that code is stashed. Once pushed this will become a bad example.
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 you suggest a useful example? I couldn't think of any...
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.
Capturing URL query params as proper attributes?
|
||
|
||
async def async_request_hook(span: Span, request: RequestInfo): | ||
"""This is called when using a `httpx.AsyncClient`.""" |
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.
Two additional notes:
async_request_hook
has to be a coroutine function, i.e. defined withasync def
, even if it only does sync things.- When instrumenting a client, the parameter is always called
request_hook
. To make it an async hook, it has to be defined as async. The type of client isn't taken into account.
I think we can automate dealing with this in the SDK. Maybe it should be an OTEL issue.
Co-authored-by: Alex Hall <[email protected]>
I think the original request was that
That's one possibility. But I don't know what you'd do about types like But we don't need to have formal docs of all the types. I'm just saying that the docstring needs something. And no, it doesn't need to block this PR. |
|
||
The `request_hook` and `async_request_hook` hooks are called before sending a request. They receive two arguments: | ||
|
||
```py title="main.py" hl_lines="24-27" |
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.
```py title="main.py" hl_lines="24-27" | |
```py title="main.py" |
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?
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 are those lines highlighted? It looks weird. I thought it wasn't intentional.
|
||
The `response_hook` and `async_response_hook` hooks are called after receiving a response. They receive three arguments: | ||
|
||
```py title="main.py" hl_lines="29-32" |
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.
```py title="main.py" hl_lines="29-32" | |
```py title="main.py" |
Co-authored-by: Alex Hall <[email protected]>
This PR is outdated. Let me craft something better.. |
No description provided.