本文整理汇总了Golang中github.com/cloudfoundry/dropsonde/metric_sender/fake.FakeMetricSender.GetContainerMetric方法的典型用法代码示例。如果您正苦于以下问题:Golang FakeMetricSender.GetContainerMetric方法的具体用法?Golang FakeMetricSender.GetContainerMetric怎么用?Golang FakeMetricSender.GetContainerMetric使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/dropsonde/metric_sender/fake.FakeMetricSender
的用法示例。
在下文中一共展示了FakeMetricSender.GetContainerMetric方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
It("delegates BatchAddCounter", func() {
metrics.BatchAddCounter("count", 3)
time.Sleep(2 * time.Millisecond)
Expect(fakeMetricSender.GetCounter("count")).To(BeEquivalentTo(3))
metrics.BatchAddCounter("count", 7)
time.Sleep(2 * time.Millisecond)
Expect(fakeMetricSender.GetCounter("count")).To(BeEquivalentTo(10))
})
It("delegates SendContainerMetric", func() {
appGuid := "some_app_guid"
metrics.SendContainerMetric(appGuid, 7, 42.42, 1234, 123412341234)
Expect(fakeMetricSender.GetContainerMetric(appGuid).ApplicationId).To(Equal(appGuid))
Expect(fakeMetricSender.GetContainerMetric(appGuid).InstanceIndex).To(BeEquivalentTo(7))
Expect(fakeMetricSender.GetContainerMetric(appGuid).CpuPercentage).To(BeEquivalentTo(42.42))
Expect(fakeMetricSender.GetContainerMetric(appGuid).MemoryBytes).To(BeEquivalentTo(1234))
Expect(fakeMetricSender.GetContainerMetric(appGuid).DiskBytes).To(BeEquivalentTo(123412341234))
})
Context("when Metric Sender is not initialized", func() {
BeforeEach(func() {
metrics.Initialize(nil, nil)
})
It("SendValue is a no-op", func() {
err := metrics.SendValue("metric", 42.42, "answers")
示例2:
AfterEach(func() {
close(metricsResults)
ginkgomon.Interrupt(process)
})
Context("when the interval elapses", func() {
BeforeEach(func() {
sendResults()
fakeClock.Increment(interval)
Eventually(fakeExecutorClient.GetAllMetricsCallCount).Should(Equal(1))
})
It("emits memory and disk usage for each container, but no CPU", func() {
Eventually(func() msfake.ContainerMetric {
return fakeMetricSender.GetContainerMetric("metrics-guid-without-index")
}).Should(Equal(msfake.ContainerMetric{
ApplicationId: "metrics-guid-without-index",
InstanceIndex: 0,
CpuPercentage: 0.0,
MemoryBytes: 123,
DiskBytes: 456,
}))
Eventually(func() msfake.ContainerMetric {
return fakeMetricSender.GetContainerMetric("metrics-guid-with-index")
}).Should(Equal(msfake.ContainerMetric{
ApplicationId: "metrics-guid-with-index",
InstanceIndex: 1,
CpuPercentage: 0.0,
MemoryBytes: 321,