ChatterBox.Client.Universal.Background.AudioVideoMetricsCollector.TrackCurrentDelayMetrics C# (CSharp) Method

TrackCurrentDelayMetrics() public method

public TrackCurrentDelayMetrics ( ) : void
return void
        public void TrackCurrentDelayMetrics()
        {
            if (_audioDelayCount > 0)
            {
                MetricTelemetry metric = new MetricTelemetry("Audio Current Delay Ratio", _audioCurrentDelayMs / _audioDelayCount);
                metric.Timestamp = System.DateTimeOffset.UtcNow;
                Task.Run(() => _telemetry.TrackMetric(metric));
            }
            if (_videoDelayCount > 0)
            {
                MetricTelemetry metric = new MetricTelemetry("Video Current Delay Ratio", _videoCurrentDelayMs / _videoDelayCount);
                metric.Timestamp = System.DateTimeOffset.UtcNow;
                Task.Run(() => _telemetry.TrackMetric(metric));
            }
            ResetDelays();
        }

Usage Example

 public void StopCallWatch()
 {
     if (_callWatch != null)
     {
         _callWatch.Stop();
         DateTime currentDateTime = DateTime.Now;
         TimeSpan time            = _callWatch.Elapsed;
         Task.Run(() => _telemetry.TrackRequest("Call Duration", currentDateTime,
                                                time,
                                                "200", true)); // Response code, success
         if (_metricsCollector != null)
         {
             _metricsCollector.TrackCurrentDelayMetrics();
             _metricsCollector.TrackNetworkQualityMetrics();
         }
         if (_networkTimer != null)
         {
             _networkTimer.Dispose();
         }
     }
 }