當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Envelope.GetContainerMetric方法代碼示例

本文整理匯總了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
}
開發者ID:Reejoshi,項目名稱:cli,代碼行數:27,代碼來源:envelope_extensions.go

示例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
	}
}
開發者ID:lyuyun,項目名稱:loggregator,代碼行數:12,代碼來源:container_metric_sink.go

示例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:    "",
	}
}
開發者ID:yacloud-io,項目名稱:firehose-to-syslog,代碼行數:16,代碼來源:events.go

示例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
}
開發者ID:kei-yamazaki,項目名稱:loggregator,代碼行數:17,代碼來源:event_unmarshaller.go

示例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
}
開發者ID:lyuyun,項目名稱:loggregator,代碼行數:22,代碼來源:doppler_endpoint.go


注:本文中的github.com/cloudfoundry/sonde-go/events.Envelope.GetContainerMetric方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。