Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion kong/observability/otlp/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,24 @@ local encode_traces, encode_logs, prepare_logs
do
local attributes_cache = setmetatable({}, { __mode = "k" })
local function default_resource_attributes()
return {
local attributes = {
["service.name"] = "kong",
["service.instance.id"] = kong and kong.node.get_id(),
["service.version"] = kong and kong.version,
}
local pod_name = os.getenv("POD_NAME")
local pod_uid = os.getenv("POD_UID")
local pod_host = os.getenv("K8S_HOST")
local pod_namespace = os.getenv("K8S_NAMESPACE")
if pod_uid ~= "" and pod_name ~= "" then
attributes = table_merge(attributes, {
["k8s.pod.name"] = pod_name,
["k8s.pod.uid"] = pod_uid,
["k8s.node.name"] = pod_host,
["k8s.namespace.name"] = pod_namespace,
})
end
return attributes
end

local function render_resource_attributes(attributes)
Expand Down