Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: add more spans to opentelemetry plugin#12686

Merged
nic-6443 merged 55 commits intoapache:masterfrom
nic-6443:nic/opentelemetry
Feb 7, 2026
Merged

feat: add more spans to opentelemetry plugin#12686
nic-6443 merged 55 commits intoapache:masterfrom
nic-6443:nic/opentelemetry

Conversation

@nic-6443
Copy link
Member

@nic-6443nic-6443 commentedOct 19, 2025
edited by AlinsRan
Loading

Description

Run jaeger in local byhttps://www.jaegertracing.io/docs/2.11/getting-started/#all-in-one

image
  • New Features

    • Added comprehensive distributed tracing across request lifecycle (SSL/SNI, access, header/body filter, upstream, and logging).
    • Enhanced OpenTelemetry integration with improved span propagation, context management, and per-request span lifecycle.
    • Newtracing configuration option to enable detailed observability.
  • Tests

    • Added OpenTelemetry plugin tracing test suite validating span generation and propagation.

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on theAPISIX mailing list first)

Signed-off-by: Nic <qianyong@api7.ai>
Signed-off-by: Nic <qianyong@api7.ai>
Signed-off-by: Nic <qianyong@api7.ai>
@RevolyssupRevolyssup marked this pull request as ready for reviewOctober 23, 2025 14:21
@dosubotdosubotbot added size:XLThis PR changes 500-999 lines, ignoring generated files. enhancementNew feature or request labelsOct 23, 2025
@dosubotdosubotbot added size:XXLThis PR changes 1000+ lines, ignoring generated files. and removed size:XLThis PR changes 500-999 lines, ignoring generated files. labelsOct 23, 2025
@dosubotdosubotbot added size:LThis PR changes 100-499 lines, ignoring generated files. and removed size:XXLThis PR changes 1000+ lines, ignoring generated files. labelsOct 23, 2025
@dosubotdosubotbot added size:XLThis PR changes 500-999 lines, ignoring generated files. and removed size:LThis PR changes 100-499 lines, ignoring generated files. labelsOct 24, 2025
@dosubotdosubotbot added size:XLThis PR changes 500-999 lines, ignoring generated files. and removed size:XXLThis PR changes 1000+ lines, ignoring generated files. labelsFeb 3, 2026
Copy link

CopilotAI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Pull request overview

Adds a new “comprehensive request lifecycle tracing” mode for the OpenTelemetry integration, instrumenting more APISIX internals and documenting/testing the resulting spans.

Changes:

  • Introduces a core tracing utility (apisix/tracer.lua) and span model (apisix/utils/span.lua) to capture APISIX-internal spans across phases.
  • Instruments multiple request lifecycle points (SSL/SNI matching, DNS resolve, plugin/global-rule execution, phases) and injects them into OpenTelemetry export.
  • Addsapisix.tracing config flag, updates EN/ZH docs, and adds a new tracing-focused test.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 8 comments.

Show a summary per file
FileDescription
t/plugin/opentelemetry6.tNew test covering additional spans being emitted and exported.
docs/zh/latest/plugins/opentelemetry.mdDocuments enabling comprehensive lifecycle tracing and shows updated collector output.
docs/en/latest/plugins/opentelemetry.mdSame as ZH docs, for English readers.
conf/config.yaml.exampleAddsapisix.tracing example + explanation.
apisix/cli/config.luaAdds defaultapisix.tracing = false in CLI default config.
apisix/tracer.luaNew internal tracer used to create/finish APISIX core spans.
apisix/utils/span.luaNew span container type used by the internal tracer.
apisix/init.luaStarts/finishes internal spans across HTTP + SSL phases; finishes all spans in log phase and releases tracing state.
apisix/plugin.luaWraps plugin execution + global rules with spans.
apisix/utils/upstream.luaAdds aresolve_dns span around domain resolution.
apisix/ssl/router/radixtree_sni.luaAdds asni_radixtree_match span around SNI routing.
apisix/secret.luaAdds afetch_secret span around secret retrieval.
apisix/plugins/opentelemetry.luaAdds attributes + injects internal APISIX spans into OpenTelemetry export in log phase.
apisix/core/response.luaAttempts to mark spans as error on>= 400 exits.
Comments suppressed due to low confidence (1)

apisix/secret.lua:157

  • A span is started (span = tracer.start(...)) but on thepcall(require, ...) failure path the function returns without finishing the span, which will leak an unfinished span intongx.ctx.tracing. Finish the span with an error status before returning.
    local span = tracer.start(ngx.ctx, "fetch_secret", tracer.kind.client)    local ok, sm = pcall(require, "apisix.secret." .. opts.manager)    if not ok then        return nil, "no secret manager: " .. opts.manager    end

💡Add Copilot custom instructions for smarter, more guided reviews.Learn how to get started.

Copy link

CopilotAI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

apisix/secret.lua:157

  • A span is started beforepcall(require, ...), but whenrequire fails this function returns without finishing the span. That leaves an open child span inngx.ctx.tracing and can skew parent/child tracking untilfinish_all runs. Finish the span on this error path as well (and set ERROR status/message).
    local span = tracer.start(ngx.ctx, "fetch_secret", tracer.kind.client)    local ok, sm = pcall(require, "apisix.secret." .. opts.manager)    if not ok then        return nil, "no secret manager: " .. opts.manager    end

💡Add Copilot custom instructions for smarter, more guided reviews.Learn how to get started.

Copy link
Contributor

@bzp2010bzp2010 left a comment
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I have no more problems to say.

I've already expressed my views twice; this would be the third time.

A span is an instance. Whatever it means to Lua—a metatable or anything else—I don't care.

We can always terminate a span using the following way:

localspan=tracer.start()span:finsih(api_ctx.ngx_ctxorngx.ctx,status,message)-- Even `api_ctx.ngx_ctx` can be omitted, since `ngx.ctx` is always available in any context where `api_ctx` can be accessed.

Simply attaching an identical metatable to the span table and obtaining the span instance from self is sufficient to achieve the same result internally as you are currently doing.
I don't understand why the API design persists in making function calls statelessly from the tracer. I've already repeated this three times, and I don't want to repeat it again.

  1. #12686 (comment)
  2. #12686 (comment)

Throughout the entire process, the PR never addressed my concerns regarding the API design.

I'm not sure how these design conflicts arose, as maintaining API compatibility with other popular implementations shouldn't be difficult. There is no external evidence to support this API design.

Since this API is unexpected for me, I won't approve this PR. However, I won't block the merge either—you'll need approval from other maintainers.

@nic-6443nic-6443force-pushed thenic/opentelemetry branch 2 times, most recently from73eb186 to83be609CompareFebruary 7, 2026 05:49
Signed-off-by: Nic <qianyong@api7.ai>
@nic-6443nic-6443 merged commitafda194 intoapache:masterFeb 7, 2026
25 of 26 checks passed
@nic-6443nic-6443 deleted the nic/opentelemetry branchFebruary 7, 2026 10:46
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@RevolyssupRevolyssupRevolyssup left review comments

Copilot code reviewCopilotCopilot left review comments

@membphismembphismembphis approved these changes

@bzp2010bzp2010bzp2010 approved these changes

@AlinsRanAlinsRanAlinsRan approved these changes

@moonmingmoonmingAwaiting requested review from moonming

@nic-chennic-chenAwaiting requested review from nic-chen

@shreemaan-abhishekshreemaan-abhishekAwaiting requested review from shreemaan-abhishek

Assignees

No one assigned

Labels

enhancementNew feature or requestsize:XLThis PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@nic-6443@Revolyssup@membphis@bzp2010@AlinsRan

[8]ページ先頭

©2009-2026 Movatter.jp