本文整理汇总了Golang中github.com/cloudfoundry/sonde-go/events.Envelope.GetCounterEvent方法的典型用法代码示例。如果您正苦于以下问题:Golang Envelope.GetCounterEvent方法的具体用法?Golang Envelope.GetCounterEvent怎么用?Golang Envelope.GetCounterEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/sonde-go/events.Envelope
的用法示例。
在下文中一共展示了Envelope.GetCounterEvent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: getName
func getName(envelope *events.Envelope) string {
switch envelope.GetEventType() {
case events.Envelope_ValueMetric:
return envelope.GetOrigin() + "." + envelope.GetValueMetric().GetName()
case events.Envelope_CounterEvent:
return envelope.GetOrigin() + "." + envelope.GetCounterEvent().GetName()
default:
panic("Unknown event type")
}
}
示例2: getValue
func getValue(envelope *events.Envelope) float64 {
switch envelope.GetEventType() {
case events.Envelope_ValueMetric:
return envelope.GetValueMetric().GetValue()
case events.Envelope_CounterEvent:
return float64(envelope.GetCounterEvent().GetTotal())
default:
panic("Unknown event type")
}
}
示例3: ProcessEvent
func (m *MsgLossChart) ProcessEvent(evt *events.Envelope) {
switch evt.GetCounterEvent().GetName() {
case "DopplerForwarder.sentMessages":
m.totalSent = update(m.sentByIP, evt)
case "tlsListener.receivedMessageCount", "dropsondeListener.receivedMessageCount":
m.totalReceived = update(m.receivedByIP, evt)
}
percent := 100 * ((m.totalSent - m.totalReceived) / m.totalSent)
m.graph.Percent = int(percent)
}
示例4: update
func update(values map[string]int64, event *events.Envelope) int64 {
values[event.GetIp()] = int64(event.GetCounterEvent().GetTotal())
var sum int64
for _, v := range values {
sum = sum + v
}
return sum
}
示例5: ForChart
func (m *MsgLossChart) ForChart(event *events.Envelope) bool {
if event.GetEventType() != events.Envelope_CounterEvent {
return false
}
if !contains(event.GetOrigin(), m.validOrigins) {
return false
}
if !contains(event.GetCounterEvent().GetName(), m.validMetricNames) {
return false
}
return true
}
示例6: CounterEvent
func CounterEvent(msg *events.Envelope) Event {
counterEvent := msg.GetCounterEvent()
fields := logrus.Fields{
"name": counterEvent.GetName(),
"delta": counterEvent.GetDelta(),
"total": counterEvent.GetTotal(),
}
return Event{
Fields: fields,
Msg: "",
}
}
示例7: CounterEvent
func CounterEvent(msg *events.Envelope) Event {
counterEvent := msg.GetCounterEvent()
fields := logrus.Fields{
"origin": msg.GetOrigin(),
"name": counterEvent.GetName(),
"delta": counterEvent.GetDelta(),
"total": counterEvent.GetTotal(),
}
return Event{
Fields: fields,
Msg: "",
Type: msg.GetEventType().String(),
}
}
示例8: updateAndReturnValue
func updateAndReturnValue(values map[string]int, event *events.Envelope) int {
switch event.GetEventType() {
case events.Envelope_CounterEvent:
values[event.GetIp()] = int(event.GetCounterEvent().GetTotal())
case events.Envelope_ValueMetric:
values[event.GetIp()] = int(event.GetValueMetric().GetValue())
}
sum := 0
for _, v := range values {
sum += v
}
return sum
}
示例9: listenForEvents
func listenForEvents(origin []string) {
for {
buffer := make([]byte, 1024)
n, _, err := udpListener.ReadFrom(buffer)
if err != nil {
return
}
if n == 0 {
panic("Received empty packet")
}
envelope := new(events.Envelope)
err = proto.Unmarshal(buffer[0:n], envelope)
if err != nil {
panic(err)
}
var eventId = envelope.GetEventType().String()
tracker := eventTracker{eventType: eventId}
switch envelope.GetEventType() {
case events.Envelope_HttpStart:
tracker.name = envelope.GetHttpStart().GetPeerType().String()
case events.Envelope_HttpStop:
tracker.name = envelope.GetHttpStop().GetPeerType().String()
case events.Envelope_ValueMetric:
tracker.name = envelope.GetValueMetric().GetName()
case events.Envelope_CounterEvent:
tracker.name = envelope.GetCounterEvent().GetName()
default:
panic("Unexpected message type")
}
if envelope.GetOrigin() != strings.Join(origin, "/") {
panic("origin not as expected")
}
func() {
lock.Lock()
defer lock.Unlock()
receivedEvents = append(receivedEvents, tracker)
}()
}
}
示例10: valid
func valid(env *events.Envelope) bool {
switch env.GetEventType() {
case events.Envelope_HttpStartStop:
return env.GetHttpStartStop() != nil
case events.Envelope_LogMessage:
return env.GetLogMessage() != nil
case events.Envelope_ValueMetric:
return env.GetValueMetric() != nil
case events.Envelope_CounterEvent:
return env.GetCounterEvent() != nil
case events.Envelope_Error:
return env.GetError() != nil
case events.Envelope_ContainerMetric:
return env.GetContainerMetric() != nil
}
return true
}
示例11: handleCounter
func (m *MessageAggregator) handleCounter(envelope *events.Envelope) *events.Envelope {
metrics.BatchIncrementCounter("MessageAggregator.counterEventReceived")
countID := counterID{
name: envelope.GetCounterEvent().GetName(),
origin: envelope.GetOrigin(),
}
newVal := m.counterTotals[countID] + envelope.GetCounterEvent().GetDelta()
m.counterTotals[countID] = newVal
envelope.GetCounterEvent().Total = &newVal
return envelope
}
示例12:
return t
}
tracksDroppedMessagesAnd := func(itMsg string, delta, total int) {
It(itMsg, func() {
var logMessageNotification *events.Envelope
Eventually(buffer.GetOutputChannel).Should(Receive(&logMessageNotification))
Expect(logMessageNotification.GetEventType()).To(Equal(events.Envelope_LogMessage))
Expect(logMessageNotification.GetLogMessage().GetAppId()).To(Equal("fake-app-id"))
Expect(logMessageNotification.GetLogMessage().GetMessage()).To(ContainSubstring(fmt.Sprintf("Log message output is too high. %d messages dropped (Total %d messages dropped) from doppler to test-sink-name.", delta, total)))
var counterEventNotification *events.Envelope
Eventually(buffer.GetOutputChannel).Should(Receive(&counterEventNotification))
Expect(counterEventNotification.GetEventType()).To(Equal(events.Envelope_CounterEvent))
counterEvent := counterEventNotification.GetCounterEvent()
Expect(counterEvent.GetName()).To(Equal("TruncatingBuffer.DroppedMessages"))
Expect(counterEvent.GetDelta()).To(BeEquivalentTo(delta))
Expect(counterEvent.GetTotal()).To(BeEquivalentTo(total))
Eventually(func() uint64 { return receiveDroppedMessages() }).Should(BeEquivalentTo(total))
})
}
BeforeEach(func() {
fakeEventEmitter = fake.NewFakeEventEmitter("doppler")
sender := metric_sender.NewMetricSender(fakeEventEmitter)
batcher := metricbatcher.New(sender, time.Millisecond)
metrics.Initialize(sender, batcher)
示例13: expectCorrectCounterNameDeltaAndTotal
func expectCorrectCounterNameDeltaAndTotal(outputMessage *events.Envelope, name string, delta uint64, total uint64) {
Expect(outputMessage.GetCounterEvent().GetName()).To(Equal(name))
Expect(outputMessage.GetCounterEvent().GetDelta()).To(Equal(delta))
Expect(outputMessage.GetCounterEvent().GetTotal()).To(Equal(total))
}
示例14:
var eventId = envelope.GetEventType().String()
tracker := eventTracker{eventType: eventId}
switch envelope.GetEventType() {
case events.Envelope_HttpStart:
tracker.name = envelope.GetHttpStart().GetPeerType().String()
case events.Envelope_HttpStop:
tracker.name = envelope.GetHttpStop().GetPeerType().String()
case events.Envelope_Heartbeat:
tracker.name = envelope.GetHeartbeat().GetControlMessageIdentifier().String()
case events.Envelope_ValueMetric:
tracker.name = envelope.GetValueMetric().GetName()
case events.Envelope_CounterEvent:
tracker.name = envelope.GetCounterEvent().GetName()
default:
panic("Unexpected message type")
}
if envelope.GetOrigin() != strings.Join(origin, "/") {
panic("origin not as expected")
}
func() {
lock.Lock()
defer lock.Unlock()
receivedEvents = append(receivedEvents, tracker)
}()
}
示例15: processCounterEvent
func (metrics *metrics) processCounterEvent(metric *events.Envelope) {
eventName := metric.GetCounterEvent().GetName()
count := metrics.metricsByName[eventName]
metrics.metricsByName[eventName] = count + float64(metric.GetCounterEvent().GetDelta())
}