You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by "nickva (via GitHub)" <gi...@apache.org> on 2023/03/13 19:00:27 UTC

[GitHub] [couchdb] nickva commented on a diff in pull request #4474: fix: prometheus counter metric naming

nickva commented on code in PR #4474:
URL: https://github.com/apache/couchdb/pull/4474#discussion_r1134492950


##########
src/couch_prometheus/src/couch_prometheus_util.erl:
##########
@@ -167,3 +167,75 @@ val(Data) ->
 val(Key, Stats) ->
     {Key, Data} = lists:keyfind(Key, 1, Stats),
     val(Data).
+
+-ifdef(TEST).
+-include_lib("couch/include/couch_eunit.hrl").
+
+to_prom_test_() ->
+    [
+        ?_assertEqual(
+            <<"couchdb_ddoc_cache 10">>,
+            test_to_prom_output(ddoc_cache, counter, 10)
+        ),
+        ?_assertEqual(
+            <<"couchdb_httpd_status_codes{code=\"200\"} 3">>,
+            test_to_prom_output(httpd_status_codes, counter, {[{code, 200}], 3})
+        ),
+        ?_assertEqual(
+            <<"couchdb_temperature_celsius 36">>,
+            test_to_prom_output(temperature_celsius, gauge, 36)
+        ),
+        ?_assertEqual(
+            <<"couchdb_mango_query_time_seconds{quantile=\"0.75\"} 4.5">>,
+            test_to_prom_sum_output([mango_query_time], [
+                {value, [
+                    {min, 0.0},
+                    {max, 0.0},
+                    {arithmetic_mean, 0.0},
+                    {geometric_mean, 0.0},
+                    {harmonic_mean, 0.0},
+                    {median, 0.0},
+                    {variance, 0.0},
+                    {standard_deviation, 0.0},
+                    {skewness, 0.0},
+                    {kurtosis, 0.0},
+                    {percentile, [
+                        {50, 0.0},
+                        {75, 4500},
+                        {90, 0.0},
+                        {95, 0.0},
+                        {99, 0.0},
+                        {999, 0.0}
+                    ]},
+                    {histogram, [
+                        {0, 0}
+                    ]},
+                    {n, 0}
+                ]},
+                {type, histogram},
+                {desc, <<"length of time processing a mango query">>}
+            ])
+        )
+    ].
+
+counter_metric_test_() ->
+    [
+        ?_assertEqual(
+            "document_purges_total",
+            counter_metric([document_purges, total])
+        ),
+        ?_assertEqual(
+            "document_purges_total",
+            counter_metric([document_purges, total])
+        )

Review Comment:
   These look identical, it seems?



-- 
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@couchdb.apache.org

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