BeforeEach(func() {
			receivedCounter = metricsreporter.NewCounter("counter")
			reader = fakeReader{}
			valueMetricReader = valuemetricreader.NewValueMetricReader(receivedCounter, &reader)
		})

		It("should report value metrics", func() {
			reader.event = messagegenerator.BasicValueMetricEnvelope(valuemetricreader.TestOrigin)

			valueMetricReader.Read()

			Expect(receivedCounter.GetValue()).To(BeEquivalentTo(1))
		})

		It("should not report log messages", func() {
			reader.event = messagegenerator.BasicLogMessageEnvelope(valuemetricreader.TestOrigin, "appID")

			valueMetricReader.Read()

			Expect(receivedCounter.GetValue()).To(BeEquivalentTo(0))
		})

		It("should only report test value metrics", func() {
			reader.event = messagegenerator.BasicValueMetricEnvelope("some-other-origin")

			valueMetricReader.Read()

			Expect(receivedCounter.GetValue()).To(BeEquivalentTo(0))
		})
	})
})
Exemplo n.º 2
0
		var (
			receivedCounter        *metricsreporter.Counter
			internalMetricsCounter *metricsreporter.Counter
			reader                 fakeReader
			legacyReader           *legacyreader.LegacyReader
		)

		BeforeEach(func() {
			receivedCounter = metricsreporter.NewCounter("received")
			internalMetricsCounter = metricsreporter.NewCounter("internal metrics")
			reader = fakeReader{}
			legacyReader = legacyreader.NewLegacyReader(receivedCounter, internalMetricsCounter, &reader)
		})

		It("should report legacy log messages", func() {
			reader.event = messagegenerator.BasicLogMessageEnvelope("legacy", "appID")

			legacyReader.Read()

			Expect(receivedCounter.GetValue()).To(BeEquivalentTo(1))
		})

		It("should report value metrics", func() {
			reader.event = messagegenerator.BasicValueMetricEnvelope("test-origin")

			legacyReader.Read()

			Expect(receivedCounter.GetValue()).To(BeEquivalentTo(1))
		})

		It("should only count test log messages", func() {
	Context("ValueMetrics", func() {
		BeforeEach(func() {
			eventType = events.Envelope_ValueMetric
		})

		It("should report value metrics", func() {
			reader.event = messagegenerator.BasicValueMetricEnvelope(testOrigin)

			valueMetricReader.Read()

			Expect(receivedCounter.GetValue()).To(BeEquivalentTo(1))
		})

		It("should not report log messages", func() {
			reader.event = messagegenerator.BasicLogMessageEnvelope(testOrigin, "appID")

			valueMetricReader.Read()

			Expect(receivedCounter.GetValue()).To(BeEquivalentTo(0))
		})

		It("should only report test value metrics", func() {
			reader.event = messagegenerator.BasicValueMetricEnvelope("some-other-origin")

			valueMetricReader.Read()

			Expect(receivedCounter.GetValue()).To(BeEquivalentTo(0))
		})
	})