Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
dmehala committed May 30, 2024
1 parent 15d7bd3 commit 0d81559
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
6 changes: 1 addition & 5 deletions kong/plugins/ddtrace/handler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,7 @@ local function apply_resource_name_rules(uri, rules)
end

local function configure(conf)
local get_from_vault = kong.vault.get
local get_env = function(env_name)
local env_value, _ = get_from_vault(string.format("{vault://env/%s}", env_name))
return env_value
end
local get_env = utils.get_env

-- Build agent url
local agent_host = get_env("DD_AGENT_HOST") or conf.agent_host or "localhost"
Expand Down
19 changes: 19 additions & 0 deletions kong/plugins/ddtrace/utils.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
local lrucache = require("resty.lrucache")

local ffi = require("ffi")
ffi.cdef([[
unsigned long long int strtoull(const char *nptr, char **endptr, int base);
Expand Down Expand Up @@ -124,9 +126,26 @@ local function join_table(separator, table)
return result
end

local LRU = lrucache.new(1000)

local function get_env(key)
local value = LRU:get(key)
if value then
return value
end

value = os.getenv(key)
if value then
LRU:set(key, value)
end

return value
end

return {
concat = concat,
dump = dump,
get_env = get_env,
join_table = join_table,
normalize_header_tags = normalize_header_tags,
parse_uint64 = parse_uint64,
Expand Down

0 comments on commit 0d81559

Please sign in to comment.