StartPerformanceTelemetry begins periodic collection and sending of performance telemetry. It should be called once after the session is initialized.
()
| 581 | // StartPerformanceTelemetry begins periodic collection and sending of performance |
| 582 | // telemetry. It should be called once after the session is initialized. |
| 583 | func (s *Session) StartPerformanceTelemetry() { |
| 584 | if !s.options.TelemetryEnabled { |
| 585 | return |
| 586 | } |
| 587 | ctx, cancel := context.WithCancel(s.backgroundCtx) |
| 588 | s.performanceTelemetryCancel = cancel |
| 589 | s.backgroundQueue.Enqueue(ctx, func(ctx context.Context) { |
| 590 | ticker := time.NewTicker(performanceTelemetryInterval) |
| 591 | defer ticker.Stop() |
| 592 | for { |
| 593 | select { |
| 594 | case <-ctx.Done(): |
| 595 | return |
| 596 | case <-ticker.C: |
| 597 | if s.client == nil || !s.client.IsActive() { |
| 598 | continue |
| 599 | } |
| 600 | s.sendPerformanceTelemetry(ctx) |
| 601 | } |
| 602 | } |
| 603 | }) |
| 604 | } |
| 605 | |
| 606 | func (s *Session) stopPerformanceTelemetry() { |
| 607 | if s.performanceTelemetryCancel != nil { |
no test coverage detected