refactor: extract get_event_type_len()
@@ -803,6 +803,11 @@ def trace_quic():
except KeyboardInterrupt:
exit()
+def get_event_type_len(usdt, providers):
+ providers_set = set(providers)
+ probes = filter(lambda probe: probe.provider in providers_set, usdt.enumerate_probes())
+ return 1 + max(map(lambda probe: len("%s__%s" % (probe.provider, probe.name)), probes))
+
if len(sys.argv) < 1:
usage()
@@ -869,9 +874,7 @@ if sys.argv[1] == "quic":
# provider h2o:
u.enable_probe(probe="send_response_header", fn_name="trace_h2o__send_response_header")
- probes = filter(lambda probe: probe.provider == "h2o" or probe.provider == "quicly", u.enumerate_probes())
- max_event_type_len = 1 + max(map(lambda probe: len("%s__%s" % (probe.provider, probe.name)), probes))
- cflags = ["-DMAX_EVENT_TYPE_LEN=%s" % max_event_type_len]
+ cflags = ["-DMAX_EVENT_TYPE_LEN=%s" % get_event_type_len(u, ["h2o", "quicly"])]
b = BPF(text=quic_bpf, usdt_contexts=[u], cflags=cflags)
else:
u.enable_probe(probe="receive_request", fn_name="trace_receive_req")
