Unifying or improving on event hooks & trace? #3379
Replies: 1 comment
-
I don’t find the Regarding the use cases
However, I would like to have some context for the traces so that they can communicate with each other and store useful information that can be utilized in other traces or even within the same trace at a different stage. I have an example of such a case here. Initially, I thought about the context between stages. For example, import httpx
def log(event_name, info, context):
_, event_name, stage = event_name.split(".")
if event_name == "start_tls":
context["tls_start_timestamp"] = 0
client = httpx.Client()
context = {}
extensions = {"trace_context": context, "trace": log}
client.get("https://www.example.com/", extensions=extensions)
print(context["tls_start_timestamp"]) |
Beta Was this translation helpful? Give feedback.
-
We've currently got an
event_hooks
API mirroring requests, with callbacks for"request"
and"response"
events.However we've now also got a much more comprehensive
"trace"
API.Here are some use-cases we might want to be able to support...
request.started
,request.complete
,response.started
,response.complete
timestamps.Are our existing APIs sufficient to be able to meet & document these use cases?
Are there improvements that we could make to provide a really neat unified API here?
Beta Was this translation helpful? Give feedback.
All reactions