You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "monkeyDluffy6017 (via GitHub)" <gi...@apache.org> on 2023/06/16 06:43:10 UTC

[GitHub] [apisix] monkeyDluffy6017 commented on a diff in pull request #9673: feat(prometheus): allow user configure DEFAULT_BUCKETS

monkeyDluffy6017 commented on code in PR #9673:
URL: https://github.com/apache/apisix/pull/9673#discussion_r1231841077


##########
t/plugin/prometheus4.t:
##########
@@ -134,3 +134,62 @@ GET /hello
 GET /apisix/prometheus/metrics
 --- response_body eval
 qr/apisix_http_status\{code="200",route="10",matched_uri="\/hello",matched_host="",service="",consumer="",node="127.0.0.1",dummy=""\} \d+/
+
+
+
+=== TEST 7: set route
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+            local code, body = t('/apisix/admin/routes/1',
+                ngx.HTTP_PUT,
+                [[{
+                    "plugins": {
+                        "prometheus": {}
+                    },
+                    "upstream": {
+                        "nodes": {
+                            "127.0.0.1:1980": 1
+                        },
+                        "type": "roundrobin"
+                    },
+                    "uri": "/hello1"
+                }]]
+                )
+
+            if code >= 300 then
+                ngx.status = code
+            end
+            ngx.say(body)
+        }
+    }
+--- response_body
+passed
+
+
+
+=== TEST 8: set default_buckets
+--- yaml_config
+plugin_attr:
+    prometheus:
+        default_buckets:
+            - 15
+            - 55
+            - 105
+            - 205
+            - 505
+--- request
+GET /hello1

Review Comment:
   I ususally wirte like this, what do you think?
   ```suggestion
   === TEST 7: set route
   --- yaml_config
   plugin_attr:
       prometheus:
           default_buckets:
               - 15
               - 55
               - 105
               - 205
               - 505
   --- config
       location /t {
           content_by_lua_block {
               local t = require("lib.test_admin").test
               local code, body = t('/apisix/admin/routes/1',
                   ngx.HTTP_PUT,
                   [[{
                       "plugins": {
                           "prometheus": {}
                       },
                       "upstream": {
                           "nodes": {
                               "127.0.0.1:1980": 1
                           },
                           "type": "roundrobin"
                       },
                       "uri": "/hello1"
                   }]]
                   )
   
               if code >= 300 then
                   ngx.status = code
               end
               ngx.say(body)
           }
       }
   --- request
   GET /hello1
   --- response_body
   passed
   ```



-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org