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


Golang Envelope.GetCounterEvent方法代码示例

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


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

示例1: getName

func getName(envelope *events.Envelope) string {
	switch envelope.GetEventType() {
	case events.Envelope_ValueMetric:
		return envelope.GetOrigin() + "." + envelope.GetValueMetric().GetName()
	case events.Envelope_CounterEvent:
		return envelope.GetOrigin() + "." + envelope.GetCounterEvent().GetName()
	default:
		panic("Unknown event type")
	}
}
开发者ID:simonjohansson,项目名称:datadog-firehose-nozzle,代码行数:10,代码来源:datadog_client.go

示例2: getValue

func getValue(envelope *events.Envelope) float64 {
	switch envelope.GetEventType() {
	case events.Envelope_ValueMetric:
		return envelope.GetValueMetric().GetValue()
	case events.Envelope_CounterEvent:
		return float64(envelope.GetCounterEvent().GetTotal())
	default:
		panic("Unknown event type")
	}
}
开发者ID:simonjohansson,项目名称:datadog-firehose-nozzle,代码行数:10,代码来源:datadog_client.go

示例3: ProcessEvent

func (m *MsgLossChart) ProcessEvent(evt *events.Envelope) {
	switch evt.GetCounterEvent().GetName() {
	case "DopplerForwarder.sentMessages":
		m.totalSent = update(m.sentByIP, evt)
	case "tlsListener.receivedMessageCount", "dropsondeListener.receivedMessageCount":
		m.totalReceived = update(m.receivedByIP, evt)
	}
	percent := 100 * ((m.totalSent - m.totalReceived) / m.totalSent)

	m.graph.Percent = int(percent)
}
开发者ID:wfernandes,项目名称:firehose-stats,代码行数:11,代码来源:msgLoss.go

示例4: update

func update(values map[string]int64, event *events.Envelope) int64 {

	values[event.GetIp()] = int64(event.GetCounterEvent().GetTotal())

	var sum int64
	for _, v := range values {
		sum = sum + v
	}

	return sum
}
开发者ID:wfernandes,项目名称:firehose-stats,代码行数:11,代码来源:msgLoss.go

示例5: ForChart

func (m *MsgLossChart) ForChart(event *events.Envelope) bool {
	if event.GetEventType() != events.Envelope_CounterEvent {
		return false
	}
	if !contains(event.GetOrigin(), m.validOrigins) {
		return false
	}
	if !contains(event.GetCounterEvent().GetName(), m.validMetricNames) {
		return false
	}
	return true
}
开发者ID:wfernandes,项目名称:firehose-stats,代码行数:12,代码来源:msgLoss.go

示例6: CounterEvent

func CounterEvent(msg *events.Envelope) Event {
	counterEvent := msg.GetCounterEvent()

	fields := logrus.Fields{
		"name":  counterEvent.GetName(),
		"delta": counterEvent.GetDelta(),
		"total": counterEvent.GetTotal(),
	}

	return Event{
		Fields: fields,
		Msg:    "",
	}
}
开发者ID:yacloud-io,项目名称:firehose-to-syslog,代码行数:14,代码来源:events.go

示例7: CounterEvent

func CounterEvent(msg *events.Envelope) Event {
	counterEvent := msg.GetCounterEvent()

	fields := logrus.Fields{
		"origin": msg.GetOrigin(),
		"name":   counterEvent.GetName(),
		"delta":  counterEvent.GetDelta(),
		"total":  counterEvent.GetTotal(),
	}

	return Event{
		Fields: fields,
		Msg:    "",
		Type:   msg.GetEventType().String(),
	}
}
开发者ID:eljuanchosf,项目名称:firehose-to-syslog,代码行数:16,代码来源:events.go

示例8: updateAndReturnValue

func updateAndReturnValue(values map[string]int, event *events.Envelope) int {

	switch event.GetEventType() {
	case events.Envelope_CounterEvent:
		values[event.GetIp()] = int(event.GetCounterEvent().GetTotal())
	case events.Envelope_ValueMetric:
		values[event.GetIp()] = int(event.GetValueMetric().GetValue())
	}

	sum := 0
	for _, v := range values {
		sum += v
	}

	return sum
}
开发者ID:wfernandes,项目名称:firehose-stats,代码行数:16,代码来源:sinkType.go

示例9: listenForEvents

func listenForEvents(origin []string) {
	for {
		buffer := make([]byte, 1024)
		n, _, err := udpListener.ReadFrom(buffer)
		if err != nil {
			return
		}

		if n == 0 {
			panic("Received empty packet")
		}
		envelope := new(events.Envelope)
		err = proto.Unmarshal(buffer[0:n], envelope)
		if err != nil {
			panic(err)
		}

		var eventId = envelope.GetEventType().String()

		tracker := eventTracker{eventType: eventId}

		switch envelope.GetEventType() {
		case events.Envelope_HttpStart:
			tracker.name = envelope.GetHttpStart().GetPeerType().String()
		case events.Envelope_HttpStop:
			tracker.name = envelope.GetHttpStop().GetPeerType().String()
		case events.Envelope_ValueMetric:
			tracker.name = envelope.GetValueMetric().GetName()
		case events.Envelope_CounterEvent:
			tracker.name = envelope.GetCounterEvent().GetName()
		default:
			panic("Unexpected message type")

		}

		if envelope.GetOrigin() != strings.Join(origin, "/") {
			panic("origin not as expected")
		}

		func() {
			lock.Lock()
			defer lock.Unlock()
			receivedEvents = append(receivedEvents, tracker)
		}()
	}
}
开发者ID:benlaplanche,项目名称:emitter,代码行数:46,代码来源:dropsonde_end_to_end_test.go

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

示例11: handleCounter

func (m *MessageAggregator) handleCounter(envelope *events.Envelope) *events.Envelope {
	metrics.BatchIncrementCounter("MessageAggregator.counterEventReceived")

	countID := counterID{
		name:   envelope.GetCounterEvent().GetName(),
		origin: envelope.GetOrigin(),
	}

	newVal := m.counterTotals[countID] + envelope.GetCounterEvent().GetDelta()
	m.counterTotals[countID] = newVal

	envelope.GetCounterEvent().Total = &newVal
	return envelope
}
开发者ID:yingkitw,项目名称:loggregator,代码行数:14,代码来源:message_aggregator.go

示例12:

				return t
			}

			tracksDroppedMessagesAnd := func(itMsg string, delta, total int) {
				It(itMsg, func() {
					var logMessageNotification *events.Envelope
					Eventually(buffer.GetOutputChannel).Should(Receive(&logMessageNotification))
					Expect(logMessageNotification.GetEventType()).To(Equal(events.Envelope_LogMessage))
					Expect(logMessageNotification.GetLogMessage().GetAppId()).To(Equal("fake-app-id"))
					Expect(logMessageNotification.GetLogMessage().GetMessage()).To(ContainSubstring(fmt.Sprintf("Log message output is too high. %d messages dropped (Total %d messages dropped) from doppler to test-sink-name.", delta, total)))

					var counterEventNotification *events.Envelope
					Eventually(buffer.GetOutputChannel).Should(Receive(&counterEventNotification))
					Expect(counterEventNotification.GetEventType()).To(Equal(events.Envelope_CounterEvent))
					counterEvent := counterEventNotification.GetCounterEvent()
					Expect(counterEvent.GetName()).To(Equal("TruncatingBuffer.DroppedMessages"))
					Expect(counterEvent.GetDelta()).To(BeEquivalentTo(delta))
					Expect(counterEvent.GetTotal()).To(BeEquivalentTo(total))

					Eventually(func() uint64 { return receiveDroppedMessages() }).Should(BeEquivalentTo(total))
				})

			}

			BeforeEach(func() {
				fakeEventEmitter = fake.NewFakeEventEmitter("doppler")
				sender := metric_sender.NewMetricSender(fakeEventEmitter)
				batcher := metricbatcher.New(sender, time.Millisecond)

				metrics.Initialize(sender, batcher)
开发者ID:yingkitw,项目名称:loggregator,代码行数:30,代码来源:truncating_buffer_test.go

示例13: expectCorrectCounterNameDeltaAndTotal

func expectCorrectCounterNameDeltaAndTotal(outputMessage *events.Envelope, name string, delta uint64, total uint64) {
	Expect(outputMessage.GetCounterEvent().GetName()).To(Equal(name))
	Expect(outputMessage.GetCounterEvent().GetDelta()).To(Equal(delta))
	Expect(outputMessage.GetCounterEvent().GetTotal()).To(Equal(total))
}
开发者ID:kei-yamazaki,项目名称:loggregator,代码行数:5,代码来源:message_aggregator_test.go

示例14:

					var eventId = envelope.GetEventType().String()

					tracker := eventTracker{eventType: eventId}

					switch envelope.GetEventType() {
					case events.Envelope_HttpStart:
						tracker.name = envelope.GetHttpStart().GetPeerType().String()
					case events.Envelope_HttpStop:
						tracker.name = envelope.GetHttpStop().GetPeerType().String()
					case events.Envelope_Heartbeat:
						tracker.name = envelope.GetHeartbeat().GetControlMessageIdentifier().String()
					case events.Envelope_ValueMetric:
						tracker.name = envelope.GetValueMetric().GetName()
					case events.Envelope_CounterEvent:
						tracker.name = envelope.GetCounterEvent().GetName()
					default:
						panic("Unexpected message type")

					}

					if envelope.GetOrigin() != strings.Join(origin, "/") {
						panic("origin not as expected")
					}

					func() {
						lock.Lock()
						defer lock.Unlock()
						receivedEvents = append(receivedEvents, tracker)
					}()
				}
开发者ID:davidwadden,项目名称:lattice-release,代码行数:30,代码来源:dropsonde_end_to_end_test.go

示例15: processCounterEvent

func (metrics *metrics) processCounterEvent(metric *events.Envelope) {
	eventName := metric.GetCounterEvent().GetName()
	count := metrics.metricsByName[eventName]
	metrics.metricsByName[eventName] = count + float64(metric.GetCounterEvent().GetDelta())
}
开发者ID:khj0651,项目名称:loggregator,代码行数:5,代码来源:metrics.go


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