当前位置: 首页>>代码示例>>Golang>>正文


Golang Envelope.GetTimestamp方法代码示例

本文整理汇总了Golang中github.com/cloudfoundry/sonde-go/events.Envelope.GetTimestamp方法的典型用法代码示例。如果您正苦于以下问题:Golang Envelope.GetTimestamp方法的具体用法?Golang Envelope.GetTimestamp怎么用?Golang Envelope.GetTimestamp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/cloudfoundry/sonde-go/events.Envelope的用法示例。


在下文中一共展示了Envelope.GetTimestamp方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: AddMetric

func (c *Client) AddMetric(envelope *events.Envelope) {
	c.totalMessagesReceived++
	if envelope.GetEventType() != events.Envelope_ValueMetric && envelope.GetEventType() != events.Envelope_CounterEvent {
		return
	}

	key := metricKey{
		eventType:  envelope.GetEventType(),
		name:       getName(envelope),
		deployment: envelope.GetDeployment(),
		job:        envelope.GetJob(),
		index:      envelope.GetIndex(),
		ip:         envelope.GetIp(),
	}

	mVal := c.metricPoints[key]
	value := getValue(envelope)

	mVal.tags = getTags(envelope)
	mVal.points = append(mVal.points, Point{
		Timestamp: envelope.GetTimestamp() / int64(time.Second),
		Value:     value,
	})

	c.metricPoints[key] = mVal
}
开发者ID:simonjohansson,项目名称:datadog-firehose-nozzle,代码行数:26,代码来源:datadog_client.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: AddMetric

func (c *Client) AddMetric(envelope *events.Envelope) {
	c.totalMessagesReceived++
	if envelope.GetEventType() != events.Envelope_ValueMetric && envelope.GetEventType() != events.Envelope_CounterEvent {
		return
	}
	metric := poster.Metric{
		Value:     getValue(envelope),
		Timestamp: envelope.GetTimestamp() / int64(time.Second),
		Metric:    c.prefix + getName(envelope),
		Tags:      getTags(envelope),
	}

	c.metrics = append(c.metrics, metric)
}
开发者ID:pivotal-cf-experimental,项目名称:opentsdb-firehose-nozzle,代码行数:14,代码来源:opentsdb_client.go

示例4: 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

示例5: EventToJSON

//EventToJSON turns a firehose event into a json representation
func EventToJSON(event *events.Envelope) *[]byte {
	props := map[string]interface{}{
		"time":       event.GetTimestamp() / 1000000000,
		"origin":     event.GetOrigin(),
		"deployment": event.GetDeployment(),
		"job":        event.GetJob(),
		"index":      event.GetIndex(),
		"ip":         event.GetIp(),
		"token":      mixPanelToken,
	}
	data := map[string]interface{}{
		"event":      event.GetEventType().String(),
		"properties": props,
	}

	j, err := json.Marshal(data)
	if nil != err {
		log.Print("Failed to marshal event")
		log.Print(data)
	}
	return &j
}
开发者ID:krujos,项目名称:firehose-mixpanel,代码行数:23,代码来源:sender.go

示例6:

		var outputMessage *events.Envelope
		BeforeEach(func() {
			messageAggregator.Write(createStartMessage(123, events.PeerType_Client))
			messageAggregator.Write(createStopMessage(123, events.PeerType_Client))

			outputMessage = mockWriter.Events[0]
		})

		It("populates all fields in the StartStop message correctly", func() {
			Expect(outputMessage.GetHttpStartStop()).To(Equal(createStartStopMessage(123, events.PeerType_Client).GetHttpStartStop()))

		})

		It("populates all fields in the Envelope correctly", func() {
			Expect(outputMessage.GetOrigin()).To(Equal("fake-origin-2"))
			Expect(outputMessage.GetTimestamp()).ToNot(BeZero())
			Expect(outputMessage.GetEventType()).To(Equal(events.Envelope_HttpStartStop))
		})
	})

	It("does not send a combined event if there only is a stop event", func() {
		messageAggregator.Write(createStopMessage(123, events.PeerType_Client))
		Consistently(func() int { return len(mockWriter.Events) }).Should(Equal(0))
	})

	Context("message expiry", func() {
		BeforeEach(func() {
			messageaggregator.MaxTTL = 0
		})

		It("does not send a combined event if the stop event doesn't arrive within the TTL", func() {
开发者ID:khj0651,项目名称:loggregator,代码行数:31,代码来源:message_aggregator_test.go


注:本文中的github.com/cloudfoundry/sonde-go/events.Envelope.GetTimestamp方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。