event: add support for custom trace events
This makes Start only use the public API, like all the other common event helpers.
This allows for custon types of trace events.
Change-Id: Id7929c81f7d1f8ba55151750830444ab9cc78247
Reviewed-on: https://go-review.googlesource.com/c/exp/+/333071
Trust: Ian Cottrell <iancottrell@google.com>
Run-TryBot: Ian Cottrell <iancottrell@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
diff --git a/event/common.go b/event/common.go
index fbe002b..4d6dbf8 100644
--- a/event/common.go
+++ b/event/common.go
@@ -70,8 +70,7 @@
if ev != nil {
ev.Labels = append(ev.Labels, String("name", name))
ev.Labels = append(ev.Labels, labels...)
- ev.prepare()
- ev.ctx = newContext(ev.ctx, ev.target.exporter, ev.ID, ev.At)
+ ev.Trace()
ctx = ev.Deliver()
}
return ctx
diff --git a/event/event.go b/event/event.go
index bc9ae85..e5746b0 100644
--- a/event/event.go
+++ b/event/event.go
@@ -104,6 +104,11 @@
return ev2
}
+func (ev *Event) Trace() {
+ ev.prepare()
+ ev.ctx = newContext(ev.ctx, ev.target.exporter, ev.ID, ev.At)
+}
+
// Deliver the event to the exporter that was found in New.
// This also returns the event to the pool, it is an error to do anything
// with the event after it is delivered.