Skip to content

Commit 2b2201c

Browse files
mayocreamfffonion
andauthored
chore(tracing): add tracing_instrumentations and tracing_sampling_rate in kong.conf, deprecate opentelemetry_* (#10122)
KAG-446 Co-authored-by: Wangchong Zhou <[email protected]>
1 parent 486c07a commit 2b2201c

File tree

8 files changed

+57
-42
lines changed

8 files changed

+57
-42
lines changed

kong.conf.default

+31-28
Original file line numberDiff line numberDiff line change
@@ -103,34 +103,37 @@
103103
# such in the Lua namespace:
104104
# `kong.vaults.{name}.*`.
105105

106-
#opentelemetry_tracing = off # Comma-separated list of tracing instrumentations
107-
# this node should load. By default, no instrumentations
108-
# are enabled.
109-
#
110-
# Valid values to this setting are:
111-
#
112-
# - `off`: do not enable instrumentations.
113-
# - `request`: only enable request-level instrumentations.
114-
# - `all`: enable all the following instrumentations.
115-
# - `db_query`: trace database query, including
116-
# Postgres and Cassandra.
117-
# - `dns_query`: trace DNS query.
118-
# - `router`: trace router execution, including
119-
# router rebuilding.
120-
# - `http_client`: trace OpenResty HTTP client requests.
121-
# - `balancer`: trace balancer retries.
122-
# - `plugin_rewrite`: trace plugins iterator
123-
# execution with rewrite phase.
124-
# - `plugin_access`: trace plugins iterator
125-
# execution with access phase.
126-
# - `plugin_header_filter`: trace plugins iterator
127-
# execution with header_filter phase.
128-
#
129-
# **Note:** In the current implementation,
130-
# tracing instrumentations are not enabled in
131-
# stream mode.
132-
133-
#opentelemetry_tracing_sampling_rate = 1.0 # Tracing instrumentation sampling rate.
106+
#opentelemetry_tracing = off # Deprecated: use tracing_instrumentatios instead
107+
108+
#tracing_instrumentations = off # Comma-separated list of tracing instrumentations
109+
# this node should load. By default, no instrumentations
110+
# are enabled.
111+
#
112+
# Valid values to this setting are:
113+
#
114+
# - `off`: do not enable instrumentations.
115+
# - `request`: only enable request-level instrumentations.
116+
# - `all`: enable all the following instrumentations.
117+
# - `db_query`: trace database query, including
118+
# Postgres and Cassandra.
119+
# - `dns_query`: trace DNS query.
120+
# - `router`: trace router execution, including
121+
# router rebuilding.
122+
# - `http_client`: trace OpenResty HTTP client requests.
123+
# - `balancer`: trace balancer retries.
124+
# - `plugin_rewrite`: trace plugins iterator
125+
# execution with rewrite phase.
126+
# - `plugin_access`: trace plugins iterator
127+
# execution with access phase.
128+
# - `plugin_header_filter`: trace plugins iterator
129+
# execution with header_filter phase.
130+
#
131+
# **Note:** In the current implementation,
132+
# tracing instrumentations are not enabled in
133+
# stream mode.
134+
135+
#opentelemetry_tracing_sampling_rate = 1.0 # Deprecated: use tracing_sampling_rate instead
136+
#tracing_sampling_rate = 1.0 # Tracing instrumentation sampling rate.
134137
# Tracer samples a fixed percentage of all spans
135138
# following the sampling rate.
136139
#

kong/conf_loader/init.lua

+18-8
Original file line numberDiff line numberDiff line change
@@ -547,8 +547,18 @@ local CONF_PARSERS = {
547547
lmdb_environment_path = { typ = "string" },
548548
lmdb_map_size = { typ = "string" },
549549

550-
opentelemetry_tracing = { typ = "array" },
551-
opentelemetry_tracing_sampling_rate = { typ = "number" },
550+
tracing_instrumentations= {
551+
typ = "array",
552+
deprecated = {
553+
replacement = "opentelemetry_tracing",
554+
},
555+
},
556+
tracing_sampling_rate = {
557+
typ = "number",
558+
deprecated = {
559+
replacement = "opentelemetry_tracing_sampling_rate",
560+
},
561+
},
552562

553563
proxy_server = { typ = "string" },
554564
proxy_server_ssl_verify = { typ = "boolean" },
@@ -1174,27 +1184,27 @@ local function check_and_parse(conf, opts)
11741184
errors[#errors + 1] = "upstream_keepalive_idle_timeout must be 0 or greater"
11751185
end
11761186

1177-
if conf.opentelemetry_tracing and #conf.opentelemetry_tracing > 0 then
1187+
if conf.tracing_instrumentations and #conf.tracing_instrumentations > 0 then
11781188
local instrumentation = require "kong.tracing.instrumentation"
11791189
local available_types_map = tablex.deepcopy(instrumentation.available_types)
11801190
available_types_map["all"] = true
11811191
available_types_map["off"] = true
11821192
available_types_map["request"] = true
11831193

1184-
for _, trace_type in ipairs(conf.opentelemetry_tracing) do
1194+
for _, trace_type in ipairs(conf.tracing_instrumentations) do
11851195
if not available_types_map[trace_type] then
11861196
errors[#errors + 1] = "invalid opentelemetry tracing type: " .. trace_type
11871197
end
11881198
end
11891199

1190-
if #conf.opentelemetry_tracing > 1
1191-
and tablex.find(conf.opentelemetry_tracing, "off")
1200+
if #conf.tracing_instrumentations > 1
1201+
and tablex.find(conf.tracing_instrumentations, "off")
11921202
then
11931203
errors[#errors + 1] = "invalid opentelemetry tracing types: off, other types are mutually exclusive"
11941204
end
11951205

1196-
if conf.opentelemetry_tracing_sampling_rate < 0 or conf.opentelemetry_tracing_sampling_rate > 1 then
1197-
errors[#errors + 1] = "opentelemetry_tracing_sampling_rate must be between 0 and 1"
1206+
if conf.tracing_sampling_rate < 0 or conf.tracing_sampling_rate > 1 then
1207+
errors[#errors + 1] = "tracing_sampling_rate must be between 0 and 1"
11981208
end
11991209
end
12001210

kong/globalpatches.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ return function(options)
463463

464464
-- DNS query is lazily patched, it will only be wrapped
465465
-- when instrumentation module is initialized later and
466-
-- `opentelemetry_tracing` includes "dns_query" or set
466+
-- `tracing_instrumentations` includes "dns_query" or set
467467
-- to "all".
468468
local instrumentation = require "kong.tracing.instrumentation"
469469
instrumentation.set_patch_dns_query_fn(toip, function(wrap)

kong/templates/kong_defaults.lua

+2
Original file line numberDiff line numberDiff line change
@@ -190,4 +190,6 @@ openresty_path =
190190
191191
opentelemetry_tracing = off
192192
opentelemetry_tracing_sampling_rate = 1.0
193+
tracing_instrumentations = off
194+
tracing_sampling_rate = 1.0
193195
]]

kong/tracing/instrumentation.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,8 @@ function _M.runloop_log_after(ctx)
335335
end
336336

337337
function _M.init(config)
338-
local trace_types = config.opentelemetry_tracing
339-
local sampling_rate = config.opentelemetry_tracing_sampling_rate
338+
local trace_types = config.tracing_instrumentations
339+
local sampling_rate = config.tracing_sampling_rate
340340
assert(type(trace_types) == "table" and next(trace_types))
341341
assert(sampling_rate >= 0 and sampling_rate <= 1)
342342

spec/02-integration/14-tracing/01-instrumentations_spec.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ for _, strategy in helpers.each_strategy() do
3838
database = strategy,
3939
nginx_conf = "spec/fixtures/custom_nginx.template",
4040
plugins = "tcp-trace-exporter",
41-
opentelemetry_tracing = types,
41+
tracing_instrumentations = types,
4242
})
4343

4444
proxy_client = helpers.proxy_client()

spec/03-plugins/37-opentelemetry/04-exporter_spec.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ for _, strategy in helpers.each_strategy() do
9191
database = strategy,
9292
nginx_conf = "spec/fixtures/custom_nginx.template",
9393
plugins = "opentelemetry",
94-
opentelemetry_tracing = types,
94+
tracing_instrumentations = types,
9595
}, nil, nil, fixtures))
9696
end
9797

spec/03-plugins/37-opentelemetry/05-otelcol_spec.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ for _, strategy in helpers.each_strategy() do
4747
database = strategy,
4848
nginx_conf = "spec/fixtures/custom_nginx.template",
4949
plugins = "opentelemetry",
50-
opentelemetry_tracing = types,
50+
tracing_instrumentations = types,
5151
})
5252

5353
proxy_url = fmt("http://%s:%s", helpers.get_proxy_ip(), helpers.get_proxy_port())

0 commit comments

Comments
 (0)