@@ -107,7 +107,7 @@ non_existent_metrics(_Config) ->
107
107
assert_status (404 , request (<<" GET" >>, " /metrics/global/badMetric" )),
108
108
assert_status (404 , request (<<" GET" >>, " /metrics/host_type/badHostType" )),
109
109
assert_status (404 , request (<<" GET" >>,
110
- " /metrics/host_type/badHostType/c2s_message_processed.count " )),
110
+ " /metrics/host_type/badHostType/xmpp_element_out.c2s.stanza_count " )),
111
111
assert_status (404 , request (<<" GET" >>, [" /metrics/" , HostType , " /" , GlobalMetricName ])),
112
112
assert_status (404 , request (<<" GET" >>, [" /metrics/" , HostType , " /badMetric" ])).
113
113
@@ -122,32 +122,32 @@ one_client_just_logs_in(Config) ->
122
122
(Config , metrics_helper :userspec (1 , Config ),
123
123
fun (_User1 ) -> end_of_story end ,
124
124
% % A list of metrics and their expected relative increase
125
- [{global , 'xmpp_element_in.c2s.iq_count' , 0 + user_alpha (2 )},
126
- {global , 'xmpp_element_out.c2s.iq_count' , 0 + user_alpha (2 )},
127
- {global , 'xmpp_element_in.c2s.message_count' , 0 },
128
- {global , 'xmpp_element_out.c2s.message_count' , 0 },
129
- {global , 'xmpp_element_in.c2s.presence_count' , 0 + user_alpha (1 )},
130
- {global , 'xmpp_element_out.c2s.presence_count' , 0 + user_alpha (1 )},
131
- {global , 'xmpp_element_in.c2s.stanza_count' , 0 + user_alpha (3 )},
132
- {global , 'xmpp_element_out.c2s.stanza_count' , 0 + user_alpha (3 )},
133
- {host_type (), 'sm_session.logins' , 0 + user_alpha (1 )},
134
- {host_type (), 'sm_session.logouts' , 0 + user_alpha (1 )}
125
+ [{'xmpp_element_in.c2s.iq_count' , 0 + user_alpha (2 )},
126
+ {'xmpp_element_out.c2s.iq_count' , 0 + user_alpha (2 )},
127
+ {'xmpp_element_in.c2s.message_count' , 0 },
128
+ {'xmpp_element_out.c2s.message_count' , 0 },
129
+ {'xmpp_element_in.c2s.presence_count' , 0 + user_alpha (1 )},
130
+ {'xmpp_element_out.c2s.presence_count' , 0 + user_alpha (1 )},
131
+ {'xmpp_element_in.c2s.stanza_count' , 0 + user_alpha (3 )},
132
+ {'xmpp_element_out.c2s.stanza_count' , 0 + user_alpha (3 )},
133
+ {'sm_session.logins' , 0 + user_alpha (1 )},
134
+ {'sm_session.logouts' , 0 + user_alpha (1 )}
135
135
]).
136
136
137
137
two_clients_just_log_in (Config ) ->
138
138
instrumented_story
139
139
(Config , metrics_helper :userspec (1 , 1 , Config ),
140
140
fun (_User1 , _User2 ) -> end_of_story end ,
141
- [{global , 'xmpp_element_in.c2s.iq_count' , 0 + user_alpha (4 )},
142
- {global , 'xmpp_element_out.c2s.iq_count' , 0 + user_alpha (4 )},
143
- {global , 'xmpp_element_in.c2s.message_count' , 0 },
144
- {global , 'xmpp_element_out.c2s.message_count' , 0 },
145
- {global , 'xmpp_element_in.c2s.presence_count' , 0 + user_alpha (2 )},
146
- {global , 'xmpp_element_out.c2s.presence_count' , 0 + user_alpha (2 )},
147
- {global , 'xmpp_element_in.c2s.stanza_count' , 0 + user_alpha (6 )},
148
- {global , 'xmpp_element_out.c2s.stanza_count' , 0 + user_alpha (6 )},
149
- {host_type (), 'sm_session.logins' , 0 + user_alpha (2 )},
150
- {host_type (), 'sm_session.logouts' , 0 + user_alpha (2 )}
141
+ [{'xmpp_element_in.c2s.iq_count' , 0 + user_alpha (4 )},
142
+ {'xmpp_element_out.c2s.iq_count' , 0 + user_alpha (4 )},
143
+ {'xmpp_element_in.c2s.message_count' , 0 },
144
+ {'xmpp_element_out.c2s.message_count' , 0 },
145
+ {'xmpp_element_in.c2s.presence_count' , 0 + user_alpha (2 )},
146
+ {'xmpp_element_out.c2s.presence_count' , 0 + user_alpha (2 )},
147
+ {'xmpp_element_in.c2s.stanza_count' , 0 + user_alpha (6 )},
148
+ {'xmpp_element_out.c2s.stanza_count' , 0 + user_alpha (6 )},
149
+ {'sm_session.logins' , 0 + user_alpha (2 )},
150
+ {'sm_session.logouts' , 0 + user_alpha (2 )}
151
151
]).
152
152
153
153
one_message_sent (Config ) ->
@@ -158,8 +158,8 @@ one_message_sent(Config) ->
158
158
escalus_client :send (User1 , Chat ),
159
159
escalus_client :wait_for_stanza (User2 )
160
160
end ,
161
- [{global , 'xmpp_element_in.c2s.message_count' , 1 },
162
- {global , 'xmpp_element_out.c2s.message_count' , 1 }]).
161
+ [{'xmpp_element_in.c2s.message_count' , 1 },
162
+ {'xmpp_element_out.c2s.message_count' , 1 }]).
163
163
164
164
one_direct_presence_sent (Config ) ->
165
165
Userspec = metrics_helper :userspec (1 , 1 , Config ),
@@ -170,10 +170,10 @@ one_direct_presence_sent(Config) ->
170
170
escalus :send (User1 , Presence ),
171
171
escalus :wait_for_stanza (User2 )
172
172
end ,
173
- [{global , 'xmpp_element_in.c2s.presence_count' , 1 + user_alpha (2 )},
174
- {global , 'xmpp_element_out.c2s.presence_count' , 1 + user_alpha (2 )},
175
- {global , 'xmpp_element_in.c2s.stanza_count' , 1 + user_alpha (6 )},
176
- {global , 'xmpp_element_out.c2s.stanza_count' , 1 + user_alpha (6 )}]).
173
+ [{'xmpp_element_in.c2s.presence_count' , 1 + user_alpha (2 )},
174
+ {'xmpp_element_out.c2s.presence_count' , 1 + user_alpha (2 )},
175
+ {'xmpp_element_in.c2s.stanza_count' , 1 + user_alpha (6 )},
176
+ {'xmpp_element_out.c2s.stanza_count' , 1 + user_alpha (6 )}]).
177
177
178
178
one_iq_sent (Config ) ->
179
179
instrumented_story
@@ -183,11 +183,11 @@ one_iq_sent(Config) ->
183
183
escalus_client :send (User1 , RosterIq ),
184
184
escalus_client :wait_for_stanza (User1 )
185
185
end ,
186
- [{global , 'xmpp_element_in.c2s.iq_count' , 3 },
187
- {global , 'xmpp_element_out.c2s.iq_count' , 3 },
188
- {host_type (), 'mod_roster_get.count' , 1 },
189
- {global , 'xmpp_element_in.c2s.stanza_count' , 1 + user_alpha (3 )},
190
- {global , 'xmpp_element_out.c2s.stanza_count' , 1 + user_alpha (3 )}]).
186
+ [{'xmpp_element_in.c2s.iq_count' , 3 },
187
+ {'xmpp_element_out.c2s.iq_count' , 3 },
188
+ {'mod_roster_get.count' , 1 },
189
+ {'xmpp_element_in.c2s.stanza_count' , 1 + user_alpha (3 )},
190
+ {'xmpp_element_out.c2s.stanza_count' , 1 + user_alpha (3 )}]).
191
191
192
192
one_message_error (Config ) ->
193
193
instrumented_story
@@ -198,10 +198,10 @@ one_message_error(Config) ->
198
198
escalus_client :send (User1 , Chat ),
199
199
escalus_client :wait_for_stanza (User1 )
200
200
end ,
201
- [{global , 'xmpp_element_out.c2s.error_count' , 1 },
202
- {global , 'xmpp_element_out.c2s.iq_error_count' , 0 },
203
- {global , 'xmpp_element_out.c2s.message_error_count' , 1 },
204
- {global , 'xmpp_element_out.c2s.presence_error_count' , 0 }]).
201
+ [{'xmpp_element_out.c2s.error_count' , 1 },
202
+ {'xmpp_element_out.c2s.iq_error_count' , 0 },
203
+ {'xmpp_element_out.c2s.message_error_count' , 1 },
204
+ {'xmpp_element_out.c2s.presence_error_count' , 0 }]).
205
205
206
206
one_iq_error (Config ) ->
207
207
instrumented_story
@@ -211,10 +211,10 @@ one_iq_error(Config) ->
211
211
escalus_client :send (User1 , BadIQ ),
212
212
escalus_client :wait_for_stanza (User1 )
213
213
end ,
214
- [{global , 'xmpp_element_out.c2s.error_count' , 1 },
215
- {global , 'xmpp_element_out.c2s.iq_error_count' , 1 },
216
- {global , 'xmpp_element_out.c2s.message_error_count' , 0 },
217
- {global , 'xmpp_element_out.c2s.presence_error_count' , 0 }]).
214
+ [{'xmpp_element_out.c2s.error_count' , 1 },
215
+ {'xmpp_element_out.c2s.iq_error_count' , 1 },
216
+ {'xmpp_element_out.c2s.message_error_count' , 0 },
217
+ {'xmpp_element_out.c2s.presence_error_count' , 0 }]).
218
218
219
219
one_presence_error (Config ) ->
220
220
instrumented_story
@@ -225,10 +225,10 @@ one_presence_error(Config) ->
225
225
escalus_client :send (User1 , BadPres ),
226
226
escalus_client :wait_for_stanza (User1 )
227
227
end ,
228
- [{global , 'xmpp_element_out.c2s.error_count' , 1 },
229
- {global , 'xmpp_element_out.c2s.iq_error_count' , 0 },
230
- {global , 'xmpp_element_out.c2s.message_error_count' , 0 },
231
- {global , 'xmpp_element_out.c2s.presence_error_count' , 1 }]).
228
+ [{'xmpp_element_out.c2s.error_count' , 1 },
229
+ {'xmpp_element_out.c2s.iq_error_count' , 0 },
230
+ {'xmpp_element_out.c2s.message_error_count' , 0 },
231
+ {'xmpp_element_out.c2s.presence_error_count' , 1 }]).
232
232
233
233
session_counters (Config ) ->
234
234
escalus :story
@@ -344,38 +344,37 @@ metrics_msg_flow(_Config) ->
344
344
user_alpha (NumberOfUsers ) ->
345
345
% % This represents the overhead of logging in N users via escalus:story/3
346
346
% % For each user,
347
- % % c2s_element_ (in|out).stanza_count
347
+ % % xmpp_element_ (in|out).c2s .stanza_count
348
348
% % and
349
- % % c2s_element_ (in|out).presence_count
349
+ % % xmpp_element_ (in|out).c2s .presence_count
350
350
% % will be bumped by +1 at login.
351
351
NumberOfUsers .
352
352
353
- instrumented_story (Config , UsersSpecs , StoryFun , CounterSpecs0 ) ->
354
- CounterSpecs = case metrics_helper :all_metrics_are_global (Config ) of
355
- true -> [{global , Counter , N } || {_ , Counter , N } <- CounterSpecs0 ];
356
- false -> CounterSpecs0
357
- end ,
353
+ instrumented_story (Config , UsersSpecs , StoryFun , CounterSpecs ) ->
358
354
Befores = fetch_all (Config , CounterSpecs ),
359
355
StoryResult = escalus :story (Config , UsersSpecs , StoryFun ),
360
356
Afters = fetch_all (Config , CounterSpecs ),
361
357
[ assert_counter_inc (Name , N , find (Name , Befores ), find (Name , Afters ))
362
- || {_ , Name , N } <- CounterSpecs ],
358
+ || {Name , N } <- CounterSpecs ],
363
359
StoryResult .
364
360
365
361
fetch_all (Config , CounterSpecs ) ->
366
- [ {Counter , fetch_counter_value (Scope , Counter , Config )}
367
- || {Scope , Counter , _ } <- CounterSpecs ].
362
+ FetchCounterFun = case metrics_helper :all_metrics_are_global (Config ) of
363
+ true -> fun fetch_global_spiral_values /2 ;
364
+ _ -> fun fetch_counter_value /2
365
+ end ,
366
+ [ {Counter , FetchCounterFun (Counter , Config )}
367
+ || {Counter , _ } <- CounterSpecs ].
368
368
369
369
find (CounterName , CounterList ) ->
370
370
case lists :keyfind (CounterName , 1 , CounterList ) of
371
371
false -> error (counter_defined_incorrectly );
372
372
{CounterName , Val } -> Val end .
373
373
374
- fetch_counter_value (global , Counter , Config ) ->
375
- fetch_global_spiral_values (Counter , Config );
376
- fetch_counter_value (HostType , Counter , Config ) ->
374
+ fetch_counter_value (Counter , _Config ) ->
377
375
Metric = atom_to_binary (Counter , utf8 ),
378
376
377
+ HostType = host_type (),
379
378
HostTypeName = metrics_helper :make_host_type_name (HostType ),
380
379
381
380
Result = request (<<" GET" >>, [" /metrics/host_type/" , HostTypeName , " /" , Metric ]),
0 commit comments