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


Golang Envelope.HttpStartStop方法代码示例

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


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

示例1: SendEvent

func (f *FakeFirehose) SendEvent(eventType events.Envelope_EventType, message string) {
	envelope := events.Envelope{
		Origin:     proto.String("origin"),
		Timestamp:  proto.Int64(1000000000),
		Deployment: proto.String("deployment-name"),
		Job:        proto.String("doppler"),
	}

	switch eventType {
	case events.Envelope_LogMessage:
		envelope.EventType = events.Envelope_LogMessage.Enum()
		envelope.LogMessage = &events.LogMessage{
			Message:     []byte(message),
			MessageType: events.LogMessage_OUT.Enum(),
			Timestamp:   proto.Int64(1000000000),
		}
	case events.Envelope_ValueMetric:
		envelope.EventType = events.Envelope_ValueMetric.Enum()
		envelope.ValueMetric = &events.ValueMetric{
			Name:  proto.String(message),
			Value: proto.Float64(42),
			Unit:  proto.String("unit"),
		}
	case events.Envelope_CounterEvent:
		envelope.EventType = events.Envelope_CounterEvent.Enum()
		envelope.CounterEvent = &events.CounterEvent{
			Name:  proto.String(message),
			Delta: proto.Uint64(42),
		}
	case events.Envelope_ContainerMetric:
		envelope.EventType = events.Envelope_ContainerMetric.Enum()
		envelope.ContainerMetric = &events.ContainerMetric{
			ApplicationId: proto.String(message),
			InstanceIndex: proto.Int32(1),
			CpuPercentage: proto.Float64(1),
			MemoryBytes:   proto.Uint64(1),
			DiskBytes:     proto.Uint64(1),
		}
	case events.Envelope_Error:
		envelope.EventType = events.Envelope_Error.Enum()
		envelope.Error = &events.Error{
			Source:  proto.String("source"),
			Code:    proto.Int32(404),
			Message: proto.String(message),
		}
	case events.Envelope_HttpStart:
		envelope.EventType = events.Envelope_HttpStart.Enum()
		uuid, _ := uuid.NewV4()
		envelope.HttpStart = &events.HttpStart{
			Timestamp:     proto.Int64(12),
			RequestId:     NewUUID(uuid),
			PeerType:      events.PeerType_Client.Enum(),
			Method:        events.Method_GET.Enum(),
			Uri:           proto.String("some uri"),
			RemoteAddress: proto.String("some address"),
			UserAgent:     proto.String(message),
		}
	case events.Envelope_HttpStop:
		envelope.EventType = events.Envelope_HttpStop.Enum()
		uuid, _ := uuid.NewV4()
		envelope.HttpStop = &events.HttpStop{
			Timestamp:     proto.Int64(12),
			Uri:           proto.String("http://stop.example.com"),
			RequestId:     NewUUID(uuid),
			PeerType:      events.PeerType_Client.Enum(),
			StatusCode:    proto.Int32(404),
			ContentLength: proto.Int64(98475189),
		}
	case events.Envelope_HttpStartStop:
		envelope.EventType = events.Envelope_HttpStartStop.Enum()
		uuid, _ := uuid.NewV4()
		envelope.HttpStartStop = &events.HttpStartStop{
			StartTimestamp: proto.Int64(1234),
			StopTimestamp:  proto.Int64(5555),
			RequestId:      NewUUID(uuid),
			PeerType:       events.PeerType_Server.Enum(),
			Method:         events.Method_GET.Enum(),
			Uri:            proto.String("http://startstop.example.com"),
			RemoteAddress:  proto.String("http://startstop.example.com"),
			UserAgent:      proto.String("test"),
			StatusCode:     proto.Int32(1234),
			ContentLength:  proto.Int64(5678),
			ApplicationId:  NewUUID(uuid),
		}

	}

	f.addEvent(envelope)
}
开发者ID:cloudfoundry,项目名称:firehose-plugin,代码行数:89,代码来源:fake_firehose.go


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