File tree Expand file tree Collapse file tree 6 files changed +64
-9
lines changed
Expand file tree Collapse file tree 6 files changed +64
-9
lines changed Original file line number Diff line number Diff line change 22
33All notable changes to this project will be documented in this file.
44
5+ ### v3.3.0
6+
7+ * feat(metrics): add gauges for meeting and user Redis mappings
8+ * fix(metrics): properly handle Prometheus collection failures
9+ * fix(metrics): handle promises in setCollectorWithGenerator
10+
511### v3.2.2
612
713* fix: handle missing checksum in API requests
Original file line number Diff line number Diff line change 11{
22 "name" : " bbb-webhooks" ,
3- "version" : " 3.2.2 " ,
3+ "version" : " 3.3.0 " ,
44 "description" : " A BigBlueButton mudule for events WebHooks" ,
55 "type" : " module" ,
66 "mconf_version" : " 2.2.2" ,
Original file line number Diff line number Diff line change @@ -25,6 +25,8 @@ const METRIC_NAMES = {
2525 MODULE_STATUS : `${ PREFIX } module_status` ,
2626 EVENT_PROCESS_FAILURES : `${ PREFIX } event_process_failures` ,
2727 EVENT_DISPATCH_FAILURES : `${ PREFIX } event_dispatch_failures` ,
28+ MEETING_MAPPINGS : `${ PREFIX } meeting_mappings` ,
29+ USER_MAPPINGS : `${ PREFIX } user_mappings` ,
2830}
2931
3032let METRICS = { }
@@ -79,6 +81,16 @@ const buildDefaultMetrics = () => {
7981 help : 'Number of event dispatch failures' ,
8082 labelNames : [ 'outputEventId' , 'module' ] ,
8183 } ) ,
84+
85+ [ METRIC_NAMES . MEETING_MAPPINGS ] : new Gauge ( {
86+ name : METRIC_NAMES . MEETING_MAPPINGS ,
87+ help : 'Number of meeting mappings saved in the database' ,
88+ } ) ,
89+
90+ [ METRIC_NAMES . USER_MAPPINGS ] : new Gauge ( {
91+ name : METRIC_NAMES . USER_MAPPINGS ,
92+ help : 'Number of user mappings saved in the database' ,
93+ } ) ,
8294 }
8395 }
8496
Original file line number Diff line number Diff line change @@ -49,14 +49,13 @@ class PrometheusScrapeAgent {
4949 async _collect ( response ) {
5050 try {
5151 const _response = await this . collect ( response ) ;
52- _response . writeHead ( 200 , { 'Content-Type' : promclient . register . contentType } ) ;
5352 const content = await promclient . register . metrics ( ) ;
53+ _response . writeHead ( 200 , { 'Content-Type' : promclient . register . contentType } ) ;
5454 _response . end ( content ) ;
5555 } catch ( error ) {
56+ this . logger . error ( 'Prometheus: error collecting metrics' , error ) ;
5657 response . writeHead ( 500 )
57- response . end ( error . message ) ;
58- this . logger . error ( 'Prometheus: error collecting metrics' ,
59- { errorCode : error . code , errorMessage : error . message } ) ;
58+ response . end ( "Error collecting metrics" ) ;
6059 }
6160 }
6261
@@ -172,8 +171,9 @@ class PrometheusScrapeAgent {
172171 /**
173172 * metric.collect.
174173 */
175- metric . collect = ( ) => {
176- metric . set ( generator ( ) ) ;
174+ metric . collect = async ( ) => {
175+ const value = await generator ( ) ;
176+ metric . set ( value ) ;
177177 } ;
178178 }
179179 }
Original file line number Diff line number Diff line change @@ -21,6 +21,42 @@ export default class EventProcessor {
2121 this . outputs = outputs ;
2222
2323 this . _exporter = Metrics . agent ;
24+ this . _setMetricsCollectors ( ) ;
25+ }
26+
27+ /**
28+ * _setMetricsCollectors - Sets the metrics collectors for the event processor.
29+ * @private
30+ */
31+ _setMetricsCollectors ( ) {
32+ const collectIDMappings = async ( ) => {
33+ try {
34+ const mappings = await IDMapping . get ( ) . getAll ( ) ;
35+ return mappings ?. length || 0 ;
36+ } catch ( error ) {
37+ Logger . error ( 'error getting ID mappings' , error ) ;
38+ return 0 ;
39+ }
40+ }
41+
42+ const collectUserMappings = async ( ) => {
43+ try {
44+ const mappings = await UserMapping . get ( ) . getAll ( ) ;
45+ return mappings ?. length || 0 ;
46+ } catch ( error ) {
47+ Logger . error ( 'error getting user mappings' , error ) ;
48+ return 0 ;
49+ }
50+ }
51+
52+ this . _exporter . setCollectorWithGenerator (
53+ Metrics . METRIC_NAMES . MEETING_MAPPINGS ,
54+ collectIDMappings ,
55+ ) ;
56+ this . _exporter . setCollectorWithGenerator (
57+ Metrics . METRIC_NAMES . USER_MAPPINGS ,
58+ collectUserMappings ,
59+ ) ;
2460 }
2561
2662 _trackModuleEvents ( ) {
You can’t perform that action at this time.
0 commit comments