func (s *valueMetricSender) SendValueMetric(deployment, job, index, eventName string, secondsSinceEpoch int64, value float64, units string) error { envelope := events.Envelope{ Origin: proto.String(ForwarderOrigin), EventType: events.Envelope_ValueMetric.Enum(), Timestamp: proto.Int64(secondsSinceEpoch * int64(time.Second)), Deployment: proto.String(deployment), Job: proto.String(job), Index: proto.String(index), Ip: proto.String(""), ValueMetric: &events.ValueMetric{ Name: proto.String(eventName), Value: proto.Float64(value), Unit: proto.String(units), }, } return envelopes.SendEnvelope(&envelope) }
"github.com/cloudfoundry/dropsonde/envelope_sender/fake" ) var _ = Describe("Metrics", func() { var fakeEnvelopeSender *fake.FakeEnvelopeSender BeforeEach(func() { fakeEnvelopeSender = fake.NewFakeEnvelopeSender() envelopes.Initialize(fakeEnvelopeSender) }) It("delegates SendEnvelope", func() { testEnvelope := createTestEnvelope() envelopes.SendEnvelope(testEnvelope) Expect(fakeEnvelopeSender.GetEnvelopes()).To(HaveLen(1)) Expect(fakeEnvelopeSender.GetEnvelopes()[0]).To(BeEquivalentTo(testEnvelope)) }) Context("when Envelope Sender is not initialized", func() { BeforeEach(func() { envelopes.Initialize(nil) }) It("SendEnvelope is a no-op", func() { err := envelopes.SendEnvelope(createTestEnvelope()) Expect(err).ToNot(HaveOccurred())