ソースを参照

Merge pull request #449 from jitsi/logs_to_callstats

Fix errors with sending final logs batch to CallStats
dev1
Saúl Ibarra Corretgé 8年前
コミット
61dfbbcf2e
2個のファイルの変更24行の追加4行の削除
  1. 4
    3
      modules/statistics/CallStats.js
  2. 20
    1
      modules/statistics/statistics.js

+ 4
- 3
modules/statistics/CallStats.js ファイルの表示

182
             logger.warn('No error is passed!');
182
             logger.warn('No error is passed!');
183
             _error = new Error('Unknown error');
183
             _error = new Error('Unknown error');
184
         }
184
         }
185
-        if (CallStats.initialized) {
186
-            CallStats.backend.reportError(pc, cs && cs.confID, type, _error);
185
+        if (CallStats.initialized && cs) {
186
+            CallStats.backend.reportError(pc, cs.confID, type, _error);
187
         } else {
187
         } else {
188
             CallStats.reportsQueue.push({
188
             CallStats.reportsQueue.push({
189
                 type: reportType.ERROR,
189
                 type: reportType.ERROR,
212
         const pc = cs && cs.peerconnection;
212
         const pc = cs && cs.peerconnection;
213
         const confID = cs && cs.confID;
213
         const confID = cs && cs.confID;
214
 
214
 
215
-        if (CallStats.initialized) {
215
+        if (CallStats.initialized && cs) {
216
             CallStats.backend.sendFabricEvent(pc, event, confID, eventData);
216
             CallStats.backend.sendFabricEvent(pc, event, confID, eventData);
217
         } else {
217
         } else {
218
             CallStats.reportsQueue.push({
218
             CallStats.reportsQueue.push({
578
                 CallStats.backend.fabricEvent.fabricTerminated,
578
                 CallStats.backend.fabricEvent.fabricTerminated,
579
                 this.confID);
579
                 this.confID);
580
         }
580
         }
581
+        CallStats.fabrics.delete(this);
581
     }
582
     }
582
 
583
 
583
     /**
584
     /**

+ 20
- 1
modules/statistics/statistics.js ファイルの表示

204
 
204
 
205
 Statistics.prototype.dispose = function() {
205
 Statistics.prototype.dispose = function() {
206
     try {
206
     try {
207
-        if (this.eventEmitter) {
207
+        // NOTE Before reading this please see the comment in stopCallStats...
208
+        //
209
+        // Here we prevent from emitting the event twice in case it will be
210
+        // triggered from stopCallStats.
211
+        // If the event is triggered from here it means that the logs will not
212
+        // be submitted anyway (because there is no CallStats instance), but
213
+        // we're doing that for the sake of some kind of consistency.
214
+        if (!this.callsStatsInstances.size) {
208
             this.eventEmitter.emit(StatisticsEvents.BEFORE_DISPOSED);
215
             this.eventEmitter.emit(StatisticsEvents.BEFORE_DISPOSED);
209
         }
216
         }
210
         for (const callStats of this.callsStatsInstances.values()) {
217
         for (const callStats of this.callsStatsInstances.values()) {
326
     const callStatsInstance = this.callsStatsInstances.get(tpc.id);
333
     const callStatsInstance = this.callsStatsInstances.get(tpc.id);
327
 
334
 
328
     if (callStatsInstance) {
335
     if (callStatsInstance) {
336
+        // FIXME the original purpose of adding BEFORE_DISPOSED event was to be
337
+        // able to submit the last log batch from jitsi-meet to CallStats. After
338
+        // recent changes we dispose the CallStats earlier
339
+        // (before Statistics.dispose), so we need to emit this event here to
340
+        // give this last chance for final log batch submission.
341
+        //
342
+        // Eventually there should be a separate module called "log storage"
343
+        // which should emit proper events when it's underlying
344
+        // CallStats instance is going away.
345
+        if (this.callsStatsInstances.size === 1) {
346
+            this.eventEmitter.emit(StatisticsEvents.BEFORE_DISPOSED);
347
+        }
329
         this.callsStatsInstances.delete(tpc.id);
348
         this.callsStatsInstances.delete(tpc.id);
330
 
349
 
331
         // The fabric needs to be terminated when being stopped
350
         // The fabric needs to be terminated when being stopped

読み込み中…
キャンセル
保存