本文整理汇总了Golang中github.com/cloudfoundry/sonde-go/events.Envelope.GetContainerMetric方法的典型用法代码示例。如果您正苦于以下问题:Golang Envelope.GetContainerMetric方法的具体用法?Golang Envelope.GetContainerMetric怎么用?Golang Envelope.GetContainerMetric使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/sonde-go/events.Envelope
的用法示例。
在下文中一共展示了Envelope.GetContainerMetric方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: GetAppId
func GetAppId(envelope *events.Envelope) string {
if envelope.GetEventType() == events.Envelope_LogMessage {
return envelope.GetLogMessage().GetAppId()
}
if envelope.GetEventType() == events.Envelope_ContainerMetric {
return envelope.GetContainerMetric().GetApplicationId()
}
var event hasAppId
switch envelope.GetEventType() {
case events.Envelope_HttpStart:
event = envelope.GetHttpStart()
case events.Envelope_HttpStop:
event = envelope.GetHttpStop()
case events.Envelope_HttpStartStop:
event = envelope.GetHttpStartStop()
default:
return SystemAppId
}
uuid := event.GetApplicationId()
if uuid != nil {
return formatUUID(uuid)
}
return SystemAppId
}
示例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: ContainerMetric
func ContainerMetric(msg *events.Envelope) Event {
containerMetric := msg.GetContainerMetric()
fields := logrus.Fields{
"cf_app_id": containerMetric.GetApplicationId(),
"cpu_percentage": containerMetric.GetCpuPercentage(),
"disk_bytes": containerMetric.GetDiskBytes(),
"instance_index": containerMetric.GetInstanceIndex(),
"memory_bytes": containerMetric.GetMemoryBytes(),
}
return Event{
Fields: fields,
Msg: "",
}
}
示例4: 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
}
示例5: 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
}