提交 db0d3c76 编写于 作者: wu-sheng's avatar wu-sheng

Remove tags/logs in report JSON, if there is no tag or log

上级 11fcae0d
......@@ -67,9 +67,12 @@ function Segment:transform()
segmentBuilder.serviceInstanceId = self.service_inst_id
segmentBuilder.spans = {}
for i, span in ipairs(self.spans)
do
segmentBuilder.spans[#segmentBuilder.spans + 1] = span:transform()
if self.spans ~= nil and #self.spans > 0 then
for i, span in ipairs(self.spans)
do
segmentBuilder.spans[#segmentBuilder.spans + 1] = span:transform()
end
end
return segmentBuilder
......
......@@ -171,8 +171,6 @@ function Span:new(operationName, context, parent)
-- o.start_time = Util.timestamp()
o.refs = {}
o.owner = context
o.tags = {}
o.logs = {}
return o
end
......@@ -265,6 +263,10 @@ function Span:tag(tagKey, tagValue)
return self
end
if self.tags == nil then
self.tags = {}
end
local tag = {key = tagKey, value = tagValue}
self.tags[#self.tags + 1] = tag
......@@ -277,6 +279,10 @@ function Span:log(timestamp, keyValuePairs)
return self
end
if self.logs == nil then
self.logs = {}
end
local logEntity = {time = timestamp, data = keyValuePairs}
self.logs[#self.logs + 1] = logEntity
......
......@@ -110,6 +110,8 @@ function TracingContext:drainAfterFinished()
if self.internal.active_count ~= 0 then
return false, nil
elseif #self.internal.finished_spans == 0 then
return false, nil
else
local segment = Segment:new()
segment.trace_id = self.trace_id
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册