From 727b1dbac287c7c56fae8cca770a0cb6d79126a5 Mon Sep 17 00:00:00 2001 From: rahulpa Date: Mon, 24 Jun 2019 11:44:39 -0700 Subject: [PATCH 1/3] rename Log and Logf interface to AddEvent and AddEventf. - also remove log package. --- api/log/log.go | 66 --------------------------- api/trace/api.go | 6 +-- api/trace/span.go | 21 +++++++-- api/trace/trace.go | 3 +- example/example.go | 5 +- example/http/server/server.go | 3 +- exporter/observer/eventtype_string.go | 4 +- exporter/observer/observer.go | 8 ++-- exporter/reader/format/format.go | 4 +- exporter/reader/reader.go | 12 ++--- plugin/httptrace/clienttrace.go | 6 +-- 11 files changed, 40 insertions(+), 98 deletions(-) delete mode 100644 api/log/log.go diff --git a/api/log/log.go b/api/log/log.go deleted file mode 100644 index 11837586873..00000000000 --- a/api/log/log.go +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2019, OpenTelemetry Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package log - -import ( - "context" - - "github.com/open-telemetry/opentelemetry-go/api/core" - "github.com/open-telemetry/opentelemetry-go/api/scope" - "github.com/open-telemetry/opentelemetry-go/exporter/observer" -) - -type ( - Interface interface { - Log(ctx context.Context, msg string, fields ...core.KeyValue) - Logf(ctx context.Context, fmt string, args ...interface{}) - } - - Logger struct { - scope.Scope - } -) - -func With(scope scope.Scope) Logger { - return Logger{scope} -} - -func Log(ctx context.Context, msg string, fields ...core.KeyValue) { - With(scope.Active(ctx)).Log(ctx, msg, fields...) -} - -func Logf(ctx context.Context, fmt string, args ...interface{}) { - With(scope.Active(ctx)).Logf(ctx, fmt, args...) -} - -func (l Logger) Log(ctx context.Context, msg string, fields ...core.KeyValue) { - observer.Record(observer.Event{ - Type: observer.LOG_EVENT, - Scope: l.ScopeID(), - String: msg, - Attributes: fields, - Context: ctx, - }) -} - -func (l Logger) Logf(ctx context.Context, fmt string, args ...interface{}) { - observer.Record(observer.Event{ - Type: observer.LOGF_EVENT, - Scope: l.ScopeID(), - String: fmt, - Arguments: args, - Context: ctx, - }) -} diff --git a/api/trace/api.go b/api/trace/api.go index 3f09a0a55d1..f0e5e32165a 100644 --- a/api/trace/api.go +++ b/api/trace/api.go @@ -21,7 +21,6 @@ import ( "google.golang.org/grpc/codes" "github.com/open-telemetry/opentelemetry-go/api/core" - "github.com/open-telemetry/opentelemetry-go/api/log" "github.com/open-telemetry/opentelemetry-go/api/scope" "github.com/open-telemetry/opentelemetry-go/api/stats" "github.com/open-telemetry/opentelemetry-go/api/tag" @@ -51,8 +50,6 @@ type ( Span interface { scope.Mutable - log.Interface - stats.Interface SetError(bool) @@ -61,6 +58,9 @@ type ( Finish() + AddEvent(ctx context.Context, msg string, fields ...core.KeyValue) + AddEventf(ctx context.Context, fmt string, args ...interface{}) + // IsRecordingEvents returns true is the span is active and recording events is enabled. IsRecordingEvents() bool diff --git a/api/trace/span.go b/api/trace/span.go index 45546b9a84e..1030a9ceb1e 100644 --- a/api/trace/span.go +++ b/api/trace/span.go @@ -20,7 +20,6 @@ import ( "google.golang.org/grpc/codes" "github.com/open-telemetry/opentelemetry-go/api/core" - "github.com/open-telemetry/opentelemetry-go/api/log" "github.com/open-telemetry/opentelemetry-go/api/stats" "github.com/open-telemetry/opentelemetry-go/exporter/observer" ) @@ -167,12 +166,24 @@ func (sp *span) Tracer() Tracer { return sp.tracer } -func (sp *span) Log(ctx context.Context, msg string, args ...core.KeyValue) { - log.With(sp).Log(ctx, msg, args...) +func (sp *span) AddEvent(ctx context.Context, msg string, attributes ...core.KeyValue) { + + observer.Record(observer.Event{ + Type: observer.ADD_EVENT, + String: msg, + Attributes: attributes, + Context: ctx, + }) } -func (sp *span) Logf(ctx context.Context, fmt string, args ...interface{}) { - log.With(sp).Logf(ctx, fmt, args...) +func (sp *span) AddEventf(ctx context.Context, fmt string, args ...interface{}) { + + observer.Record(observer.Event{ + Type: observer.ADD_EVENTF, + String: fmt, + Arguments: args, + Context: ctx, + }) } func (sp *span) Record(ctx context.Context, m ...core.Measurement) { diff --git a/api/trace/trace.go b/api/trace/trace.go index aa4417eb863..ff76a448b1f 100644 --- a/api/trace/trace.go +++ b/api/trace/trace.go @@ -23,7 +23,6 @@ import ( "google.golang.org/grpc/codes" "github.com/open-telemetry/opentelemetry-go/api/core" - "github.com/open-telemetry/opentelemetry-go/api/log" "github.com/open-telemetry/opentelemetry-go/api/scope" "github.com/open-telemetry/opentelemetry-go/api/tag" "github.com/open-telemetry/opentelemetry-go/exporter/observer" @@ -90,7 +89,7 @@ func (t *tracer) WithSpan(ctx context.Context, name string, body func(context.Co if err := body(ctx); err != nil { span.SetAttribute(ErrorKey.Bool(true)) - log.Log(ctx, "span error", MessageKey.String(err.Error())) + span.AddEvent(ctx, "span error", MessageKey.String(err.Error())) return err } return nil diff --git a/example/example.go b/example/example.go index 16890c33962..8fa78d3ed04 100644 --- a/example/example.go +++ b/example/example.go @@ -17,7 +17,6 @@ package main import ( "context" - "github.com/open-telemetry/opentelemetry-go/api/log" "github.com/open-telemetry/opentelemetry-go/api/metric" "github.com/open-telemetry/opentelemetry-go/api/stats" "github.com/open-telemetry/opentelemetry-go/api/tag" @@ -64,7 +63,7 @@ func main() { trace.SetError(ctx, true) - log.Log(ctx, "Nice operation!", tag.New("bogons").Int(100)) + trace.Active(ctx).AddEvent(ctx, "Nice operation!", tag.New("bogons").Int(100)) trace.Active(ctx).SetAttributes(anotherKey.String("yes")) @@ -76,7 +75,7 @@ func main() { func(ctx context.Context) error { trace.Active(ctx).SetAttribute(lemonsKey.String("five")) - log.Logf(ctx, "Format schmormat %d!", 100) + trace.Active(ctx).AddEventf(ctx, "Format schmormat %d!", 100) stats.Record(ctx, measureTwo.M(1.3)) diff --git a/example/http/server/server.go b/example/http/server/server.go index e9728af9143..0fc64fd4ac9 100644 --- a/example/http/server/server.go +++ b/example/http/server/server.go @@ -19,7 +19,6 @@ import ( "net/http" "github.com/open-telemetry/opentelemetry-go/api/core" - "github.com/open-telemetry/opentelemetry-go/api/log" "github.com/open-telemetry/opentelemetry-go/api/tag" "github.com/open-telemetry/opentelemetry-go/api/trace" "github.com/open-telemetry/opentelemetry-go/plugin/httptrace" @@ -50,7 +49,7 @@ func main() { ) defer span.Finish() - log.Log(ctx, "handling this...") + span.AddEvent(ctx, "handling this...") io.WriteString(w, "Hello, world!\n") } diff --git a/exporter/observer/eventtype_string.go b/exporter/observer/eventtype_string.go index 400906ec55d..2cb7fa713ad 100644 --- a/exporter/observer/eventtype_string.go +++ b/exporter/observer/eventtype_string.go @@ -25,8 +25,8 @@ func _() { _ = x[INVALID-0] _ = x[START_SPAN-1] _ = x[FINISH_SPAN-2] - _ = x[LOG_EVENT-3] - _ = x[LOGF_EVENT-4] + _ = x[ADD_EVENT-3] + _ = x[ADD_EVENTF-4] _ = x[NEW_SCOPE-5] _ = x[NEW_MEASURE-6] _ = x[NEW_METRIC-7] diff --git a/exporter/observer/observer.go b/exporter/observer/observer.go index 2c5558357bb..95029c3c86e 100644 --- a/exporter/observer/observer.go +++ b/exporter/observer/observer.go @@ -40,10 +40,10 @@ type ( // Arguments (type-specific) Attribute core.KeyValue // SET_ATTRIBUTE - Attributes []core.KeyValue // SET_ATTRIBUTES, LOG_EVENT + Attributes []core.KeyValue // SET_ATTRIBUTES, ADD_EVENT Mutator core.Mutator // SET_ATTRIBUTE Mutators []core.Mutator // SET_ATTRIBUTES - Arguments []interface{} // LOGF_EVENT + Arguments []interface{} // ADD_EVENTF Recovered interface{} // FINISH_SPAN Status codes.Code // SET_STATUS @@ -68,8 +68,8 @@ const ( INVALID EventType = iota START_SPAN FINISH_SPAN - LOG_EVENT - LOGF_EVENT + ADD_EVENT + ADD_EVENTF NEW_SCOPE NEW_MEASURE NEW_METRIC diff --git a/exporter/reader/format/format.go b/exporter/reader/format/format.go index 2d924de7126..6466de2df42 100644 --- a/exporter/reader/format/format.go +++ b/exporter/reader/format/format.go @@ -64,10 +64,10 @@ func AppendEvent(buf *strings.Builder, data reader.Event) { buf.WriteString(data.Duration.String()) buf.WriteString(")") - case reader.LOG_EVENT: + case reader.ADD_EVENT: buf.WriteString(data.Message) - case reader.LOGF_EVENT: + case reader.ADD_EVENTF: buf.WriteString(data.Message) case reader.MODIFY_ATTR: diff --git a/exporter/reader/reader.go b/exporter/reader/reader.go index 0686524bcb5..2e53f53fd4a 100644 --- a/exporter/reader/reader.go +++ b/exporter/reader/reader.go @@ -106,8 +106,8 @@ const ( INVALID EventType = iota START_SPAN FINISH_SPAN - LOG_EVENT - LOGF_EVENT + ADD_EVENT + ADD_EVENTF MODIFY_ATTR RECORD_STATS SET_STATUS @@ -260,8 +260,8 @@ func (ro *readerObserver) Observe(event observer.Event) { ro.metrics.Store(event.Sequence, metric) return - case observer.LOG_EVENT: - read.Type = LOG_EVENT + case observer.ADD_EVENT: + read.Type = ADD_EVENT read.Message = event.String @@ -271,11 +271,11 @@ func (ro *readerObserver) Observe(event observer.Event) { read.SpanContext = span.spanContext } - case observer.LOGF_EVENT: + case observer.ADD_EVENTF: // TODO: this can't be done lazily, must be done before Record() read.Message = fmt.Sprintf(event.String, event.Arguments...) - read.Type = LOGF_EVENT + read.Type = ADD_EVENTF attrs, span := ro.readScope(event.Scope) read.Attributes = attrs if span != nil { diff --git a/plugin/httptrace/clienttrace.go b/plugin/httptrace/clienttrace.go index f5024e31811..837b0924cd4 100644 --- a/plugin/httptrace/clienttrace.go +++ b/plugin/httptrace/clienttrace.go @@ -150,15 +150,15 @@ func (ct *clientTracer) wroteRequest(info httptrace.WroteRequestInfo) { } func (ct *clientTracer) got100Continue() { - ct.current().Log(ct.Context, "GOT 100 - Continue") + ct.current().AddEvent(ct.Context, "GOT 100 - Continue") } func (ct *clientTracer) wait100Continue() { - ct.current().Log(ct.Context, "GOT 100 - Wait") + ct.current().AddEvent(ct.Context, "GOT 100 - Wait") } func (ct *clientTracer) got1xxResponse(code int, header textproto.MIMEHeader) error { - ct.current().Log(ct.Context, "GOT 1xx", + ct.current().AddEvent(ct.Context, "GOT 1xx", HTTPStatus.Int(code), HTTPHeaderMIME.String(sm2s(header)), ) From 4516c13712759e4ffedb2245cc55ce966872e231 Mon Sep 17 00:00:00 2001 From: rahulpa Date: Mon, 24 Jun 2019 16:19:17 -0700 Subject: [PATCH 2/3] provide only AddEvent interface to Span - Event can be created using Event specific interface. --- api/event/event.go | 57 ++++++++++++++++++++++++++++++++ api/trace/api.go | 5 +-- api/trace/span.go | 20 +++-------- api/trace/trace.go | 3 +- example/example.go | 5 +-- example/http/server/server.go | 3 +- exporter/observer/observer.go | 6 ++-- exporter/reader/format/format.go | 11 +++--- exporter/reader/reader.go | 17 ++-------- plugin/httptrace/clienttrace.go | 9 ++--- 10 files changed, 91 insertions(+), 45 deletions(-) create mode 100644 api/event/event.go diff --git a/api/event/event.go b/api/event/event.go new file mode 100644 index 00000000000..d0fabcc6f35 --- /dev/null +++ b/api/event/event.go @@ -0,0 +1,57 @@ +// Copyright 2019, OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package event + +import ( + "fmt" + + "github.com/open-telemetry/opentelemetry-go/api/core" +) + +type ( + event struct { + message string + attributes []core.KeyValue + } + + // Event interface provides methods to retrieve Event properties. + Event interface { + + // Message interface retrieves message string of the Event. + Message() string + + // Attributes interface returns a copy of attributes associated with the Event. + Attributes() []core.KeyValue + } +) + +// WithAttr creates an Event with Attributes and a message. +// Attributes are immutable. +func WithAttr(msg string, attributes ...core.KeyValue) Event { + return event{message: msg, attributes: attributes} +} + +// WithString creates an Event with formatted string. +func WithString(f string, args ...interface{}) Event { + return event{message: fmt.Sprint(f, args), attributes: nil} +} + +func (e event) Message() string { + return e.message +} + +func (e event) Attributes() []core.KeyValue { + return append(e.attributes[:0:0], e.attributes...) +} diff --git a/api/trace/api.go b/api/trace/api.go index f0e5e32165a..ab900d9b55f 100644 --- a/api/trace/api.go +++ b/api/trace/api.go @@ -21,6 +21,7 @@ import ( "google.golang.org/grpc/codes" "github.com/open-telemetry/opentelemetry-go/api/core" + "github.com/open-telemetry/opentelemetry-go/api/event" "github.com/open-telemetry/opentelemetry-go/api/scope" "github.com/open-telemetry/opentelemetry-go/api/stats" "github.com/open-telemetry/opentelemetry-go/api/tag" @@ -58,8 +59,8 @@ type ( Finish() - AddEvent(ctx context.Context, msg string, fields ...core.KeyValue) - AddEventf(ctx context.Context, fmt string, args ...interface{}) + // AddEvent adds an event to the span. + AddEvent(ctx context.Context, event event.Event) // IsRecordingEvents returns true is the span is active and recording events is enabled. IsRecordingEvents() bool diff --git a/api/trace/span.go b/api/trace/span.go index 1030a9ceb1e..803de35311e 100644 --- a/api/trace/span.go +++ b/api/trace/span.go @@ -20,6 +20,7 @@ import ( "google.golang.org/grpc/codes" "github.com/open-telemetry/opentelemetry-go/api/core" + "github.com/open-telemetry/opentelemetry-go/api/event" "github.com/open-telemetry/opentelemetry-go/api/stats" "github.com/open-telemetry/opentelemetry-go/exporter/observer" ) @@ -166,23 +167,12 @@ func (sp *span) Tracer() Tracer { return sp.tracer } -func (sp *span) AddEvent(ctx context.Context, msg string, attributes ...core.KeyValue) { +func (sp *span) AddEvent(ctx context.Context, event event.Event) { observer.Record(observer.Event{ - Type: observer.ADD_EVENT, - String: msg, - Attributes: attributes, - Context: ctx, - }) -} - -func (sp *span) AddEventf(ctx context.Context, fmt string, args ...interface{}) { - - observer.Record(observer.Event{ - Type: observer.ADD_EVENTF, - String: fmt, - Arguments: args, - Context: ctx, + Type: observer.ADD_EVENT, + Event: event, + Context: ctx, }) } diff --git a/api/trace/trace.go b/api/trace/trace.go index ff76a448b1f..ee2691ce966 100644 --- a/api/trace/trace.go +++ b/api/trace/trace.go @@ -23,6 +23,7 @@ import ( "google.golang.org/grpc/codes" "github.com/open-telemetry/opentelemetry-go/api/core" + "github.com/open-telemetry/opentelemetry-go/api/event" "github.com/open-telemetry/opentelemetry-go/api/scope" "github.com/open-telemetry/opentelemetry-go/api/tag" "github.com/open-telemetry/opentelemetry-go/exporter/observer" @@ -89,7 +90,7 @@ func (t *tracer) WithSpan(ctx context.Context, name string, body func(context.Co if err := body(ctx); err != nil { span.SetAttribute(ErrorKey.Bool(true)) - span.AddEvent(ctx, "span error", MessageKey.String(err.Error())) + span.AddEvent(ctx, event.WithAttr("span error", MessageKey.String(err.Error()))) return err } return nil diff --git a/example/example.go b/example/example.go index 8fa78d3ed04..e7589d6eb0c 100644 --- a/example/example.go +++ b/example/example.go @@ -22,6 +22,7 @@ import ( "github.com/open-telemetry/opentelemetry-go/api/tag" "github.com/open-telemetry/opentelemetry-go/api/trace" + "github.com/open-telemetry/opentelemetry-go/api/event" "github.com/open-telemetry/opentelemetry-go/exporter/loader" ) @@ -63,7 +64,7 @@ func main() { trace.SetError(ctx, true) - trace.Active(ctx).AddEvent(ctx, "Nice operation!", tag.New("bogons").Int(100)) + trace.Active(ctx).AddEvent(ctx, event.WithAttr("Nice operation!", tag.New("bogons").Int(100))) trace.Active(ctx).SetAttributes(anotherKey.String("yes")) @@ -75,7 +76,7 @@ func main() { func(ctx context.Context) error { trace.Active(ctx).SetAttribute(lemonsKey.String("five")) - trace.Active(ctx).AddEventf(ctx, "Format schmormat %d!", 100) + trace.Active(ctx).AddEvent(ctx, event.WithString("Format schmormat %d!", 100)) stats.Record(ctx, measureTwo.M(1.3)) diff --git a/example/http/server/server.go b/example/http/server/server.go index 0fc64fd4ac9..9aa4487bc14 100644 --- a/example/http/server/server.go +++ b/example/http/server/server.go @@ -23,6 +23,7 @@ import ( "github.com/open-telemetry/opentelemetry-go/api/trace" "github.com/open-telemetry/opentelemetry-go/plugin/httptrace" + "github.com/open-telemetry/opentelemetry-go/api/event" _ "github.com/open-telemetry/opentelemetry-go/exporter/loader" ) @@ -49,7 +50,7 @@ func main() { ) defer span.Finish() - span.AddEvent(ctx, "handling this...") + span.AddEvent(ctx, event.WithString("handling this...")) io.WriteString(w, "Hello, world!\n") } diff --git a/exporter/observer/observer.go b/exporter/observer/observer.go index 95029c3c86e..7a93e37b235 100644 --- a/exporter/observer/observer.go +++ b/exporter/observer/observer.go @@ -23,11 +23,13 @@ import ( "google.golang.org/grpc/codes" "github.com/open-telemetry/opentelemetry-go/api/core" + "github.com/open-telemetry/opentelemetry-go/api/event" ) type ( EventType int + // TODO: this Event is confusing with event.Event. Event struct { // Automatic fields Sequence core.EventID // Auto-filled @@ -40,10 +42,10 @@ type ( // Arguments (type-specific) Attribute core.KeyValue // SET_ATTRIBUTE - Attributes []core.KeyValue // SET_ATTRIBUTES, ADD_EVENT + Attributes []core.KeyValue // SET_ATTRIBUTES Mutator core.Mutator // SET_ATTRIBUTE Mutators []core.Mutator // SET_ATTRIBUTES - Arguments []interface{} // ADD_EVENTF + Event event.Event // ADD_EVENT Recovered interface{} // FINISH_SPAN Status codes.Code // SET_STATUS diff --git a/exporter/reader/format/format.go b/exporter/reader/format/format.go index 6466de2df42..f839a1c11d2 100644 --- a/exporter/reader/format/format.go +++ b/exporter/reader/format/format.go @@ -65,10 +65,13 @@ func AppendEvent(buf *strings.Builder, data reader.Event) { buf.WriteString(")") case reader.ADD_EVENT: - buf.WriteString(data.Message) - - case reader.ADD_EVENTF: - buf.WriteString(data.Message) + buf.WriteString("event: ") + buf.WriteString(data.Event.Message()) + buf.WriteString(" (") + for _, kv := range data.Event.Attributes() { + buf.WriteString(" " + kv.Key.Name() + "=" + kv.Value.Emit()) + } + buf.WriteString(")") case reader.MODIFY_ATTR: buf.WriteString("modify attr") diff --git a/exporter/reader/reader.go b/exporter/reader/reader.go index 2e53f53fd4a..ecc3a2fae9b 100644 --- a/exporter/reader/reader.go +++ b/exporter/reader/reader.go @@ -22,6 +22,7 @@ import ( "google.golang.org/grpc/codes" "github.com/open-telemetry/opentelemetry-go/api/core" + "github.com/open-telemetry/opentelemetry-go/api/event" "github.com/open-telemetry/opentelemetry-go/api/metric" "github.com/open-telemetry/opentelemetry-go/api/tag" "github.com/open-telemetry/opentelemetry-go/api/trace" @@ -43,6 +44,7 @@ type ( SpanContext core.SpanContext Tags tag.Map Attributes tag.Map + Event event.Event Stats []Measurement Parent core.SpanContext @@ -107,7 +109,6 @@ const ( START_SPAN FINISH_SPAN ADD_EVENT - ADD_EVENTF MODIFY_ATTR RECORD_STATS SET_STATUS @@ -262,8 +263,7 @@ func (ro *readerObserver) Observe(event observer.Event) { case observer.ADD_EVENT: read.Type = ADD_EVENT - - read.Message = event.String + read.Event = event.Event attrs, span := ro.readScope(event.Scope) read.Attributes = attrs.Apply(core.KeyValue{}, event.Attributes, core.Mutator{}, nil) @@ -271,17 +271,6 @@ func (ro *readerObserver) Observe(event observer.Event) { read.SpanContext = span.spanContext } - case observer.ADD_EVENTF: - // TODO: this can't be done lazily, must be done before Record() - read.Message = fmt.Sprintf(event.String, event.Arguments...) - - read.Type = ADD_EVENTF - attrs, span := ro.readScope(event.Scope) - read.Attributes = attrs - if span != nil { - read.SpanContext = span.spanContext - } - case observer.RECORD_STATS: read.Type = RECORD_STATS diff --git a/plugin/httptrace/clienttrace.go b/plugin/httptrace/clienttrace.go index 837b0924cd4..8425501a865 100644 --- a/plugin/httptrace/clienttrace.go +++ b/plugin/httptrace/clienttrace.go @@ -22,6 +22,7 @@ import ( "strings" "github.com/open-telemetry/opentelemetry-go/api/core" + "github.com/open-telemetry/opentelemetry-go/api/event" "github.com/open-telemetry/opentelemetry-go/api/tag" "github.com/open-telemetry/opentelemetry-go/api/trace" ) @@ -150,18 +151,18 @@ func (ct *clientTracer) wroteRequest(info httptrace.WroteRequestInfo) { } func (ct *clientTracer) got100Continue() { - ct.current().AddEvent(ct.Context, "GOT 100 - Continue") + ct.current().AddEvent(ct.Context, event.WithString("GOT 100 - Continue")) } func (ct *clientTracer) wait100Continue() { - ct.current().AddEvent(ct.Context, "GOT 100 - Wait") + ct.current().AddEvent(ct.Context, event.WithString("GOT 100 - Wait")) } func (ct *clientTracer) got1xxResponse(code int, header textproto.MIMEHeader) error { - ct.current().AddEvent(ct.Context, "GOT 1xx", + ct.current().AddEvent(ct.Context, event.WithAttr("GOT 1xx", HTTPStatus.Int(code), HTTPHeaderMIME.String(sm2s(header)), - ) + )) return nil } From b0a420c44d980b781a6adf587833e1bc1d3edfa3 Mon Sep 17 00:00:00 2001 From: rahulpa Date: Tue, 25 Jun 2019 13:49:26 -0700 Subject: [PATCH 3/3] add var trick for Event interface. --- api/event/event.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/api/event/event.go b/api/event/event.go index d0fabcc6f35..5511e9ccb6d 100644 --- a/api/event/event.go +++ b/api/event/event.go @@ -37,6 +37,8 @@ type ( } ) +var _ Event = (*event)(nil) + // WithAttr creates an Event with Attributes and a message. // Attributes are immutable. func WithAttr(msg string, attributes ...core.KeyValue) Event {