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