Skip to content

Commit

Permalink
Fix Jaeger exporter status conversion (#2440)
Browse files Browse the repository at this point in the history
* Fix Jaeger exporter status conversion

The status tag needs to be a string of value `ERROR` or `OK` for Error
and Ok statuses respectively according to the OTel spec.

* Add PR number to changelog
  • Loading branch information
MrAlias committed Dec 10, 2021
1 parent 9312664 commit b46019a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
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

0 comments on commit b46019a

Please sign in to comment.