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")
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,