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

Update precedence of event name in Jaeger exporter #1768

Merged
merged 5 commits into from
Apr 2, 2021
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- The `Span.IsRecording` implementation from `go.opentelemetry.io/otel/sdk/trace` always returns false when not being sampled. (#1750)
- The Jaeger exporter now correctly sets tags for the Span status code and message.
This means it uses the correct tag keys (`"otel.status_code"`, `"otel.status_description"`) and does not set the status message as a tag unless it is set on the span. (#1761)
- The Jaeger exporter now correctly records Span event's names using the `"event"` key for a tag.
Additionally, this tag is overridden, as specified in the OTel specification, if the event contains an attribute with that key. (#1768)

### Changed

Expand Down
13 changes: 11 additions & 2 deletions exporters/trace/jaeger/jaeger.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const (
keySpanKind = "span.kind"
keyStatusCode = "otel.status_code"
keyStatusMessage = "otel.status_description"
keyEventName = "event"
)

type Option func(*options)
Expand Down Expand Up @@ -290,14 +291,22 @@ func spanSnapshotToThrift(ss *export.SpanSnapshot) *gen.Span {

var logs []*gen.Log
for _, a := range ss.MessageEvents {
fields := make([]*gen.Tag, 0, len(a.Attributes))
nTags := len(a.Attributes)
if a.Name != "" {
nTags++
}
fields := make([]*gen.Tag, 0, nTags)
if a.Name != "" {
// If an event contains an attribute with the same key, it needs
// to be given precedence and overwrite this.
fields = append(fields, getStringTag(keyEventName, a.Name))
}
for _, kv := range a.Attributes {
tag := keyValueToTag(kv)
if tag != nil {
fields = append(fields, tag)
}
}
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 exporters/trace/jaeger/jaeger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,13 +473,13 @@ func Test_spanSnapshotToThrift(t *testing.T) {
Timestamp: now.UnixNano() / 1000,
Fields: []*gen.Tag{
{
Key: "k1",
VStr: &keyValue,
Key: keyEventName,
VStr: &eventNameValue,
VType: gen.TagType_STRING,
},
{
Key: "name",
VStr: &eventNameValue,
Key: "k1",
VStr: &keyValue,
VType: gen.TagType_STRING,
},
},
Expand Down