func()

in loadgen/eventhandler/apm-collector.go [40:69]


func (a *APMEventCollector) Process(linecopy []byte) event {
	event := event{payload: linecopy}
	result := gjson.ParseBytes(linecopy)
	result.ForEach(func(key, value gjson.Result) bool {
		event.objectType = key.Str // lines look like {"span":{...}}
		timestampResult := value.Get("timestamp")
		if timestampResult.Exists() {
			switch timestampResult.Type {
			case gjson.Number:
				us := timestampResult.Int()
				if us >= 0 {
					s := us / 1000000
					ns := (us - (s * 1000000)) * 1000
					event.timestamp = time.Unix(s, ns)
				}
			case gjson.String:
				tstr := timestampResult.Str
				for _, f := range supportedTSFormats {
					if t, err := time.Parse(f, tstr); err == nil {
						event.timestamp = t
						break
					}
				}
			}
		}
		return false
	})

	return event
}