Skip to content
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 @@ -26,6 +26,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
### Fixed

- 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)

### Changed

Expand Down
16 changes: 10 additions & 6 deletions exporters/trace/jaeger/jaeger.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ import (
const (
keyInstrumentationLibraryName = "otel.library.name"
keyInstrumentationLibraryVersion = "otel.library.version"
keyError = "error"
keySpanKind = "span.kind"
keyStatusCode = "otel.status_code"
keyStatusMessage = "otel.status_description"
)

type Option func(*options)
Expand Down Expand Up @@ -269,18 +273,18 @@ func spanSnapshotToThrift(ss *export.SpanSnapshot) *gen.Span {

if ss.SpanKind != trace.SpanKindInternal {
tags = append(tags,
getStringTag("span.kind", ss.SpanKind.String()),
getStringTag(keySpanKind, ss.SpanKind.String()),
)
}

if ss.StatusCode != codes.Unset {
tags = append(tags,
getInt64Tag("status.code", int64(ss.StatusCode)),
getStringTag("status.message", ss.StatusMessage),
)
tags = append(tags, getInt64Tag(keyStatusCode, int64(ss.StatusCode)))
if ss.StatusMessage != "" {
tags = append(tags, getStringTag(keyStatusMessage, ss.StatusMessage))
}

if ss.StatusCode == codes.Error {
tags = append(tags, getBoolTag("error", true))
tags = append(tags, getBoolTag(keyError, true))
}
}

Expand Down
56 changes: 45 additions & 11 deletions exporters/trace/jaeger/jaeger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,40 @@ func Test_spanSnapshotToThrift(t *testing.T) {
data *export.SpanSnapshot
want *gen.Span
}{
{
name: "no status description",
data: &export.SpanSnapshot{
SpanContext: trace.NewSpanContext(trace.SpanContextConfig{
TraceID: traceID,
SpanID: spanID,
}),
Name: "/foo",
StartTime: now,
EndTime: now,
StatusCode: codes.Error,
SpanKind: trace.SpanKindClient,
InstrumentationLibrary: instrumentation.Library{
Name: instrLibName,
Version: instrLibVersion,
},
},
want: &gen.Span{
TraceIdLow: 651345242494996240,
TraceIdHigh: 72623859790382856,
SpanId: 72623859790382856,
OperationName: "/foo",
StartTime: now.UnixNano() / 1000,
Duration: 0,
Tags: []*gen.Tag{
{Key: keyError, VType: gen.TagType_BOOL, VBool: &boolTrue},
{Key: keyInstrumentationLibraryName, VType: gen.TagType_STRING, VStr: &instrLibName},
{Key: keyInstrumentationLibraryVersion, VType: gen.TagType_STRING, VStr: &instrLibVersion},
{Key: keyStatusCode, VType: gen.TagType_LONG, VLong: &statusCodeValue},
// Should not have a status message because it was unset
{Key: keySpanKind, VType: gen.TagType_STRING, VStr: &spanKind},
},
},
},
{
name: "no parent",
data: &export.SpanSnapshot{
Expand Down Expand Up @@ -408,12 +442,12 @@ func Test_spanSnapshotToThrift(t *testing.T) {
{Key: "double", VType: gen.TagType_DOUBLE, VDouble: &doubleValue},
{Key: "key", VType: gen.TagType_STRING, VStr: &keyValue},
{Key: "int", VType: gen.TagType_LONG, VLong: &intValue},
{Key: "error", VType: gen.TagType_BOOL, VBool: &boolTrue},
{Key: "otel.library.name", VType: gen.TagType_STRING, VStr: &instrLibName},
{Key: "otel.library.version", VType: gen.TagType_STRING, VStr: &instrLibVersion},
{Key: "status.code", VType: gen.TagType_LONG, VLong: &statusCodeValue},
{Key: "status.message", VType: gen.TagType_STRING, VStr: &statusMessage},
{Key: "span.kind", VType: gen.TagType_STRING, VStr: &spanKind},
{Key: keyError, VType: gen.TagType_BOOL, VBool: &boolTrue},
{Key: keyInstrumentationLibraryName, VType: gen.TagType_STRING, VStr: &instrLibName},
{Key: keyInstrumentationLibraryVersion, VType: gen.TagType_STRING, VStr: &instrLibVersion},
{Key: keyStatusCode, VType: gen.TagType_LONG, VLong: &statusCodeValue},
{Key: keyStatusMessage, VType: gen.TagType_STRING, VStr: &statusMessage},
{Key: keySpanKind, VType: gen.TagType_STRING, VStr: &spanKind},
},
References: []*gen.SpanRef{
{
Expand Down Expand Up @@ -486,8 +520,8 @@ func Test_spanSnapshotToThrift(t *testing.T) {
Tags: []*gen.Tag{
// status code, message and span kind should NOT be populated
{Key: "arr", VType: gen.TagType_STRING, VStr: &arrValue},
{Key: "otel.library.name", VType: gen.TagType_STRING, VStr: &instrLibName},
{Key: "otel.library.version", VType: gen.TagType_STRING, VStr: &instrLibVersion},
{Key: keyInstrumentationLibraryName, VType: gen.TagType_STRING, VStr: &instrLibName},
{Key: keyInstrumentationLibraryVersion, VType: gen.TagType_STRING, VStr: &instrLibVersion},
},
References: []*gen.SpanRef{
{
Expand Down Expand Up @@ -535,8 +569,8 @@ func Test_spanSnapshotToThrift(t *testing.T) {
StartTime: now.UnixNano() / 1000,
Duration: 0,
Tags: []*gen.Tag{
{Key: "otel.library.name", VType: gen.TagType_STRING, VStr: &instrLibName},
{Key: "otel.library.version", VType: gen.TagType_STRING, VStr: &instrLibVersion},
{Key: keyInstrumentationLibraryName, VType: gen.TagType_STRING, VStr: &instrLibName},
{Key: keyInstrumentationLibraryVersion, VType: gen.TagType_STRING, VStr: &instrLibVersion},
},
},
},
Expand Down Expand Up @@ -649,7 +683,7 @@ func TestJaegerBatchList(t *testing.T) {
{
OperationName: "s1",
Tags: []*gen.Tag{
{Key: "span.kind", VType: gen.TagType_STRING, VStr: &spanKind},
{Key: keySpanKind, VType: gen.TagType_STRING, VStr: &spanKind},
},
StartTime: now.UnixNano() / 1000,
},
Expand Down