当前位置: 首页>>代码示例>>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;未经允许,请勿转载。