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


Golang Counter.GetValue方法代碼示例

本文整理匯總了Golang中tools/benchmark/metricsreporter.Counter.GetValue方法的典型用法代碼示例。如果您正苦於以下問題:Golang Counter.GetValue方法的具體用法?Golang Counter.GetValue怎麽用?Golang Counter.GetValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tools/benchmark/metricsreporter.Counter的用法示例。


在下文中一共展示了Counter.GetValue方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1:

			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() {
			reader.event = messagegenerator.BasicLogMessageEnvelope("non-test-origin", "appID")

			legacyReader.Read()
開發者ID:Jonty,項目名稱:loggregator,代碼行數:30,代碼來源:legacy_reader_test.go

示例2:

)

var _ = Describe("MessageWriter", func() {
	var (
		sentCounter *metricsreporter.Counter
	)
	BeforeEach(func() {
		sentCounter = metricsreporter.NewCounter("sent")
	})

	It("should keep track of the total sent messages", func() {
		msgWriter := messagewriter.NewMessageWriter("localhost", 51161, "", sentCounter)
		message := []byte{}
		msgWriter.Write(message)
		msgWriter.Write(message)
		msgWriter.Write(message)
		msgWriter.Write(message)
		msgWriter.Write(message)
		msgWriter.Write(message)
		msgWriter.Write(message)
		msgWriter.Write(message)

		Expect(sentCounter.GetValue()).To(BeEquivalentTo(8))
	})

	It("should not increment total sent messages", func() {
		messagewriter.NewMessageWriter("localhost", 51161, "", sentCounter)
		Expect(sentCounter.GetValue()).To(BeEquivalentTo(0))
	})
})
開發者ID:lyuyun,項目名稱:loggregator,代碼行數:30,代碼來源:message_writer_test.go

示例3:

			reader            fakeReader
			valueMetricReader *valuemetricreader.ValueMetricReader
		)

		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()
開發者ID:lyuyun,項目名稱:loggregator,代碼行數:30,代碼來源:value_metric_reader_test.go

示例4:

var _ = Describe("Counter", func() {
	var counter *metricsreporter.Counter

	BeforeEach(func() {
		counter = metricsreporter.NewCounter("counter")
	})

	Context("GetName", func() {
		It("returns its name", func() {
			Expect(counter.GetName()).To(Equal("counter"))
		})
	})

	Context("GetValue", func() {
		It("returns its current value", func() {
			Expect(counter.GetValue()).To(BeEquivalentTo(0))
		})
	})

	Context("GetTotal", func() {
		It("returns its current total", func() {
			Expect(counter.GetTotal()).To(BeEquivalentTo(0))
		})
	})

	Context("IncrementValue", func() {
		It("increments the value", func() {
			counter.IncrementValue()
			Expect(counter.GetValue()).To(BeEquivalentTo(1))
		})
	})
開發者ID:lyuyun,項目名稱:loggregator,代碼行數:31,代碼來源:counter_test.go


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