Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename Message in Event to Name #389

Merged
merged 1 commit into from
Dec 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions api/trace/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ type Span interface {
End(options ...EndOption)

// AddEvent adds an event to the span.
AddEvent(ctx context.Context, msg string, attrs ...core.KeyValue)
AddEvent(ctx context.Context, name string, attrs ...core.KeyValue)
// AddEventWithTimestamp adds an event with a custom timestamp
// to the span.
AddEventWithTimestamp(ctx context.Context, timestamp time.Time, msg string, attrs ...core.KeyValue)
AddEventWithTimestamp(ctx context.Context, timestamp time.Time, name string, attrs ...core.KeyValue)

// IsRecording returns true if the span is active and recording events is enabled.
IsRecording() bool
Expand Down
4 changes: 2 additions & 2 deletions api/trace/current_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ func (mockSpan) Tracer() trace.Tracer {
}

// Event does nothing.
func (mockSpan) AddEvent(ctx context.Context, msg string, attrs ...core.KeyValue) {
func (mockSpan) AddEvent(ctx context.Context, name string, attrs ...core.KeyValue) {
}

// AddEventWithTimestamp does nothing.
func (mockSpan) AddEventWithTimestamp(ctx context.Context, timestamp time.Time, msg string, attrs ...core.KeyValue) {
func (mockSpan) AddEventWithTimestamp(ctx context.Context, timestamp time.Time, name string, attrs ...core.KeyValue) {
}
4 changes: 2 additions & 2 deletions api/trace/noop_span.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ func (NoopSpan) Tracer() Tracer {
}

// AddEvent does nothing.
func (NoopSpan) AddEvent(ctx context.Context, msg string, attrs ...core.KeyValue) {
func (NoopSpan) AddEvent(ctx context.Context, name string, attrs ...core.KeyValue) {
}

// AddEventWithTimestamp does nothing.
func (NoopSpan) AddEventWithTimestamp(ctx context.Context, timestamp time.Time, msg string, attrs ...core.KeyValue) {
func (NoopSpan) AddEventWithTimestamp(ctx context.Context, timestamp time.Time, name string, attrs ...core.KeyValue) {
}

// SetName does nothing.
Expand Down
2 changes: 1 addition & 1 deletion api/trace/testtrace/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ import (
// Event encapsulates the properties of calls to AddEvent or AddEventWithTimestamp.
type Event struct {
Timestamp time.Time
Message string
Name string
Attributes map[core.Key]core.Value
}
8 changes: 4 additions & 4 deletions api/trace/testtrace/span.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ func (s *Span) End(opts ...trace.EndOption) {
s.ended = true
}

func (s *Span) AddEvent(ctx context.Context, msg string, attrs ...core.KeyValue) {
s.AddEventWithTimestamp(ctx, time.Now(), msg, attrs...)
func (s *Span) AddEvent(ctx context.Context, name string, attrs ...core.KeyValue) {
s.AddEventWithTimestamp(ctx, time.Now(), name, attrs...)
}

func (s *Span) AddEventWithTimestamp(ctx context.Context, timestamp time.Time, msg string, attrs ...core.KeyValue) {
func (s *Span) AddEventWithTimestamp(ctx context.Context, timestamp time.Time, name string, attrs ...core.KeyValue) {
s.lock.Lock()
defer s.lock.Unlock()

Expand All @@ -89,7 +89,7 @@ func (s *Span) AddEventWithTimestamp(ctx context.Context, timestamp time.Time, m

s.events = append(s.events, Event{
Timestamp: timestamp,
Message: msg,
Name: name,
Attributes: attributes,
})
}
Expand Down
12 changes: 6 additions & 6 deletions api/trace/testtrace/span_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,23 +337,23 @@ func TestSpan(t *testing.T) {
subject, ok := span.(*testtrace.Span)
e.Expect(ok).ToBeTrue()

event1Msg := "event1"
event1Name := "event1"
event1Attributes := []core.KeyValue{
core.Key("event1Attr1").String("foo"),
core.Key("event1Attr2").String("bar"),
}

event1Start := time.Now()
subject.AddEvent(context.Background(), event1Msg, event1Attributes...)
subject.AddEvent(context.Background(), event1Name, event1Attributes...)
event1End := time.Now()

event2Timestamp := time.Now().AddDate(5, 0, 0)
event2Msg := "event1"
event2Name := "event1"
event2Attributes := []core.KeyValue{
core.Key("event2Attr").String("abc"),
}

subject.AddEventWithTimestamp(context.Background(), event2Timestamp, event2Msg, event2Attributes...)
subject.AddEventWithTimestamp(context.Background(), event2Timestamp, event2Name, event2Attributes...)

events := subject.Events()

Expand All @@ -363,7 +363,7 @@ func TestSpan(t *testing.T) {

e.Expect(event1.Timestamp).ToBeTemporally(matchers.AfterOrSameTime, event1Start)
e.Expect(event1.Timestamp).ToBeTemporally(matchers.BeforeOrSameTime, event1End)
e.Expect(event1.Message).ToEqual(event1Msg)
e.Expect(event1.Name).ToEqual(event1Name)

for _, attr := range event1Attributes {
e.Expect(event1.Attributes[attr.Key]).ToEqual(attr.Value)
Expand All @@ -372,7 +372,7 @@ func TestSpan(t *testing.T) {
event2 := events[1]

e.Expect(event2.Timestamp).ToEqual(event2Timestamp)
e.Expect(event2.Message).ToEqual(event2Msg)
e.Expect(event2.Name).ToEqual(event2Name)

for _, attr := range event2Attributes {
e.Expect(event2.Attributes[attr.Key]).ToEqual(attr.Value)
Expand Down
10 changes: 5 additions & 5 deletions bridge/opentracing/internal/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func (t *MockTracer) DeferredContextSetupHook(ctx context.Context, span oteltrac
type MockEvent struct {
CtxAttributes oteldctx.Map
Timestamp time.Time
Msg string
Name string
Attributes oteldctx.Map
}

Expand Down Expand Up @@ -268,15 +268,15 @@ func (s *MockSpan) Tracer() oteltrace.Tracer {
return s.officialTracer
}

func (s *MockSpan) AddEvent(ctx context.Context, msg string, attrs ...otelcore.KeyValue) {
s.AddEventWithTimestamp(ctx, time.Now(), msg, attrs...)
func (s *MockSpan) AddEvent(ctx context.Context, name string, attrs ...otelcore.KeyValue) {
s.AddEventWithTimestamp(ctx, time.Now(), name, attrs...)
}

func (s *MockSpan) AddEventWithTimestamp(ctx context.Context, timestamp time.Time, msg string, attrs ...otelcore.KeyValue) {
func (s *MockSpan) AddEventWithTimestamp(ctx context.Context, timestamp time.Time, name string, attrs ...otelcore.KeyValue) {
s.Events = append(s.Events, MockEvent{
CtxAttributes: oteldctx.FromContext(ctx),
Timestamp: timestamp,
Msg: msg,
Name: name,
Attributes: oteldctx.NewMap(oteldctx.MapUpdate{
MultiKV: attrs,
}),
Expand Down
2 changes: 1 addition & 1 deletion exporter/trace/jaeger/jaeger.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func spanDataToThrift(data *export.SpanData) *gen.Span {
fields = append(fields, tag)
}
}
fields = append(fields, getStringTag("message", a.Message))
fields = append(fields, getStringTag("name", a.Name))
logs = append(logs, &gen.Log{
Timestamp: a.Time.UnixNano() / 1000,
Fields: fields,
Expand Down
8 changes: 4 additions & 4 deletions exporter/trace/jaeger/jaeger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func Test_spanDataToThrift(t *testing.T) {
linkTraceID, _ := core.TraceIDFromHex("0102030405060709090a0b0c0d0e0f11")
linkSpanID, _ := core.SpanIDFromHex("0102030405060709")

messageEventValue := "event-test"
eventNameValue := "event-test"
keyValue := "value"
statusCodeValue := int64(2)
doubleValue := 123.456
Expand Down Expand Up @@ -189,7 +189,7 @@ func Test_spanDataToThrift(t *testing.T) {
key.Uint64("ignored", 123),
},
MessageEvents: []export.Event{
{Message: messageEventValue, Attributes: []core.KeyValue{key.String("k1", keyValue)}, Time: now},
{Name: eventNameValue, Attributes: []core.KeyValue{key.String("k1", keyValue)}, Time: now},
},
Status: codes.Unknown,
},
Expand Down Expand Up @@ -225,8 +225,8 @@ func Test_spanDataToThrift(t *testing.T) {
VType: gen.TagType_STRING,
},
{
Key: "message",
VStr: &messageEventValue,
Key: "name",
VStr: &eventNameValue,
VType: gen.TagType_STRING,
},
},
Expand Down
2 changes: 1 addition & 1 deletion exporter/trace/stackdriver/trace_proto.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func protoFromSpanData(s *export.SpanData, projectID string) *tracepb.Span {
droppedAnnotationsCount = len(es) - i
break
}
annotation := &tracepb.Span_TimeEvent_Annotation{Description: trunc(e.Message, maxAttributeStringValue)}
annotation := &tracepb.Span_TimeEvent_Annotation{Description: trunc(e.Name, maxAttributeStringValue)}
copyAttributes(&annotation.Attributes, e.Attributes)
event := &tracepb.Span_TimeEvent{
Time: timestampProto(e.Time),
Expand Down
8 changes: 4 additions & 4 deletions exporter/trace/stdout/stdout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ func TestExporter_ExportSpan(t *testing.T) {
key.Float64("double", doubleValue),
},
MessageEvents: []export.Event{
{Message: "foo", Attributes: []core.KeyValue{key.String("key", keyValue)}, Time: now},
{Message: "bar", Attributes: []core.KeyValue{key.Float64("double", doubleValue)}, Time: now},
{Name: "foo", Attributes: []core.KeyValue{key.String("key", keyValue)}, Time: now},
{Name: "bar", Attributes: []core.KeyValue{key.Float64("double", doubleValue)}, Time: now},
},
SpanKind: trace.SpanKindInternal,
Status: codes.Unknown,
Expand Down Expand Up @@ -90,7 +90,7 @@ func TestExporter_ExportSpan(t *testing.T) {
`],` +
`"MessageEvents":[` +
`{` +
`"Message":"foo",` +
`"Name":"foo",` +
`"Attributes":[` +
`{` +
`"Key":"key",` +
Expand All @@ -100,7 +100,7 @@ func TestExporter_ExportSpan(t *testing.T) {
`"Time":` + string(expectedSerializedNow) +
`},` +
`{` +
`"Message":"bar",` +
`"Name":"bar",` +
`"Attributes":[` +
`{` +
`"Key":"double",` +
Expand Down
4 changes: 2 additions & 2 deletions internal/trace/mock_span.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ func (ms *MockSpan) Tracer() apitrace.Tracer {
}

// AddEvent does nothing.
func (ms *MockSpan) AddEvent(ctx context.Context, msg string, attrs ...core.KeyValue) {
func (ms *MockSpan) AddEvent(ctx context.Context, name string, attrs ...core.KeyValue) {
}

// AddEvent does nothing.
func (ms *MockSpan) AddEventWithTimestamp(ctx context.Context, timestamp time.Time, msg string, attrs ...core.KeyValue) {
func (ms *MockSpan) AddEventWithTimestamp(ctx context.Context, timestamp time.Time, name string, attrs ...core.KeyValue) {
}
4 changes: 2 additions & 2 deletions sdk/export/trace/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ type SpanData struct {
// Event is used to describe an Event with a message string and set of
// Attributes.
type Event struct {
// Message describes the Event.
Message string
// Name is the name of this event
Name string

// Attributes contains a list of keyvalue pairs.
Attributes []core.KeyValue
Expand Down
12 changes: 6 additions & 6 deletions sdk/trace/span.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,25 +127,25 @@ func (s *span) Tracer() apitrace.Tracer {
return s.tracer
}

func (s *span) AddEvent(ctx context.Context, msg string, attrs ...core.KeyValue) {
func (s *span) AddEvent(ctx context.Context, name string, attrs ...core.KeyValue) {
if !s.IsRecording() {
return
}
s.addEventWithTimestamp(time.Now(), msg, attrs...)
s.addEventWithTimestamp(time.Now(), name, attrs...)
}

func (s *span) AddEventWithTimestamp(ctx context.Context, timestamp time.Time, msg string, attrs ...core.KeyValue) {
func (s *span) AddEventWithTimestamp(ctx context.Context, timestamp time.Time, name string, attrs ...core.KeyValue) {
if !s.IsRecording() {
return
}
s.addEventWithTimestamp(timestamp, msg, attrs...)
s.addEventWithTimestamp(timestamp, name, attrs...)
}

func (s *span) addEventWithTimestamp(timestamp time.Time, msg string, attrs ...core.KeyValue) {
func (s *span) addEventWithTimestamp(timestamp time.Time, name string, attrs ...core.KeyValue) {
s.mu.Lock()
defer s.mu.Unlock()
s.messageEvents.add(export.Event{
Message: msg,
Name: name,
Attributes: attrs,
Time: timestamp,
})
Expand Down
8 changes: 4 additions & 4 deletions sdk/trace/trace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,8 @@ func TestEvents(t *testing.T) {
Name: "Events/span0",
HasRemoteParent: true,
MessageEvents: []export.Event{
{Message: "foo", Attributes: []core.KeyValue{k1v1}},
{Message: "bar", Attributes: []core.KeyValue{k2v2, k3v3}},
{Name: "foo", Attributes: []core.KeyValue{k1v1}},
{Name: "bar", Attributes: []core.KeyValue{k2v2, k3v3}},
},
SpanKind: apitrace.SpanKindInternal,
}
Expand Down Expand Up @@ -472,8 +472,8 @@ func TestEventsOverLimit(t *testing.T) {
ParentSpanID: sid,
Name: "EventsOverLimit/span0",
MessageEvents: []export.Event{
{Message: "foo", Attributes: []core.KeyValue{k1v1}},
{Message: "bar", Attributes: []core.KeyValue{k2v2, k3v3}},
{Name: "foo", Attributes: []core.KeyValue{k1v1}},
{Name: "bar", Attributes: []core.KeyValue{k2v2, k3v3}},
},
DroppedMessageEventCount: 2,
HasRemoteParent: true,
Expand Down