コード例 #1
0
 internal ContainerMetrics(MetricsSystem ms, ContainerId containerId, long flushPeriodMs
                           , long delayMs)
 {
     // Use a multiplier of 1000 to avoid losing too much precision when
     // converting to integers
     // This tracks overall CPU percentage of the machine in terms of percentage
     // of 1 core similar to top
     // Thus if you use 2 cores completely out of 4 available cores this value
     // will be 200
     // Metrics publishing status
     // true if period elapsed
     // true if container finished
     // unregister
     // lazily initialized
     // Create a timer to unregister container metrics,
     // whose associated thread run as a daemon.
     this.recordInfo        = Interns.Info(SourceName(containerId), RecordInfo.Description());
     this.registry          = new MetricsRegistry(recordInfo);
     this.metricsSystem     = ms;
     this.containerId       = containerId;
     this.flushPeriodMs     = flushPeriodMs;
     this.unregisterDelayMs = delayMs < 0 ? 0 : delayMs;
     ScheduleTimerTaskIfRequired();
     this.pMemMBsStat = registry.NewStat(PmemUsageMetricName, "Physical memory stats",
                                         "Usage", "MBs", true);
     this.cpuCoreUsagePercent = registry.NewStat(PhyCpuUsageMetricName, "Physical Cpu core percent usage stats"
                                                 , "Usage", "Percents", true);
     this.milliVcoresUsed = registry.NewStat(VcoreUsageMetricName, "1000 times Vcore usage"
                                             , "Usage", "MilliVcores", true);
     this.pMemLimitMbs = registry.NewGauge(PmemLimitMetricName, "Physical memory limit in MBs"
                                           , 0);
     this.vMemLimitMbs = registry.NewGauge(VmemLimitMetricName, "Virtual memory limit in MBs"
                                           , 0);
     this.cpuVcoreLimit = registry.NewGauge(VcoreLimitMetricName, "CPU limit in number of vcores"
                                            , 0);
 }