本文整理汇总了Golang中github.com/cloudfoundry/sonde-go/events.Envelope.GetTimestamp方法的典型用法代码示例。如果您正苦于以下问题:Golang Envelope.GetTimestamp方法的具体用法?Golang Envelope.GetTimestamp怎么用?Golang Envelope.GetTimestamp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/sonde-go/events.Envelope
的用法示例。
在下文中一共展示了Envelope.GetTimestamp方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: AddMetric
func (c *Client) AddMetric(envelope *events.Envelope) {
c.totalMessagesReceived++
if envelope.GetEventType() != events.Envelope_ValueMetric && envelope.GetEventType() != events.Envelope_CounterEvent {
return
}
key := metricKey{
eventType: envelope.GetEventType(),
name: getName(envelope),
deployment: envelope.GetDeployment(),
job: envelope.GetJob(),
index: envelope.GetIndex(),
ip: envelope.GetIp(),
}
mVal := c.metricPoints[key]
value := getValue(envelope)
mVal.tags = getTags(envelope)
mVal.points = append(mVal.points, Point{
Timestamp: envelope.GetTimestamp() / int64(time.Second),
Value: value,
})
c.metricPoints[key] = mVal
}
示例2: updateMetric
func (sink *ContainerMetricSink) updateMetric(event *events.Envelope) {
sink.lock.Lock()
defer sink.lock.Unlock()
instance := event.GetContainerMetric().GetInstanceIndex()
oldMetric, ok := sink.metrics[instance]
if !ok || oldMetric.GetTimestamp() < event.GetTimestamp() {
sink.metrics[instance] = event
}
}
示例3: AddMetric
func (c *Client) AddMetric(envelope *events.Envelope) {
c.totalMessagesReceived++
if envelope.GetEventType() != events.Envelope_ValueMetric && envelope.GetEventType() != events.Envelope_CounterEvent {
return
}
metric := poster.Metric{
Value: getValue(envelope),
Timestamp: envelope.GetTimestamp() / int64(time.Second),
Metric: c.prefix + getName(envelope),
Tags: getTags(envelope),
}
c.metrics = append(c.metrics, metric)
}
示例4: DeDupe
func DeDupe(input <-chan []byte) <-chan []byte {
messages := make(map[int32]*events.Envelope)
for message := range input {
var envelope events.Envelope
proto.Unmarshal(message, &envelope)
cm := envelope.GetContainerMetric()
oldEnvelope, ok := messages[cm.GetInstanceIndex()]
if !ok || oldEnvelope.GetTimestamp() < envelope.GetTimestamp() {
messages[cm.GetInstanceIndex()] = &envelope
}
}
output := make(chan []byte, len(messages))
for _, envelope := range messages {
bytes, _ := proto.Marshal(envelope)
output <- bytes
}
close(output)
return output
}
示例5: EventToJSON
//EventToJSON turns a firehose event into a json representation
func EventToJSON(event *events.Envelope) *[]byte {
props := map[string]interface{}{
"time": event.GetTimestamp() / 1000000000,
"origin": event.GetOrigin(),
"deployment": event.GetDeployment(),
"job": event.GetJob(),
"index": event.GetIndex(),
"ip": event.GetIp(),
"token": mixPanelToken,
}
data := map[string]interface{}{
"event": event.GetEventType().String(),
"properties": props,
}
j, err := json.Marshal(data)
if nil != err {
log.Print("Failed to marshal event")
log.Print(data)
}
return &j
}
示例6:
var outputMessage *events.Envelope
BeforeEach(func() {
messageAggregator.Write(createStartMessage(123, events.PeerType_Client))
messageAggregator.Write(createStopMessage(123, events.PeerType_Client))
outputMessage = mockWriter.Events[0]
})
It("populates all fields in the StartStop message correctly", func() {
Expect(outputMessage.GetHttpStartStop()).To(Equal(createStartStopMessage(123, events.PeerType_Client).GetHttpStartStop()))
})
It("populates all fields in the Envelope correctly", func() {
Expect(outputMessage.GetOrigin()).To(Equal("fake-origin-2"))
Expect(outputMessage.GetTimestamp()).ToNot(BeZero())
Expect(outputMessage.GetEventType()).To(Equal(events.Envelope_HttpStartStop))
})
})
It("does not send a combined event if there only is a stop event", func() {
messageAggregator.Write(createStopMessage(123, events.PeerType_Client))
Consistently(func() int { return len(mockWriter.Events) }).Should(Equal(0))
})
Context("message expiry", func() {
BeforeEach(func() {
messageaggregator.MaxTTL = 0
})
It("does not send a combined event if the stop event doesn't arrive within the TTL", func() {