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
}
Exemple #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
}
Exemple #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)
	}
}
Exemple #4
0
			Expect(mockWriter.Events).To(HaveLen(1))
			writtenEnvelope := mockWriter.Events[0]
			Eventually(*writtenEnvelope.Job).Should(Equal("another-job"))
		})

		It("when index is already set", func() {
			envelope.Index = proto.String("3")
			t.Write(envelope)

			Expect(mockWriter.Events).To(HaveLen(1))
			writtenEnvelope := mockWriter.Events[0]
			Eventually(*writtenEnvelope.Index).Should(Equal("3"))
		})

		It("when ip is already set", func() {
			envelope.Ip = proto.String("1.1.1.1")
			t.Write(envelope)

			Expect(mockWriter.Events).To(HaveLen(1))
			writtenEnvelope := mockWriter.Events[0]
			Eventually(*writtenEnvelope.Ip).Should(Equal("1.1.1.1"))
		})
	})
})

func basicMessage() *events.Envelope {
	return &events.Envelope{
		EventType: events.Envelope_HttpStartStop.Enum(),
		ValueMetric: &events.ValueMetric{
			Name:  proto.String("metricName"),
			Value: proto.Float64(2.0),