当前位置: 首页>>代码示例>>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;未经允许,请勿转载。