Skip to content

Commit

Permalink
improve the flame chisel to emit a single object instead of 3 variables.
Browse files Browse the repository at this point in the history
  • Loading branch information
ldegio committed Oct 20, 2016
1 parent 6f52840 commit f6f1d09
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions userspace/sysdig/chisels/flame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function on_init()
end

fid = chisel.request_field("span.id")
flatency = chisel.request_field("span.latency")
flatency = chisel.request_field("span.duration")
fcontname = chisel.request_field("container.name")
fexe = chisel.request_field("proc.exeline")
fbuf = chisel.request_field("evt.buffer")
Expand Down Expand Up @@ -452,11 +452,13 @@ function on_capture_end()
normalize(v, v.n)
end

print "var FlameData = {"

-- emit the average transaction
local AvgData = {}
AvgData[""] = {ch=avg_tree, t=0, tt=0}
local str = json.encode(AvgData, { indent = true })
print("AvgData = " .. str .. ";")
print('"AvgData": ' .. str .. ",")

-- normalize the best transaction
for i,v in pairs(min_tree) do
Expand All @@ -467,7 +469,7 @@ function on_capture_end()
local tdata = {}
tdata[""] = {ch=min_tree, t=0, tt=0}
local str = json.encode(tdata, { indent = true })
print("MinData = " .. str .. ";")
print('"MinData": ' .. str .. ",")

-- normalize the worst transaction
for i,v in pairs(max_tree) do
Expand All @@ -478,5 +480,7 @@ function on_capture_end()
local tdata = {}
tdata[""] = {ch=max_tree, t=0, tt=0}
local str = json.encode(tdata, { indent = true })
print("MaxData = " .. str .. ";")
print('"MaxData": ' .. str .. ",")

print "};"
end

0 comments on commit f6f1d09

Please sign in to comment.