예제 #1
0
func addDefaultTags(envelope *events.Envelope) *events.Envelope {
	envelope.Deployment = proto.String("deployment-name")
	envelope.Job = proto.String("test-component")
	envelope.Index = proto.String("42")
	envelope.Ip = proto.String(localIPAddress)

	return envelope
}
예제 #2
0
func basicTaggedHttpStartStopMessage(envelope events.Envelope) *events.Envelope {
	ip, _ := localip.LocalIP()

	envelope.Deployment = proto.String("test-deployment")
	envelope.Job = proto.String("test-job")
	envelope.Index = proto.String("2")
	envelope.Ip = proto.String(ip)

	return &envelope
}
예제 #3
0
func (t *Tagger) setDefaultTags(envelope *events.Envelope) {
	if envelope.Deployment == nil {
		envelope.Deployment = proto.String(t.deploymentName)
	}
	if envelope.Job == nil {
		envelope.Job = proto.String(t.job)
	}
	if envelope.Index == nil {
		envelope.Index = proto.String(t.index)
	}
	if envelope.Ip == nil {
		envelope.Ip = proto.String(t.ip)
	}
}
예제 #4
0
	})

	Context("doesn't overwrite", func() {
		var mockWriter *mocks.MockEnvelopeWriter
		var t *tagger.Tagger
		var envelope *events.Envelope

		BeforeEach(func() {
			mockWriter = &mocks.MockEnvelopeWriter{}
			t = tagger.New("test-deployment", "test-job", 2, mockWriter)

			envelope = basicMessage()
		})

		It("when deployment is already set", func() {
			envelope.Deployment = proto.String("another-deployment")
			t.Write(envelope)

			Expect(mockWriter.Events).To(HaveLen(1))
			writtenEnvelope := mockWriter.Events[0]
			Eventually(*writtenEnvelope.Deployment).Should(Equal("another-deployment"))
		})

		It("when job is already set", func() {
			envelope.Job = proto.String("another-job")
			t.Write(envelope)

			Expect(mockWriter.Events).To(HaveLen(1))
			writtenEnvelope := mockWriter.Events[0]
			Eventually(*writtenEnvelope.Job).Should(Equal("another-job"))
		})