Skip to content

bug: openelemetry set_ngx_var option causes errors #12402

Description

@nvx

Current Behavior

When enabling set_ngx_var in the opentelemetry plugin apisix errors out during startup.

This worked prior to PR #11940. Looking at https://github.com/apache/apisix/blob/3.13.0/apisix/cli/ops.lua#L554 it appears that the part of the code to setup the required nginx variable wasn't migrated to use plugin metadata and is still using plugin attributes.

Expected Behavior

No response

Error Logs

"2025/07/07 01:32:59 [error] 38#38: *291 lua entry thread aborted: runtime error: /usr/local/apisix/apisix/plugins/opentelemetry.lua:374: variable "opentelemetry_context_traceparent" not found for writing; maybe it is a built-in variable that is not changeable or you forgot to use "set $opentelemetry_context_traceparent '';" in the config file to define it first"

Steps to Reproduce

Enable the opentelemetry plugin and set the following plugin metadata

"plugin_metadata":
  - "collector":
      "address": "127.0.0.1:4318"
      "request_timeout": 3
    "id": "opentelemetry"
    "set_ngx_var": true

Environment

  • APISIX version (run apisix version): apache/apisix:3.13.0-debian
  • Operating system (run uname -a): Linux/Docker
  • OpenResty / Nginx version (run openresty -V or nginx -V): as per docker image
  • LuaRocks version, for installation issues (run luarocks --version): as per docker image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingplugin

    Type

    No type

    Projects

    Status
    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions