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

feat(zipkin) override unknown-service-name #45

Merged
merged 1 commit into from
Aug 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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