Example #1
0
			Eventually(emitter.GetEvents).Should(ContainElement(&events.ValueMetric{Name: proto.String("logSenderTotalMessagesRead"), Value: proto.Float64(2), Unit: proto.String("count")}))
		})

		It("counts number of log messages read per app", func() {
			sender.SendAppLog("app-id1", "custom-log-message", "App", "0")
			sender.SendAppLog("app-id1", "custom-log-message", "App", "0")
			sender.SendAppLog("app-id2", "custom-log-message", "App", "0")

			Eventually(emitter.GetEvents).Should(ContainElement(&events.ValueMetric{Name: proto.String("logSenderTotalMessagesRead.app-id1"), Value: proto.Float64(2), Unit: proto.String("count")}))
			Eventually(emitter.GetEvents).Should(ContainElement(&events.ValueMetric{Name: proto.String("logSenderTotalMessagesRead.app-id2"), Value: proto.Float64(1), Unit: proto.String("count")}))
		})
	})

	Describe("SendAppErrorLog", func() {
		It("sends a log error message event to its emitter", func() {
			err := sender.SendAppErrorLog("app-id", "custom-log-error-message", "App", "0")
			Expect(err).NotTo(HaveOccurred())

			Expect(emitter.Messages).To(HaveLen(1))
			log := emitter.Messages[0].Event.(*events.LogMessage)
			Expect(log.GetMessageType()).To(Equal(events.LogMessage_ERR))
			Expect(log.GetMessage()).To(BeEquivalentTo("custom-log-error-message"))
			Expect(log.GetAppId()).To(Equal("app-id"))
			Expect(log.GetSourceType()).To(Equal("App"))
			Expect(log.GetSourceInstance()).To(Equal("0"))
			Expect(log.GetTimestamp()).ToNot(BeNil())
		})

		It("totals number of log messages sent to emitter", func() {
			sender.SendAppErrorLog("app-id", "custom-log-message", "App", "0")
			sender.SendAppErrorLog("app-id", "custom-log-message", "App", "0")