Skip to content

feat: As a user, I want to be able to choose "root span name", so that I can better distringuish traces #13748

Description

@UnoYakshi

Clarification/Context

I have Tempo+Grafana setup, traces are correctly sent to the OTLP endpoint. However, I'd like the "Name" column (in Grafana) to show "http.target" / "url.uri" (of span attributes) and not "http.route". Because, for multiple endpoints, I'd get the same "Name", e.g., /api/admin/*. But it's currently hardcoded in opentelemetry.lua#L417.
As mentioned here, frontend application should own/be the parent span. However, when no there is no frontend application, it's not the case. And I'd like to be able to better distinguish one request from another.

Suggestion

What if we add another parameter to opentelemetry plug-in, span_name_strategy?

{
  "span_name_strategy": "path|target"
}

(pseudocode)

-- Either `metadata_schema` or `schema`...
local schema = {
    type = "object",
    properties = {

        -- ...

        span_name_strategy = {
            type = "string",
            enum = {"path", "target"},
            default = "path",
        },

        -- ...
}

-- ...

local function resolve_span_name(conf, api_ctx)
    local span_name_strategy = conf.span_name_strategy or "route"

    if strategy == "target" then
        return api_ctx.var.uri
    end

    return api_ctx.curr_req_matched._path
end

-- ...

-- Closer to line 417...
local span_name_suffix = resolve_span_name_suffix(plugin_info, api_ctx)
span_name = span_name .. " " .. span_name_suffix

WIP PR

#13749

I'm not really sure how to affect only root span, and not children.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status
    📋 Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions