本文整理匯總了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,