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

Document HTTPX parameters #781

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions docs/integrations/http-clients/httpx.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,5 +146,54 @@ client.get('https://httpbin.org/get')

You can also use the hooks to filter headers or modify them before capturing them.

### Capture HTTP Bodies

By default, **Logfire** doesn't capture HTTP bodies.

#### Capture Request Body

You can enable capturing the request body by setting the `capture_request_body` parameter to `True`.

```py
import httpx
import logfire

logfire.configure()
logfire.instrument_httpx(capture_request_body=True)

client = httpx.Client()
client.post("https://httpbin.org/post", data="Hello, World!")
```

#### Capture Response Body

You can enable capturing the response body by setting the `capture_response_body` parameter to `True`.

```py
import httpx
import logfire

logfire.configure()
logfire.instrument_httpx(capture_response_body=True)

client = httpx.Client()
client.get("https://httpbin.org/get")
```

### Capture All Information

You can capture all information (headers and bodies) by setting the `capture_all` parameter to `True`.

```py
import httpx
import logfire

logfire.configure()
logfire.instrument_httpx(capture_all=True)

client = httpx.Client()
client.post("https://httpbin.org/post", data="Hello, World!")
```

[httpx]: https://www.python-httpx.org/
[opentelemetry-httpx]: https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/httpx/httpx.html
Loading