當前位置: 首頁>>代碼示例>>Golang>>正文


Golang FakeMetricSender.GetContainerMetric方法代碼示例

本文整理匯總了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")
開發者ID:benlaplanche,項目名稱:emitter,代碼行數:29,代碼來源:metrics_test.go

示例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,
開發者ID:snowsnail,項目名稱:executor,代碼行數:31,代碼來源:stats_reporter_test.go


注:本文中的github.com/cloudfoundry/dropsonde/metric_sender/fake.FakeMetricSender.GetContainerMetric方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。