Hello
Here's a first proof-of-concept regarding an ad-hoc tracer for h2o based off dtrace probes. The aim was to be cost free when not attached, and still performant under load.
I implemented a small test client for it in python using EBPF/BCC, but any language can be used really. The script is here, and would require BCC. I pasted a sample output below.
The PR implements a communication socket to the tracing program. It allows to stop any tracing processing if the tracer program disconnects or crashes, and also some lightweight communication to filter out some events from being processed. This socket port is settable using the config below.
Cheers !
listen:
port: 4321
tracing: ON
% sudo ./picotracer.py `pgrep h2o`
>> 1553636178731756 36 SSLNew TLSv1.3 AES256-GCM 0x7ff626ffcac0
>> 1553636178731756 36 NewConnH2 10.0.2.15:9090 10.0.2.15:34200
>> 1553636178731756 36 RxHeader user-agent curl/7.64.0
>> 1553636178731756 36 RxHeader accept */*
>> 1553636178731756 36 NewReq HTTP/2 GET /assets/2.ts
>> 1553636178731756 36 Proxy [unix:/tmp/h2o.sock]
>> 1553636178731756 36 ProxyTxHdr user-agent curl/7.64.0
>> 1553636178731756 36 ProxyTxHdr accept */*
>> 1553636178731756 36 ProxyNewReq HTTP/1.1 GET /assets/2.ts
>> 1553636178731756 36 ProxyRxHdr date Tue, 26 Mar 2019 21:36:18 GMT
>> 1553636178731756 36 ProxyRxHdr content-type video/mp2t
>> 1553636178731756 36 ProxyRxHdr last-modified Mon, 06 Aug 2018 09:07:10 GMT
>> 1553636178731756 36 ProxyRxHdr etag "5b680fbe-1a8780"
>> 1553636178731756 36 ProxyRxHdr accept-ranges bytes
>> 1553636178731756 36 ProxyNewRes HTTP/1.1 200 len: 1738624
>> 1553636178731756 36 TxHeader date Tue, 26 Mar 2019 21:36:18 GMT
>> 1553636178731756 36 TxHeader content-type video/mp2t
>> 1553636178731756 36 TxHeader last-modified Mon, 06 Aug 2018 09:07:10 GMT
>> 1553636178731756 36 TxHeader etag "5b680fbe-1a8780"
>> 1553636178731756 36 TxHeader accept-ranges bytes
>> 1553636178731756 36 NewRes HTTP/2 200 len: 1738624