From 1082f94c34529ddebdfd7aadc6a79d9580b3eb79 Mon Sep 17 00:00:00 2001 From: WenMing Date: Wed, 24 Jul 2019 20:48:45 +0800 Subject: [PATCH] removed useless code. --- lua/apisix/plugins/zipkin.lua | 2 +- lua/apisix/plugins/zipkin/handler.lua | 41 --------------------------- 2 files changed, 1 insertion(+), 42 deletions(-) delete mode 100644 lua/apisix/plugins/zipkin/handler.lua diff --git a/lua/apisix/plugins/zipkin.lua b/lua/apisix/plugins/zipkin.lua index d3d5488ee5acd..977a538131d9a 100644 --- a/lua/apisix/plugins/zipkin.lua +++ b/lua/apisix/plugins/zipkin.lua @@ -41,7 +41,7 @@ end local function create_tracer(conf) - local tracer = new_tracer(new_reporter(conf), new_random_sampler(conf)) + local tracer = new_tracer(new_reporter(conf), new_random_sampler(conf)) tracer:register_injector("http_headers", zipkin_codec.new_injector()) tracer:register_extractor("http_headers", zipkin_codec.new_extractor()) return tracer diff --git a/lua/apisix/plugins/zipkin/handler.lua b/lua/apisix/plugins/zipkin/handler.lua deleted file mode 100644 index 2b2513fddd8bb..0000000000000 --- a/lua/apisix/plugins/zipkin/handler.lua +++ /dev/null @@ -1,41 +0,0 @@ -local new_tracer = require "opentracing.tracer".new -local zipkin_codec = require "kong.plugins.zipkin.codec" -local new_random_sampler = require "kong.plugins.zipkin.random_sampler".new -local new_zipkin_reporter = require "kong.plugins.zipkin.reporter".new -local OpenTracingHandler = require "kong.plugins.zipkin.opentracing" - --- Zipkin plugin derives from general opentracing one -local ZipkinLogHandler = OpenTracingHandler:extend() -ZipkinLogHandler.VERSION = "scm" - -function ZipkinLogHandler.new_tracer(conf) - local tracer = new_tracer(new_zipkin_reporter(conf), new_random_sampler(conf)) - tracer:register_injector("http_headers", zipkin_codec.new_injector()) - tracer:register_extractor("http_headers", zipkin_codec.new_extractor()) - return tracer -end - -local function log(premature, reporter) - if premature then - return - end - - local ok, err = reporter:flush() - if not ok then - kong.log.err("reporter flush ", err) - return - end -end - -function ZipkinLogHandler:log(conf) - ZipkinLogHandler.super.log(self, conf) - - local tracer = self:get_tracer(conf) - local zipkin_reporter = tracer.reporter -- XXX: not guaranteed by opentracing-lua? - local ok, err = ngx.timer.at(0, log, zipkin_reporter) - if not ok then - kong.log.err("failed to create timer: ", err) - end -end - -return ZipkinLogHandler