本文整理汇总了Golang中github.com/cloudfoundry/sonde-go/events.Envelope.GetValueMetric方法的典型用法代码示例。如果您正苦于以下问题:Golang Envelope.GetValueMetric方法的具体用法?Golang Envelope.GetValueMetric怎么用?Golang Envelope.GetValueMetric使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/sonde-go/events.Envelope
的用法示例。
在下文中一共展示了Envelope.GetValueMetric方法的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: checkValueMetric
func checkValueMetric(receivedEnvelope *events.Envelope, origin string, name string, value float64, unit string) {
Expect(receivedEnvelope.GetEventType()).To(Equal(events.Envelope_ValueMetric))
Expect(receivedEnvelope.GetOrigin()).To(Equal(origin))
vm := receivedEnvelope.GetValueMetric()
Expect(vm.GetName()).To(Equal(name))
Expect(vm.GetValue()).To(BeNumerically("==", value))
Expect(vm.GetUnit()).To(Equal(unit))
}
示例4: ProcessEvent
func (s *UAAChart) ProcessEvent(event *events.Envelope) {
switch event.GetValueMetric().GetName() {
case "audit_service.user_authentication_count":
s.data[0] = updateAndReturnValue(s.dataByIp[0], event)
case "audit_service.user_authentication_failure_count":
s.data[1] = updateAndReturnValue(s.dataByIp[1], event)
case "audit_service.principal_authentication_failure_count":
s.data[2] = updateAndReturnValue(s.dataByIp[2], event)
case "audit_service.user_password_failures":
s.data[3] = updateAndReturnValue(s.dataByIp[3], event)
}
}
示例5: ProcessEvent
func (s *SinkTypeChart) ProcessEvent(event *events.Envelope) {
switch event.GetValueMetric().GetName() {
case "messageRouter.numberOfContainerMetricSinks":
s.data[0] = updateAndReturnValue(s.dataByIp[0], event)
case "messageRouter.numberOfSyslogSinks":
s.data[1] = updateAndReturnValue(s.dataByIp[1], event)
case "messageRouter.numberOfDumpSinks":
s.data[2] = updateAndReturnValue(s.dataByIp[2], event)
case "messageRouter.numberOfWebsocketSinks":
s.data[3] = updateAndReturnValue(s.dataByIp[3], event)
case "messageRouter.numberOfFirehoseSinks":
s.data[4] = updateAndReturnValue(s.dataByIp[4], event)
}
}
示例6: ForChart
func (s *SinkTypeChart) ForChart(event *events.Envelope) bool {
if event.GetEventType() != events.Envelope_ValueMetric {
return false
}
if !contains(event.GetOrigin(), s.validOrigins) {
return false
}
if !contains(event.GetValueMetric().GetName(), s.validMetricNames) {
return false
}
// s.cfUI.Say("%f ", event.GetValueMetric().GetValue())
return true
}
示例7: ValueMetric
func ValueMetric(msg *events.Envelope) Event {
valMetric := msg.GetValueMetric()
fields := logrus.Fields{
"name": valMetric.GetName(),
"unit": valMetric.GetUnit(),
"value": valMetric.GetValue(),
}
return Event{
Fields: fields,
Msg: "",
}
}
示例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: ValueMetric
func ValueMetric(msg *events.Envelope) Event {
valMetric := msg.GetValueMetric()
fields := logrus.Fields{
"origin": msg.GetOrigin(),
"name": valMetric.GetName(),
"unit": valMetric.GetUnit(),
"value": valMetric.GetValue(),
}
return Event{
Fields: fields,
Msg: "",
Type: msg.GetEventType().String(),
}
}
示例10: 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)
}()
}
}
示例11: 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
}
示例12: Write
func (f *fakeWriter) Write(message *events.Envelope) {
if message.GetEventType() == events.Envelope_ValueMetric {
switch message.GetValueMetric().GetName() {
case "Uptime":
atomic.StoreUint64(&f.lastUptime, uint64(message.GetValueMetric().GetValue()))
case "LinuxFileDescriptor":
atomic.StoreUint64(&f.openFileDescriptors, uint64(message.GetValueMetric().GetValue()))
}
}
}
示例13: Write
func (f *fakeWriter) Write(message *events.Envelope) {
if message.GetEventType() == events.Envelope_ValueMetric && message.GetValueMetric().GetName() == "Uptime" {
atomic.StoreUint64(&f.lastUptime, uint64(message.GetValueMetric().GetValue()))
}
}
示例14: processValueMetric
func (metrics *metrics) processValueMetric(metric *events.Envelope) {
metrics.metricsByName[metric.GetValueMetric().GetName()] = metric.GetValueMetric().GetValue()
}
示例15:
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_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)