The OpenTelemetry plugin names all transactions statically as “kong” instead of using the expected format with the protocol, method, host, port, and path.
OpenTelemetry plugin in Kong is naming all transactions statically as "kong"
Why does the OpenTelemetry plugin name all transactions statically as “kong”?
A change in Kong Gateway made the OpenTelemetry plugin use a static “kong” trace name instead of the protocol/method/host/port/path format. Work around it with a global pre-function (Serverless Functions) plugin that sets root_span.name from the request method and path in the header_filter phase.
Cause
The change in question was introduced in this PR.
Solution
To work around this issue you can enable a global pre-function plugin that sets the trace name to include the method and path, as shown below.
Here is the Lua code snippet that you can use in a Serverless Functions plugin to dynamically set the trace name:
header_filter:
local root_span = kong.tracing.active_span()
local path = kong.request.get_path()
local method = kong.request.get_method()
root_span.name = method .. " " .. pathYou can find more information on how to use the Serverless Functions plugin in the Kong documentation: Serverless Functions.