You are browsing documentation for an outdated plugin version.
The OpenTelemetry plugin is built on top of the Kong Gateway tracing PDK.
It’s possible to customize the spans and add your own spans through the universal tracing PDK.
Create a custom span
The following is an example for adding a custom span using Kong Gateway’s serverless plugin:
-
Create a file named
custom-span.lua
with the following content:-- Modify the root span local root_span = kong.tracing.active_span() root_span:set_attribute("custom.attribute", "custom value") -- Create a custom span local span = kong.tracing.start_span("custom-span") -- Append attributes span:set_attribute("custom.attribute", "custom value") -- Close the span span:finish()
-
Apply the Lua code using the
post-function
plugin using a cURL file upload:curl -i -X POST http://localhost:8001/plugins \ -F "name=post-function" \ -F "config.access[1]=@custom-span.lua" HTTP/1.1 201 Created ...