gy09535 commented on a change in pull request #2727:
URL: https://github.com/apache/apisix/pull/2727#discussion_r523924761
##########
File path: apisix/plugins/zipkin/reporter.lua
##########
@@ -105,39 +105,71 @@ function _M.report(self, span)
annotations = span.logs
}
- local i = self.pending_spans_n + 1
- self.pending_spans[i] = zipkin_span
- self.pending_spans_n = i
-end
-
-function _M.flush(self)
- if self.pending_spans_n == 0 then
-
- return true
+ self.pending_spans_n = self.pending_spans_n + 1
+ if self.processor then
+ self.processor:push(zipkin_span)
end
+end
- local pending_spans = cjson.encode(self.pending_spans)
- self.pending_spans = {}
- self.pending_spans_n = 0
-
+local function send_span(pending_spans, report)
local httpc = resty_http.new()
- local res, err = httpc:request_uri(self.endpoint, {
+ local res, err = httpc:request_uri(report.endpoint, {
method = "POST",
headers = {
["content-type"] = "application/json",
},
body = pending_spans,
+ keepalive = 5000,
+ keepalive_pool = 5
})
- -- TODO: on failure, retry?
if not res then
- return nil, "failed to request: " .. err
+ core.log.error("report span error: ", err)
+ return nil, "failed: " .. report.endpoint
Review comment:
fixed
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]