-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathmtev-http2-module.lua
More file actions
46 lines (41 loc) · 1.43 KB
/
mtev-http2-module.lua
File metadata and controls
46 lines (41 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
local function L(...)
pmodule.log(pmodule.log_level.info, string.format(...))
end
local function bt2str(bt_var, len)
len = len or 256
local addr = pmodule.variable_from_bt(bt_var):value()
return pmodule.address_read_string(addr, len)
end
local function bt2val(bt_var)
return pmodule.variable_from_bt(bt_var):value()
end
local function variable_http2_cb(pt_var, bt_var)
local tid = pt_var:thread():tid()
local method = bt2str(bt_var.method_str)
local uri = bt2str(bt_var.uri_str)
local qs = bt2str(bt_var.orig_qs)
qs = qs and ("?" .. qs) or ""
local length = bt2val(bt_var.content_length) or -1
local payload_len = bt2val(bt_var.upload.size)
local payload = bt2str(bt_var.upload.data, payload_len + 1)
pt_var:thread():annotate(
pmodule.annotation.comment,
string.format("mtev_http2_request: %s %s%s (%d)", method, uri, qs, length))
pt_var:backtrace():add_kv_string(
"mtev_http_request",
string.format("%s %s%s (%d)", method, uri, qs, length))
pt_var:backtrace():add_kv_string(
"mtev_http_payload_in",
string.format("%s", payload))
end
local function pm_mtev_http2_req()
L("module-mtev-http2: load")
local m = pmodule.match()
m:add_file("mtev_http", pmodule.match_type.substr)
m:add_variable_base_type("mtev_http2_request", pmodule.match_type.exact)
pmodule.register(pmodule.event.variable, variable_http2_cb, m)
end
pmodule.define {
id = "mtev_http2_req",
load = pm_mtev_http2_req,
}