Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Commit

Permalink
feat(zipkin) override unknown-service-name
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyjpj0916 authored and bungle committed Aug 16, 2019
1 parent b5272ef commit 6c017ed
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
15 changes: 12 additions & 3 deletions kong/plugins/zipkin/reporter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ local zipkin_reporter_mt = {

local function new_zipkin_reporter(conf)
local http_endpoint = conf.http_endpoint
local default_service_name = conf.default_service_name
assert(type(http_endpoint) == "string", "invalid http endpoint")
return setmetatable({
default_service_name = default_service_name;
http_endpoint = http_endpoint;
pending_spans = {};
pending_spans_n = 0;
Expand Down Expand Up @@ -48,8 +50,15 @@ function zipkin_reporter_methods:report(span)
-- TODO: ip/port from ngx.var.server_name/ngx.var.server_port?
}
else
-- needs to be null; not the empty object
localEndpoint = cjson.null
-- configurable override of the unknown-service-name spans
if self.default_service_name then
localEndpoint = {
serviceName = self.default_service_name;
}
-- needs to be null; not the empty object
else
localEndpoint = cjson.null
end
end
end

Expand Down Expand Up @@ -118,4 +127,4 @@ end

return {
new = new_zipkin_reporter;
}
}
1 change: 1 addition & 0 deletions kong/plugins/zipkin/schema.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ return {
{ sample_ratio = { type = "number",
default = 0.001,
between = { 0, 1 } } },
{ default_service_name = { type = "string", default = nil } },
{ include_credential = { type = "boolean", required = true, default = true } },
},
}, },
Expand Down

0 comments on commit 6c017ed

Please sign in to comment.