本文整理匯總了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
}