(ctx context.Context)
| 611 | } |
| 612 | |
| 613 | func (s *Session) sendPerformanceTelemetry(ctx context.Context) { |
| 614 | if s.client == nil || !s.options.TelemetryEnabled { |
| 615 | return |
| 616 | } |
| 617 | s.snapshotMu.RLock() |
| 618 | snapshot := s.snapshot |
| 619 | s.snapshotMu.RUnlock() |
| 620 | |
| 621 | // Read Go runtime metrics in a single call |
| 622 | const ( |
| 623 | sMemoryUsedBytes = iota |
| 624 | sGoMemLimit |
| 625 | sGoGCPercent |
| 626 | sHeapGoalBytes |
| 627 | sHeapLiveBytes |
| 628 | sHeapObjectCount |
| 629 | sHeapStackBytes |
| 630 | sHeapReleasedBytes |
| 631 | sHeapFreeBytes |
| 632 | sGcScanHeapBytes |
| 633 | sGoMaxProcs |
| 634 | sGoroutineCount |
| 635 | sGcCyclesTotal |
| 636 | sGcCPUSeconds |
| 637 | sUserCPUSeconds |
| 638 | sMetricCount |
| 639 | ) |
| 640 | samples := make([]gometrics.Sample, sMetricCount) |
| 641 | samples[sMemoryUsedBytes].Name = "/memory/classes/total:bytes" |
| 642 | samples[sGoMemLimit].Name = "/gc/gomemlimit:bytes" |
| 643 | samples[sGoGCPercent].Name = "/gc/gogc:percent" |
| 644 | samples[sHeapGoalBytes].Name = "/gc/heap/goal:bytes" |
| 645 | samples[sHeapLiveBytes].Name = "/gc/heap/live:bytes" |
| 646 | samples[sHeapObjectCount].Name = "/gc/heap/objects:objects" |
| 647 | samples[sHeapStackBytes].Name = "/memory/classes/heap/stacks:bytes" |
| 648 | samples[sHeapReleasedBytes].Name = "/memory/classes/heap/released:bytes" |
| 649 | samples[sHeapFreeBytes].Name = "/memory/classes/heap/free:bytes" |
| 650 | samples[sGcScanHeapBytes].Name = "/gc/scan/heap:bytes" |
| 651 | samples[sGoMaxProcs].Name = "/sched/gomaxprocs:threads" |
| 652 | samples[sGoroutineCount].Name = "/sched/goroutines:goroutines" |
| 653 | samples[sGcCyclesTotal].Name = "/gc/cycles/total:gc-cycles" |
| 654 | samples[sGcCPUSeconds].Name = "/cpu/classes/gc/total:cpu-seconds" |
| 655 | samples[sUserCPUSeconds].Name = "/cpu/classes/user:cpu-seconds" |
| 656 | gometrics.Read(samples) |
| 657 | |
| 658 | measurements := &lsproto.PerformanceStatsTelemetryMeasurements{ |
| 659 | OpenFileCount: float64(len(snapshot.fs.overlays)), |
| 660 | UptimeSeconds: time.Since(s.startTime).Seconds(), |
| 661 | ProjectCount: float64(len(snapshot.ProjectCollection.Projects())), |
| 662 | ConfigCount: float64(len(snapshot.ConfigFileRegistry.configs)), |
| 663 | CachedDiskFileCount: float64(len(snapshot.fs.diskFiles)), |
| 664 | } |
| 665 | |
| 666 | readUint64 := func(s gometrics.Sample) float64 { |
| 667 | if s.Value.Kind() == gometrics.KindUint64 { |
| 668 | return float64(s.Value.Uint64()) |
| 669 | } |
| 670 | return 0 |
no test coverage detected