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

Fix Jaeger exporter status conversion #2440

Merged
merged 2 commits into from Dec 10, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -28,6 +28,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- The `go.opentelemetry.io/otel/exporter/otel/*` exporters are updated to handle per-signal and universal endpoints according to the OpenTelemetry specification.
Any per-signal endpoint set via an `OTEL_EXPORTER_OTLP_<signal>_ENDPOINT` environment variable is now used without modification of the path.
When `OTEL_EXPORTER_OTLP_ENDPOINT` is set, if it contains a path, that path is used as a base path which per-signal paths are appended to. (#2338 #2433)
- The `go.opentelemetry.io/otel/exporter/jaeger` correctly sets the `otel.status_code` value to be a string of `ERROR` or `OK` instead of an integer code. (#2439, #2440)

### Deprecated

Expand Down
12 changes: 7 additions & 5 deletions exporters/jaeger/jaeger.go
Expand Up @@ -147,14 +147,16 @@ func spanToThrift(ss sdktrace.ReadOnlySpan) *gen.Span {
}

if ss.Status().Code != codes.Unset {
tags = append(tags, getInt64Tag(keyStatusCode, int64(ss.Status().Code)))
switch ss.Status().Code {
case codes.Ok:
tags = append(tags, getStringTag(keyStatusCode, "OK"))
case codes.Error:
tags = append(tags, getBoolTag(keyError, true))
tags = append(tags, getStringTag(keyStatusCode, "ERROR"))
}
if ss.Status().Description != "" {
tags = append(tags, getStringTag(keyStatusMessage, ss.Status().Description))
}

if ss.Status().Code == codes.Error {
tags = append(tags, getBoolTag(keyError, true))
}
}

var logs []*gen.Log
Expand Down
6 changes: 3 additions & 3 deletions exporters/jaeger/jaeger_test.go
Expand Up @@ -158,7 +158,7 @@ func Test_spanSnapshotToThrift(t *testing.T) {
eventNameValue := "event-test"
eventDropped := int64(10)
keyValue := "value"
statusCodeValue := int64(1)
statusCodeValue := "ERROR"
doubleValue := 123.456
intValue := int64(123)
boolTrue := true
Expand Down Expand Up @@ -203,7 +203,7 @@ func Test_spanSnapshotToThrift(t *testing.T) {
{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: keyStatusCode, VType: gen.TagType_STRING, VStr: &statusCodeValue},
// Should not have a status message because it was unset
{Key: keySpanKind, VType: gen.TagType_STRING, VStr: &spanKind},
},
Expand Down Expand Up @@ -264,7 +264,7 @@ func Test_spanSnapshotToThrift(t *testing.T) {
{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: keyStatusCode, VType: gen.TagType_STRING, VStr: &statusCodeValue},
{Key: keyStatusMessage, VType: gen.TagType_STRING, VStr: &statusMessage},
{Key: keySpanKind, VType: gen.TagType_STRING, VStr: &spanKind},
},
Expand Down