Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(opentelemetry): set default propagation type to w3c #9457

Merged
merged 2 commits into from
Oct 28, 2022
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
2 changes: 1 addition & 1 deletion kong/plugins/opentelemetry/handler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ function OpenTelemetryHandler:rewrite()
root_span.parent_id = span_id
end

propagation_set("w3c", header_type, root_span)
propagation_set("preserve", header_type, root_span, "w3c")
end

function OpenTelemetryHandler:log(conf)
Expand Down
15 changes: 12 additions & 3 deletions spec/03-plugins/37-opentelemetry/03-propagation_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ describe("propagation tests #" .. strategy, function()
helpers.stop_kong()
end)

it("default propagation headers (w3c)", function()
local r = proxy_client:get("/", {
headers = {
host = "http-route",
},
})
local body = assert.response(r).has.status(200)
local json = cjson.decode(body)

assert.matches("00%-%x+-%x+-01", json.headers.traceparent)
end)

it("propagates tracing headers (b3 request)", function()
local trace_id = gen_trace_id()
local r = proxy_client:get("/", {
Expand All @@ -65,7 +77,6 @@ describe("propagation tests #" .. strategy, function()
local body = assert.response(r).has.status(200)
local json = cjson.decode(body)
assert.equals(trace_id, json.headers["x-b3-traceid"])
assert.matches("00%-" .. trace_id .. "%-%x+-01", json.headers.traceparent)
end)

describe("propagates tracing headers (b3-single request)", function()
Expand All @@ -83,7 +94,6 @@ describe("propagation tests #" .. strategy, function()
local body = assert.response(r).has.status(200)
local json = cjson.decode(body)
assert.matches(trace_id .. "%-%x+%-1%-%x+", json.headers.b3)
assert.matches("00%-" .. trace_id .. "%-%x+-01", json.headers.traceparent)
end)

it("without parent_id", function()
Expand All @@ -99,7 +109,6 @@ describe("propagation tests #" .. strategy, function()
local body = assert.response(r).has.status(200)
local json = cjson.decode(body)
assert.matches(trace_id .. "%-%x+%-1", json.headers.b3)
assert.matches("00%-" .. trace_id .. "%-%x+-01", json.headers.traceparent)
end)
end)

Expand Down