Skip to content

bug: using consumer_name additional_attributes not work in opentelemetry plugins #12873

Description

@guanjie-pony

Current Behavior

from the document: https://apisix.apache.org/docs/apisix/plugins/opentelemetry/ plugin support the built-in variables like consumer_name: https://apisix.apache.org/docs/apisix/apisix-variable/, but seems it not works, my config is here:

apiVersion: apisix.apache.org/v2
kind: ApisixGlobalRule
metadata:
  name: tracing-prod
  namespace: ingress-apisix
spec:
  ingressClassName: apisix-internal
  plugins:
  - config:
      additional_attributes:
      - balancer_ip
      - consumer_name
      sampler:
        name: always_on
    enable: true
    name: opentelemetry

test request:

curl http://test-redirect.xxxxxxx/info  -H "Authorization: ${jwt_token}"

we can see trace in jaeger, but no consumer_name

Image

but using file-log in log, I can see the consumer_name:

{
   "hostname":"apisix-549f49b45b-w7qbr",
   "latency":0.003,
   "upstream_response_time":0.002,
   "response_size":760,
   "url":"/info",
   "upstream_status":"200",
   "uri":"/info",
   "opentelemetry_context_traceparent":"00-b44ea22321e1af9d2e092060e0366466-a77d28d2e9411a08-01",
   "ingress_class":"apisix-internal",
   "opentelemetry_trace_id":"b44ea22321e1af9d2e092060e0366466",
   "method":"GET",
   "consumer_name":"ingress-apisix_user-pony",
   "service_id":"bdfaae16",
   "service_name":"ingress-apisix_test-redirect_0",
   "route_id":"3cbfb533",
   "user_agent":"curl/7.81.0",
   "region":"common-ack-test",
   "size":256,
   "@timestamp":"2026-01-08T03:02:36+00:00",
   "status":200,
   "opentelemetry_span_id":"a77d28d2e9411a08"
}

Expected Behavior

the consumer_name should be in jaeger tracing.

Error Logs

No response

Steps to Reproduce

  1. using apisix ingress controller 2.0.0
  2. create a apisixconsumer in jwt
  3. create a apisixroute with jwt auth
  4. enable opentelemetry config
  5. set apisixglobalrules for opentelemetry
apiVersion: apisix.apache.org/v2
kind: ApisixGlobalRule
metadata:
  name: tracing-prod
  namespace: ingress-apisix
spec:
  ingressClassName: apisix-internal
  plugins:
  - config:
      additional_attributes:
      - balancer_ip
      - consumer_name
      sampler:
        name: always_on
    enable: true
    name: opentelemetry
  1. curl the test url

Environment

  • APISIX version (run apisix version): 3.14.1
  • Operating system (run uname -a): Linux apisix-549f49b45b-w7qbr 5.10.134-16.3.al8.x86_64 SMP Tue Mar 26 18:54:05 CST 2024 x86_64 x86_64 x86_64 GNU/Linux
  • OpenResty / Nginx version (run openresty -V or nginx -V): nginx version: openresty/1.27.1.2

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