tokers commented on code in PR #7822: URL: https://github.com/apache/apisix/pull/7822#discussion_r959066037
########## apisix/plugins/opentelemetry.lua: ########## @@ -273,6 +280,26 @@ local function create_tracer_obj(conf) end +local function inject_attributes(attributes, wanted_attributes, source) + for _, key in ipairs(wanted_attributes) do + local is_key_a_match = #key >= 2 and string.sub(key, -1, -1) == "*" + local prefix = string.sub(key, 0, -2) + local prefix_size = #prefix + local val = source[key] + if val then + core.table.insert(attributes, attr.string(key, val)) + end + if is_key_a_match then + for possible_key, value in pairs(source) do + if string.sub(possible_key, 0, prefix_size) == prefix then Review Comment: We already have a `has_prefix` method in `apisix.core.string`. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
