@@ -116,7 +116,7 @@ couch_to_prom(Path, Info, _All) ->
116116type_def (Metric , Type , Desc ) ->
117117 Name = to_prom_name (Metric ),
118118 [
119- to_bin (io_lib :format (" \n # HELP ~s ~s \r " , [Name , Desc ])),
119+ to_bin (io_lib :format (" \n # HELP ~s ~s " , [Name , Desc ])),
120120 to_bin (io_lib :format (" # TYPE ~s ~s " , [Name , Type ]))
121121 ].
122122
@@ -126,7 +126,7 @@ to_prom(_Metric, _Type, _Desc, []) ->
126126 [];
127127to_prom (Metric , Type , Desc , Instances ) when is_list (Instances ) ->
128128 TypeStr = type_def (Metric , Type , Desc ),
129- [ TypeStr ] ++ lists :flatmap (fun (Inst ) -> to_prom (Metric , Inst ) end , Instances );
129+ TypeStr ++ lists :flatmap (fun (Inst ) -> to_prom (Metric , Inst ) end , Instances );
130130to_prom (Metric , Type , Desc , Data ) ->
131131 to_prom (Metric , Type , Desc , [Data ]).
132132
@@ -221,6 +221,23 @@ desc(Info) ->
221221-ifdef (TEST ).
222222-include_lib (" couch/include/couch_eunit.hrl" ).
223223
224+ to_prom_annotations_test () ->
225+ Out = to_prom (couchdb_bt_engine_cache_size , gauge , " number of entries in the btree cache" , 9 ),
226+ [
227+ ? assertEqual (
228+ <<" \n # HELP couchdb_couchdb_bt_engine_cache_size number of entries in the btree cache" >>,
229+ lists :nth (1 , Out )
230+ ),
231+ ? assertEqual (
232+ <<" # TYPE couchdb_couchdb_bt_engine_cache_size gauge" >>,
233+ lists :nth (2 , Out )
234+ ),
235+ ? assertEqual (
236+ <<" couchdb_couchdb_bt_engine_cache_size 9" >>,
237+ lists :nth (3 , Out )
238+ )
239+ ].
240+
224241to_prom_counter_test () ->
225242 [
226243 ? assertEqual (
@@ -288,10 +305,10 @@ counter_metric_test_() ->
288305
289306test_to_prom_output (Metric , Type , Desc , Val ) ->
290307 Out = to_prom (Metric , Type , Desc , Val ),
291- lists :nth (2 , Out ).
308+ lists :nth (3 , Out ).
292309
293310test_to_prom_summary_output (Metric , Info ) ->
294311 Out = to_prom_summary (Metric , Info ),
295- lists :nth (3 , Out ).
312+ lists :nth (4 , Out ).
296313
297314-endif .
0 commit comments