Py.Cafe

maartenbreddels/

logfire-httpx-monitoring

Logfire HTTPX Monitoring

DocsPricing
  • app.py
  • requirements.txt
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
"""This example demonstrates instrumenting HTTPX with Logfire."""
import streamlit as st
import logfire
import httpx # see https://www.python-httpx.org/

# to join the logfire project, 
# follow https://logfire.pydantic.dev/join/samuelcolvin/-/project-invitation/pydantic-run-demo/b7cce6af-8916-4f79-8542-47d9c550722d
logfire.configure(token='W3mkJvNKtxhpDk3Hx8WQWG3bg7qMH8lrVmnstdb1NRdF')
logfire.instrument_httpx(capture_all=True)


r = httpx.get('https://httpbin.org/get')
st.write('response code:', r.status_code)
st.markdown("#response text:")
st.json(r.text)
requirements.txt
1
2
3
4
5
6
7

streamlit==1.27.2  # currently pinned to this version
numpy
altair
pandas
logfire[httpx]==3.4.0
httpx