func EventToProtocolBuffer(event *Event) (*proto.Event, error) {
	if event.Host == "" {
		event.Host, _ = os.Hostname()
	}
	if event.Time.IsZero() {
		event.Time = time.Now()
	}
	var e proto.Event
	e.Host = pb.String(event.Host)
	e.Time = pb.Int64(event.Time.Unix())
	e.TimeMicros = pb.Int64(event.Time.UnixNano() / int64(time.Microsecond))
	if event.Service != "" {
		e.Service = pb.String(event.Service)
	}
	if event.State != "" {
		e.State = pb.String(event.State)
	}
	if event.Description != "" {
		e.Description = pb.String(event.Description)
	}
	e.Tags = event.Tags
	e.Attributes = sortAttributes(
		event.Attributes,
	)
	if event.TTL != 0 {
		e.Ttl = pb.Float32(float32(event.TTL / time.Second))
	}
	if event.Metric != nil {
		switch reflect.TypeOf(event.Metric).Kind() {
		case reflect.Int, reflect.Int32, reflect.Int64:
			e.MetricSint64 = pb.Int64(reflect.ValueOf(event.Metric).Int())
		case reflect.Float32:
			e.MetricD = pb.Float64(reflect.ValueOf(event.Metric).Float())
		case reflect.Float64:
			e.MetricD = pb.Float64(reflect.ValueOf(event.Metric).Float())
		case reflect.Uint, reflect.Uint32, reflect.Uint64:
			e.MetricSint64 = pb.Int64(int64(reflect.ValueOf(event.Metric).Uint()))
		default:
			return nil, fmt.Errorf("Metric of invalid type (type %v)",
				reflect.TypeOf(event.Metric).Kind())
		}
	}
	return &e, nil
}
EventToProtocolBuffer convert an event to a protobuf Event
package riemanngo
import (
	"fmt"
	"os"
	"reflect"
	"sort"
	"time"
	pb "github.com/golang/protobuf/proto"
	"github.com/riemann/riemann-go-client/proto"
)