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

オープン
#13,748 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

  • #13749 @UnoYakshi による — マージされずにクローズ

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
lua

調査の方向性

まず、apisix/plugins/opentelemetry.lua の417行目付近にある root span の命名ロジックを読み、リンクされている WIP PR #13749 を確認します。opentelemetry プラグインが root span と child span をどのように区別しているかを追跡し、要求された strategy configuration、そのデフォルト動作、および結果として生じる名前の変更が root span のみに影響することを検証します。

索引モデルが issue の本文から書いたものです。

説明

feature-request

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

https://github.com/apache/apisix/pull/13749

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

主要言語
Lua
スター
17.3k
フォーク
3k
平均マージ
4日 16時間
マージ済み PR(30日)
69

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/apisix のほかの issue

apache/apisix の issue をすべて見る

似ている issue

Lua の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。