| 463 | } // namespace Tests |
| 464 | |
| 465 | ACTOR void publishProcessMetrics() { |
| 466 | // Give time to systemMonitor to log events. |
| 467 | wait(delay(5.0)); |
| 468 | |
| 469 | TraceEvent("BD_processMetricsPublisher"); |
| 470 | try { |
| 471 | loop { |
| 472 | // Update metrics at high priority. |
| 473 | wait(delay(5.0, TaskMaxPriority)); |
| 474 | |
| 475 | auto processMetrics = latestEventCache.get("ProcessMetrics"); |
| 476 | double processMetricsElapsed = processMetrics.getDouble("Elapsed"); |
| 477 | double cpuSeconds = processMetrics.getDouble("CPUSeconds"); |
| 478 | double mainThreadCPUSeconds = processMetrics.getDouble("MainThreadCPUSeconds"); |
| 479 | |
| 480 | double cpuUsage = std::max(0.0, cpuSeconds / processMetricsElapsed) * 100; |
| 481 | double mainThreadCPUUsage = std::max(0.0, mainThreadCPUSeconds / processMetricsElapsed) * 100; |
| 482 | |
| 483 | DocumentLayer::metricReporter->captureGauge(DocLayerConstants::MT_GUAGE_CPU_PERCENTAGE, cpuUsage); |
| 484 | DocumentLayer::metricReporter->captureGauge(DocLayerConstants::MT_GUAGE_MAIN_THREAD_CPU_PERCENTAGE, |
| 485 | mainThreadCPUUsage); |
| 486 | DocumentLayer::metricReporter->captureGauge(DocLayerConstants::MT_GUAGE_MEMORY_USAGE, |
| 487 | processMetrics.getInt64("Memory")); |
| 488 | }; |
| 489 | } catch (...) { |
| 490 | TraceEvent("BD_processMetricsPublisherException"); |
| 491 | throw; |
| 492 | } |
| 493 | } |
| 494 | |
| 495 | typedef std::vector<std::pair<FDBNetworkOption, Standalone<StringRef>>> NetworkOptionsT; |
| 496 |
no test coverage detected