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


Golang Envelope.GetHttpStartStop方法代碼示例

本文整理匯總了Golang中github.com/cloudfoundry/sonde-go/events.Envelope.GetHttpStartStop方法的典型用法代碼示例。如果您正苦於以下問題:Golang Envelope.GetHttpStartStop方法的具體用法?Golang Envelope.GetHttpStartStop怎麽用?Golang Envelope.GetHttpStartStop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/cloudfoundry/sonde-go/events.Envelope的用法示例。


在下文中一共展示了Envelope.GetHttpStartStop方法的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: 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(),
	}
}
開發者ID:eljuanchosf,項目名稱:firehose-to-syslog,代碼行數:28,代碼來源:events.go

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

示例4: processHTTPStartStop

func (metrics *metrics) processHTTPStartStop(metric *events.Envelope) {
	eventName := "requestCount"
	count := metrics.metricsByName[eventName]
	metrics.metricsByName[eventName] = count + 1

	startStop := metric.GetHttpStartStop()
	status := startStop.GetStatusCode()
	switch {
	case status >= 100 && status < 200:
		metrics.metricsByName["responseCount1XX"] = metrics.metricsByName["responseCount1XX"] + 1
	case status >= 200 && status < 300:
		metrics.metricsByName["responseCount2XX"] = metrics.metricsByName["responseCount2XX"] + 1
	case status >= 300 && status < 400:
		metrics.metricsByName["responseCount3XX"] = metrics.metricsByName["responseCount3XX"] + 1
	case status >= 400 && status < 500:
		metrics.metricsByName["responseCount4XX"] = metrics.metricsByName["responseCount4XX"] + 1
	case status >= 500 && status < 600:
		metrics.metricsByName["responseCount5XX"] = metrics.metricsByName["responseCount5XX"] + 1
	default:
	}
}
開發者ID:khj0651,項目名稱:loggregator,代碼行數:21,代碼來源:metrics.go

示例5:

			Expect(mockWriter.Events[2].GetOrigin()).To(Equal("fake-origin-4"))
			expectCorrectCounterNameDeltaAndTotal(mockWriter.Events[2], "counter1", 4, 8)
		})
	})

	Context("single StartStop message", func() {
		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))
	})
開發者ID:khj0651,項目名稱:loggregator,代碼行數:30,代碼來源:message_aggregator_test.go


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