The plugin does request sampling. For each request that triggers the plugin, a random number between 0 and 1 is chosen.
If the number is smaller than the configured config.sample_ratio
, then a trace with several spans will be generated. If config.sample_ratio
is set to 1, then all requests will generate a trace (this might be very noisy).
For each request that gets traced, the following spans are produced: request, proxy, and balancer.
Span kind: SERVER
There is one request span per request, which encompasses the whole request in Kong Gateway.
The proxy and balancer spans are children of this span. It contains the following logs/annotations for the rewrite phase:
-
krs
: kong.rewrite.start
-
krf
: kong.rewrite.finish
The request span has the following tags:
Tag
|
Description
|
lc
|
Hardcoded to kong .
|
kong.service
|
The UUID of the Gateway Service matched when processing the request, if any.
|
kong.service_name
|
The name of the Gateway Service matched when processing the request, if Gateway Service exists and has a name attribute.
|
kong.route
|
The UUID of the Route matched when processing the request, if any (it can be nil on non-matched requests).
|
kong.route_name
|
The name of the Route matched when processing the request, if Route exists and has a name attribute.
|
http.method
|
The HTTP method used on the original request (only for HTTP requests).
|
http.path
|
The path of the request (only for HTTP requests).
|
Additional tags:
- If the plugin
tags_header
config option is set, and the request contains headers with the appropriate name and correct encoding tags, then the trace will include the tags.
- If the plugin
static_tags
config option is set, then the tags in the config option will be included in the trace.
Span kind: CLIENT
There is one proxy span per request, encompassing most of Kong Gateway’s internal processing of a request.
The proxy span contains the following logs/annotations for the start/finish of the of the Kong Gateway plugin phases:
Tag
|
Phase
|
kas
|
kong.access.start
|
kaf
|
kong.access.finish
|
kbs
|
kong.body_filter.start
|
kbf
|
kong.body_filter.finish
|
khs
|
kong.header_filter.start
|
khf
|
kong.header_filter.finish
|
kps
|
kong.preread.start (only for stream requests)
|
kpf
|
kong.preread.finish (only for stream requests)
|
Span kind: CLIENT
There are zero or more balancer spans per request, each encompassing one balancer attempt.
This span contains the following tags specific to load balancing:
Tag
|
Description
|
kong.balancer.try
|
A number indicating the attempt (one for the first load-balancing attempt, two for the second, and so on).
|
peer.ipv4 or peer.ipv6
|
The balancer IP.
|
peer.port
|
The balancer port.
|
error
|
Set to true if the balancing attempt was unsuccessful, otherwise unset.
|
http.status_code
|
The HTTP status code received, in case of error.
|
kong.balancer.state
|
An NGINX-specific description of the error, next/failed for HTTP failures, or 0 for stream failures.
Equivalent to state_name in OpenResty’s balancer’s get_last_failure function.
|