@@ -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_element_out.stanza_count " )),
110
+ " /metrics/host_type/badHostType/c2s_message_processed.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
- [{'c2s_element_in .iq_count' , 0 + user_alpha (2 )},
126
- {'c2s_element_out .iq_count' , 0 + user_alpha (2 )},
127
- {'c2s_element_in .message_count' , 0 },
128
- {'c2s_element_out .message_count' , 0 },
129
- {'c2s_element_in .presence_count' , 0 + user_alpha (1 )},
130
- {'c2s_element_out .presence_count' , 0 + user_alpha (1 )},
131
- {'c2s_element_in .stanza_count' , 0 + user_alpha (3 )},
132
- {'c2s_element_out .stanza_count' , 0 + user_alpha (3 )},
133
- {'sm_session.logins' , 0 + user_alpha (1 )},
134
- {'sm_session.logouts' , 0 + user_alpha (1 )}
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 )}
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
- [{'c2s_element_in .iq_count' , 0 + user_alpha (4 )},
142
- {'c2s_element_out .iq_count' , 0 + user_alpha (4 )},
143
- {'c2s_element_in .message_count' , 0 },
144
- {'c2s_element_out .message_count' , 0 },
145
- {'c2s_element_in .presence_count' , 0 + user_alpha (2 )},
146
- {'c2s_element_out .presence_count' , 0 + user_alpha (2 )},
147
- {'c2s_element_in .stanza_count' , 0 + user_alpha (6 )},
148
- {'c2s_element_out .stanza_count' , 0 + user_alpha (6 )},
149
- {'sm_session.logins' , 0 + user_alpha (2 )},
150
- {'sm_session.logouts' , 0 + user_alpha (2 )}
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 )}
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
- [{'c2s_element_in .message_count' , 1 },
162
- {'c2s_element_out .message_count' , 1 }]).
161
+ [{global , 'xmpp_element_in.c2s .message_count' , 1 },
162
+ {global , '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
- [{'c2s_element_in .presence_count' , 1 + user_alpha (2 )},
174
- {'c2s_element_out .presence_count' , 1 + user_alpha (2 )},
175
- {'c2s_element_in .stanza_count' , 1 + user_alpha (6 )},
176
- {'c2s_element_out .stanza_count' , 1 + user_alpha (6 )}]).
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 )}]).
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
- [{'c2s_element_in .iq_count' , 3 },
187
- {'c2s_element_out .iq_count' , 3 },
188
- {'mod_roster_get.count' , 1 },
189
- {'c2s_element_in .stanza_count' , 1 + user_alpha (3 )},
190
- {'c2s_element_out .stanza_count' , 1 + user_alpha (3 )}]).
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 )}]).
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
- [{'c2s_element_out .error_count' , 1 },
202
- {'c2s_element_out .iq_error_count' , 0 },
203
- {'c2s_element_out .message_error_count' , 1 },
204
- {'c2s_element_out .presence_error_count' , 0 }]).
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 }]).
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
- [{'c2s_element_out .error_count' , 1 },
215
- {'c2s_element_out .iq_error_count' , 1 },
216
- {'c2s_element_out .message_error_count' , 0 },
217
- {'c2s_element_out .presence_error_count' , 0 }]).
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 }]).
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
- [{'c2s_element_out .error_count' , 1 },
229
- {'c2s_element_out .iq_error_count' , 0 },
230
- {'c2s_element_out .message_error_count' , 0 },
231
- {'c2s_element_out .presence_error_count' , 1 }]).
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 }]).
232
232
233
233
session_counters (Config ) ->
234
234
escalus :story
@@ -350,31 +350,32 @@ user_alpha(NumberOfUsers) ->
350
350
% % will be bumped by +1 at login.
351
351
NumberOfUsers .
352
352
353
- instrumented_story (Config , UsersSpecs , StoryFun , CounterSpecs ) ->
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 ,
354
358
Befores = fetch_all (Config , CounterSpecs ),
355
359
StoryResult = escalus :story (Config , UsersSpecs , StoryFun ),
356
360
Afters = fetch_all (Config , CounterSpecs ),
357
361
[ assert_counter_inc (Name , N , find (Name , Befores ), find (Name , Afters ))
358
- || {Name , N } <- CounterSpecs ],
362
+ || {_ , Name , N } <- CounterSpecs ],
359
363
StoryResult .
360
364
361
365
fetch_all (Config , 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 ].
366
+ [ {Counter , fetch_counter_value (Scope , Counter , Config )}
367
+ || {Scope , 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 (Counter , _Config ) ->
374
+ fetch_counter_value (global , Counter , Config ) ->
375
+ fetch_global_spiral_values (Counter , Config );
376
+ fetch_counter_value (HostType , Counter , Config ) ->
375
377
Metric = atom_to_binary (Counter , utf8 ),
376
378
377
- HostType = host_type (),
378
379
HostTypeName = metrics_helper :make_host_type_name (HostType ),
379
380
380
381
Result = request (<<" GET" >>, [" /metrics/host_type/" , HostTypeName , " /" , Metric ]),
0 commit comments