Skip to content
This repository was archived by the owner on Nov 30, 2021. It is now read-only.
12 changes: 10 additions & 2 deletions kong/plugins/zipkin/handler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,16 @@ if subsystem == "http" then
initialize_request = function(conf, ctx)
local req = kong.request

local header_type, trace_id, span_id, parent_id, should_sample, baggage =
tracing_headers.parse(req.get_headers())
local header_type = conf.default_header_type
local trace_id, span_id, parent_id, should_sample, baggage

-- If header_type is set to `ignore`, then the default_header_type will
-- be used to initiate a new trace.
if conf.header_type ~= "ignore" then
header_type, trace_id, span_id, parent_id, should_sample, baggage =
tracing_headers.parse(req.get_headers())
end

local method = req.get_method()

if should_sample == nil then
Expand Down
2 changes: 1 addition & 1 deletion kong/plugins/zipkin/schema.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ return {
{ include_credential = { type = "boolean", required = true, default = true } },
{ traceid_byte_count = { type = "integer", required = true, default = 16, one_of = { 8, 16 } } },
{ header_type = { type = "string", required = true, default = "preserve",
one_of = { "preserve", "b3", "b3-single", "w3c", "jaeger" } } },
one_of = { "preserve", "ignore", "b3", "b3-single", "w3c", "jaeger" } } },
{ default_header_type = { type = "string", required = true, default = "b3",
one_of = { "b3", "b3-single", "w3c", "jaeger" } } },
{ static_tags = { type = "array", elements = static_tag,
Expand Down
3 changes: 3 additions & 0 deletions kong/plugins/zipkin/tracing_headers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,10 @@ end
local function set(conf_header_type, found_header_type, proxy_span, conf_default_header_type)
local set_header = kong.service.request.set_header

-- If conf_header_type is set to `preserve`, found_header_type is used over default_header_type;
-- if conf_header_type is set to `ignore`, found_header_type is not set, thus default_header_type is used.
if conf_header_type ~= "preserve" and
conf_header_type ~= "ignore" and
found_header_type ~= nil and
conf_header_type ~= found_header_type
then
Expand Down