diff --git a/kong/plugins/opentelemetry/handler.lua b/kong/plugins/opentelemetry/handler.lua index 8ca68b5225d..3125c79f636 100644 --- a/kong/plugins/opentelemetry/handler.lua +++ b/kong/plugins/opentelemetry/handler.lua @@ -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) diff --git a/spec/03-plugins/37-opentelemetry/03-propagation_spec.lua b/spec/03-plugins/37-opentelemetry/03-propagation_spec.lua index bb7803158cc..8ce89d2a1f0 100644 --- a/spec/03-plugins/37-opentelemetry/03-propagation_spec.lua +++ b/spec/03-plugins/37-opentelemetry/03-propagation_spec.lua @@ -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("/", { @@ -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() @@ -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() @@ -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)