diff --git a/kong/plugins/prometheus/wasmx.lua b/kong/plugins/prometheus/wasmx.lua index d2aff3256c37..0b52f7f53d51 100644 --- a/kong/plugins/prometheus/wasmx.lua +++ b/kong/plugins/prometheus/wasmx.lua @@ -152,7 +152,16 @@ _M.metric_data = function() -- delayed require of the WasmX module, to ensure it is loaded -- after ngx_wasm_module.so is loaded. - wasmx_shm = wasmx_shm or require "resty.wasmx.shm" + if not wasmx_shm then + local ok, _wasmx_shm = pcall(require, "resty.wasmx.shm") + if ok then + wasmx_shm = _wasmx_shm + end + end + + if not wasmx_shm then + return + end wasmx_shm.metrics:lock()