janiussyafiq commented on code in PR #13265:
URL: https://github.com/apache/apisix/pull/13265#discussion_r3165030141


##########
t/plugin/opentelemetry.t:
##########
@@ -488,3 +488,154 @@ opentracing
 tail -n 1 ci/pod/otelcol-contrib/data-otlp.json
 --- response_body eval
 qr/.*opentelemetry-lua.*/
+
+
+
+=== TEST 23: setup consumer_name in additional_attributes
+--- extra_yaml_config
+plugins:
+    - opentelemetry
+    - key-auth
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+            local code, body = t('/apisix/admin/consumers',
+                ngx.HTTP_PUT,
+                [[{
+                    "username": "john",
+                    "plugins": {
+                        "key-auth": {
+                            "key": "john-key"
+                        }
+                    }
+                }]]
+            )
+            if code >= 300 then
+                ngx.status = code
+                ngx.say(body)
+                return
+            end
+
+            local code, body = t('/apisix/admin/routes/1',
+                ngx.HTTP_PUT,
+                [[{
+                    "plugins": {
+                        "key-auth": {},
+                        "opentelemetry": {
+                            "sampler": {
+                                "name": "always_on"
+                            },
+                            "additional_attributes": [
+                                "consumer_name"
+                            ]
+                        }
+                    },
+                    "upstream": {
+                        "nodes": {
+                            "127.0.0.1:1980": 1
+                        },
+                        "type": "roundrobin"
+                    },
+                    "uri": "/opentracing"
+                }]]
+            )
+            if code >= 300 then
+                ngx.status = code
+            end
+            ngx.say(body)
+        }
+    }
+--- request
+GET /t
+
+
+
+=== TEST 24: trigger opentelemetry with consumer
+--- extra_yaml_config
+plugins:
+    - opentelemetry
+    - key-auth
+--- request
+GET /opentracing
+--- more_headers
+X-Request-Id: 01010101010101010101010101010102
+apikey: john-key
+--- wait: 2
+--- response_body
+opentracing
+
+
+
+=== TEST 25: check consumer_name in span attributes
+--- exec
+tail -n 1 ci/pod/otelcol-contrib/data-otlp.json

Review Comment:
   followed test convention from previous test cases



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to