Exemplo n.º 1
0
func (this *TransformExecutor) handleJson(body []byte, logLine *avro.LogLine) error {
	if err := json.Unmarshal(body, logLine); err != nil {
		return err
	}

	// golang's json numbers are always float64's :(
	if logLine.Logtypeid != nil {
		logLine.Logtypeid = int64(logLine.Logtypeid.(float64))
	}

	return nil
}
Exemplo n.º 2
0
func (this *TransformExecutor) protoToAvroLogLine(protoLogLine *pb.LogLine, logLine *avro.LogLine) *avro.LogLine {
	logLine.Line = protoLogLine.GetLine()
	logLine.Source = protoLogLine.GetSource()
	logLine.Logtypeid = protoLogLine.GetLogtypeid()

	logLine.Tag = make(map[string]string)
	for _, tag := range protoLogLine.GetTag() {
		logLine.Tag[tag.GetKey()] = tag.GetValue()
	}

	logLine.Timings = make([]*avro.Timing, 0)
	for _, timing := range protoLogLine.GetTimings() {
		kv := avro.NewTiming()
		kv.EventName = timing.GetEventName()
		kv.Value = timing.GetValue()
		logLine.Timings = append(logLine.Timings, kv)
	}

	return logLine
}