本文整理汇总了Golang中github.com/cloudfoundry/sonde-go/events.Envelope.GetOrigin方法的典型用法代码示例。如果您正苦于以下问题:Golang Envelope.GetOrigin方法的具体用法?Golang Envelope.GetOrigin怎么用?Golang Envelope.GetOrigin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/sonde-go/events.Envelope
的用法示例。
在下文中一共展示了Envelope.GetOrigin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: dopplerReceivedMessageCount
func dopplerReceivedMessageCount(msg *events.Envelope) bool {
return msg.GetEventType() == events.Envelope_CounterEvent &&
(msg.CounterEvent.GetName() == "udpListener.receivedMessageCount" ||
msg.CounterEvent.GetName() == "tcpListener.receivedMessageCount" ||
msg.CounterEvent.GetName() == "tlsListener.receivedMessageCount") &&
msg.GetOrigin() == "DopplerServer"
}
示例2: HttpStartStop
func HttpStartStop(msg *events.Envelope) Event {
httpStartStop := msg.GetHttpStartStop()
fields := logrus.Fields{
"origin": msg.GetOrigin(),
"cf_app_id": httpStartStop.GetApplicationId(),
"content_length": httpStartStop.GetContentLength(),
"instance_id": httpStartStop.GetInstanceId(),
"instance_index": httpStartStop.GetInstanceIndex(),
"method": httpStartStop.GetMethod(),
"parent_request_id": httpStartStop.GetParentRequestId(),
"peer_type": httpStartStop.GetPeerType(),
"remote_addr": httpStartStop.GetRemoteAddress(),
"request_id": httpStartStop.GetRequestId(),
"start_timestamp": httpStartStop.GetStartTimestamp(),
"status_code": httpStartStop.GetStatusCode(),
"stop_timestamp": httpStartStop.GetStopTimestamp(),
"uri": httpStartStop.GetUri(),
"user_agent": httpStartStop.GetUserAgent(),
"duration_ms": (((httpStartStop.GetStopTimestamp() - httpStartStop.GetStartTimestamp()) / 1000) / 1000),
}
return Event{
Fields: fields,
Msg: "",
Type: msg.GetEventType().String(),
}
}
示例3: AnnotateWithEnveloppeData
func (e *Event) AnnotateWithEnveloppeData(msg *events.Envelope) {
e.Fields["origin"] = msg.GetOrigin()
e.Fields["deployment"] = msg.GetDeployment()
e.Fields["ip"] = msg.GetIp()
e.Fields["job"] = msg.GetJob()
e.Fields["index"] = msg.GetIndex()
//e.Fields["tags"] = msg.GetTags()
e.Type = msg.GetEventType().String()
}
示例4: handleMessage
func (m *MetricsNozzle) handleMessage(envelope *events.Envelope) {
if m.config.OriginID != "" {
if envelope.GetOrigin() == m.config.OriginID {
fmt.Fprintf(m.stdout, "%v \n", envelope)
}
} else {
fmt.Fprintf(m.stdout, "%v \n", envelope)
}
}
示例5: checkValueMetric
func checkValueMetric(receivedEnvelope *events.Envelope, origin string, name string, value float64, unit string) {
Expect(receivedEnvelope.GetEventType()).To(Equal(events.Envelope_ValueMetric))
Expect(receivedEnvelope.GetOrigin()).To(Equal(origin))
vm := receivedEnvelope.GetValueMetric()
Expect(vm.GetName()).To(Equal(name))
Expect(vm.GetValue()).To(BeNumerically("==", value))
Expect(vm.GetUnit()).To(Equal(unit))
}
示例6: 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")
}
}
示例7: 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
}
示例8: ForChart
func (s *SinkTypeChart) ForChart(event *events.Envelope) bool {
if event.GetEventType() != events.Envelope_ValueMetric {
return false
}
if !contains(event.GetOrigin(), s.validOrigins) {
return false
}
if !contains(event.GetValueMetric().GetName(), s.validMetricNames) {
return false
}
// s.cfUI.Say("%f ", event.GetValueMetric().GetValue())
return true
}
示例9: 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
}
示例10: ErrorEvent
func ErrorEvent(msg *events.Envelope) Event {
errorEvent := msg.GetError()
fields := logrus.Fields{
"origin": msg.GetOrigin(),
"code": errorEvent.GetCode(),
"delta": errorEvent.GetSource(),
}
return Event{
Fields: fields,
Msg: errorEvent.GetMessage(),
Type: msg.GetEventType().String(),
}
}
示例11: 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(),
}
}
示例12: ValueMetric
func ValueMetric(msg *events.Envelope) Event {
valMetric := msg.GetValueMetric()
fields := logrus.Fields{
"origin": msg.GetOrigin(),
"name": valMetric.GetName(),
"unit": valMetric.GetUnit(),
"value": valMetric.GetValue(),
}
return Event{
Fields: fields,
Msg: "",
Type: msg.GetEventType().String(),
}
}
示例13: 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)
}()
}
}
示例14: LogMessage
func LogMessage(msg *events.Envelope) Event {
logMessage := msg.GetLogMessage()
fields := logrus.Fields{
"origin": msg.GetOrigin(),
"cf_app_id": logMessage.GetAppId(),
"timestamp": logMessage.GetTimestamp(),
"source_type": logMessage.GetSourceType(),
"message_type": logMessage.GetMessageType().String(),
"source_instance": logMessage.GetSourceInstance(),
}
return Event{
Fields: fields,
Msg: string(logMessage.GetMessage()),
Type: msg.GetEventType().String(),
}
}
示例15: ContainerMetric
func ContainerMetric(msg *events.Envelope) Event {
containerMetric := msg.GetContainerMetric()
fields := logrus.Fields{
"origin": msg.GetOrigin(),
"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: "",
Type: msg.GetEventType().String(),
}
}