From 68a544d8335c20b5e9984b290500d126a6eaee32 Mon Sep 17 00:00:00 2001 From: sabertobihwy Date: Wed, 23 Aug 2023 15:02:07 +0800 Subject: [PATCH 1/7] refactor(statsd): refactor workspace id and name retrieval use the workspace created by default to avoid querying the database for workspace ID and name with every request. --- kong/plugins/statsd/log.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/kong/plugins/statsd/log.lua b/kong/plugins/statsd/log.lua index 28d1ad6b00f3..8b527d879c01 100644 --- a/kong/plugins/statsd/log.lua +++ b/kong/plugins/statsd/log.lua @@ -129,11 +129,10 @@ local get_service_id = { local get_workspace_id = { workspace_id = function() - return ws.get_workspace_id() + return kong.default_workspace end, workspace_name = function() - local workspace = ws.get_workspace() - return workspace.name + return "default" end } From 623ba0da62352e41db6385e93b7d53217ff8ef33 Mon Sep 17 00:00:00 2001 From: sabertobihwy Date: Wed, 23 Aug 2023 15:19:50 +0800 Subject: [PATCH 2/7] remove unnecessary code --- kong/plugins/statsd/log.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/kong/plugins/statsd/log.lua b/kong/plugins/statsd/log.lua index 8b527d879c01..ad9fd2faea5a 100644 --- a/kong/plugins/statsd/log.lua +++ b/kong/plugins/statsd/log.lua @@ -1,7 +1,6 @@ local Queue = require "kong.tools.queue" local constants = require "kong.plugins.statsd.constants" local statsd_logger = require "kong.plugins.statsd.statsd_logger" -local ws = require "kong.workspaces" local ngx = ngx local kong = kong From 7b0b4d6928278706d91ecb5933713dbec9fe4cdf Mon Sep 17 00:00:00 2001 From: sabertobihwy Date: Mon, 28 Aug 2023 15:57:30 +0800 Subject: [PATCH 3/7] add new workspace function and update statsd log --- kong/plugins/statsd/log.lua | 5 +++-- kong/workspaces/init.lua | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/kong/plugins/statsd/log.lua b/kong/plugins/statsd/log.lua index ad9fd2faea5a..d0bede908d67 100644 --- a/kong/plugins/statsd/log.lua +++ b/kong/plugins/statsd/log.lua @@ -1,6 +1,7 @@ local Queue = require "kong.tools.queue" local constants = require "kong.plugins.statsd.constants" local statsd_logger = require "kong.plugins.statsd.statsd_logger" +local ws = require "kong.workspaces" local ngx = ngx local kong = kong @@ -128,10 +129,10 @@ local get_service_id = { local get_workspace_id = { workspace_id = function() - return kong.default_workspace + return ws.get_workspace_id() end, workspace_name = function() - return "default" + return ws.get_workspace_name() end } diff --git a/kong/workspaces/init.lua b/kong/workspaces/init.lua index c877a6e777d8..87e780ce30d7 100644 --- a/kong/workspaces/init.lua +++ b/kong/workspaces/init.lua @@ -34,6 +34,11 @@ function workspaces.get_workspace() end +function workspaces.get_workspace_name() + return "default" +end + + function workspaces.set_workspace(ws) ngx.ctx.workspace = ws and ws.id end From 69a3733b029b30644ba16c56ae784411667433e4 Mon Sep 17 00:00:00 2001 From: sabertobihwy Date: Fri, 8 Sep 2023 17:51:09 +0800 Subject: [PATCH 4/7] add Changelog --- CHANGELOG/unreleased/kong/11442.yaml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 CHANGELOG/unreleased/kong/11442.yaml diff --git a/CHANGELOG/unreleased/kong/11442.yaml b/CHANGELOG/unreleased/kong/11442.yaml new file mode 100644 index 000000000000..954725009bcc --- /dev/null +++ b/CHANGELOG/unreleased/kong/11442.yaml @@ -0,0 +1,7 @@ +message: refactor workspace id and name retrieval +type: refactor +scope: Core +prs: +- 11442 +jiras: +- "FTI-5303" \ No newline at end of file From 13f46a258dc45421476891509a0f3f8b5ce6032f Mon Sep 17 00:00:00 2001 From: sabertobihwy Date: Fri, 8 Sep 2023 17:51:34 +0800 Subject: [PATCH 5/7] chore --- CHANGELOG/unreleased/kong/11442.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG/unreleased/kong/11442.yaml b/CHANGELOG/unreleased/kong/11442.yaml index 954725009bcc..a3232cd160ce 100644 --- a/CHANGELOG/unreleased/kong/11442.yaml +++ b/CHANGELOG/unreleased/kong/11442.yaml @@ -4,4 +4,4 @@ scope: Core prs: - 11442 jiras: -- "FTI-5303" \ No newline at end of file +- "FTI-5303" From 6a6f78d6f6a2eae9a9358473fa54cce492a88b12 Mon Sep 17 00:00:00 2001 From: sabertobihwy Date: Fri, 8 Sep 2023 17:59:02 +0800 Subject: [PATCH 6/7] fix changelog type --- CHANGELOG/unreleased/kong/11442.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG/unreleased/kong/11442.yaml b/CHANGELOG/unreleased/kong/11442.yaml index a3232cd160ce..f83903f04709 100644 --- a/CHANGELOG/unreleased/kong/11442.yaml +++ b/CHANGELOG/unreleased/kong/11442.yaml @@ -1,5 +1,5 @@ message: refactor workspace id and name retrieval -type: refactor +type: feature scope: Core prs: - 11442 From 99e8e019cba49c51fca5a572d00d808bb990fce9 Mon Sep 17 00:00:00 2001 From: sabertobihwy Date: Fri, 8 Sep 2023 18:00:27 +0800 Subject: [PATCH 7/7] correction changlog type --- CHANGELOG/unreleased/kong/11442.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG/unreleased/kong/11442.yaml b/CHANGELOG/unreleased/kong/11442.yaml index f83903f04709..30dc3e5fe2e8 100644 --- a/CHANGELOG/unreleased/kong/11442.yaml +++ b/CHANGELOG/unreleased/kong/11442.yaml @@ -1,5 +1,5 @@ message: refactor workspace id and name retrieval -type: feature +type: performance scope: Core prs: - 11442