Skip to content

Commit

Permalink
export status codes to upper case in zipkin exporter
Browse files Browse the repository at this point in the history
  • Loading branch information
NewReStarter committed Oct 18, 2022
1 parent 1cbd4c2 commit 62bd8a8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -22,6 +22,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Slice attributes of `attribute` package are now comparable based on their value, not instance. (#3108 #3252)
- Prometheus exporter will now cumulatively sum histogram buckets. (#3281)
- Export the sum of each histogram datapoint uniquely with the `go.opentelemetry.io/otel/exporters/otlpmetric` exporters. (#3284, #3293)
- Exported `Status` codes in `zipkin` exporter are now upper case. (#3340)

## [1.11.0/0.32.3] 2022-10-12

Expand Down
5 changes: 4 additions & 1 deletion exporters/zipkin/model.go
Expand Up @@ -20,6 +20,7 @@ import (
"fmt"
"net"
"strconv"
"strings"

zkmodel "github.com/openzipkin/zipkin-go/model"

Expand Down Expand Up @@ -209,7 +210,9 @@ func toZipkinTags(data tracesdk.ReadOnlySpan) map[string]string {
}

if data.Status().Code != codes.Unset {
m["otel.status_code"] = data.Status().Code.String()
// zipkin expect to receive upper case STATUS values
// rather than default capitalized ones.
m["otel.status_code"] = strings.ToUpper(data.Status().Code.String())
}

if data.Status().Code == codes.Error {
Expand Down
19 changes: 10 additions & 9 deletions exporters/zipkin/model_test.go
Expand Up @@ -18,6 +18,7 @@ import (
"fmt"
"net"
"strconv"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -409,7 +410,7 @@ func TestModelConversion(t *testing.T) {
"attr1": "42",
"attr2": "bar",
"attr3": "[0,1,2]",
"otel.status_code": "Error",
"otel.status_code": "ERROR",
"error": "404, file not found",
"service.name": "model-test",
"service.version": "0.1.0",
Expand Down Expand Up @@ -452,7 +453,7 @@ func TestModelConversion(t *testing.T) {
Tags: map[string]string{
"attr1": "42",
"attr2": "bar",
"otel.status_code": "Error",
"otel.status_code": "ERROR",
"error": "404, file not found",
"service.name": "model-test",
"service.version": "0.1.0",
Expand Down Expand Up @@ -495,7 +496,7 @@ func TestModelConversion(t *testing.T) {
Tags: map[string]string{
"attr1": "42",
"attr2": "bar",
"otel.status_code": "Error",
"otel.status_code": "ERROR",
"error": "404, file not found",
"service.name": "model-test",
"service.version": "0.1.0",
Expand Down Expand Up @@ -538,7 +539,7 @@ func TestModelConversion(t *testing.T) {
Tags: map[string]string{
"attr1": "42",
"attr2": "bar",
"otel.status_code": "Error",
"otel.status_code": "ERROR",
"error": "404, file not found",
"service.name": "model-test",
"service.version": "0.1.0",
Expand Down Expand Up @@ -587,7 +588,7 @@ func TestModelConversion(t *testing.T) {
"net.peer.ip": "1.2.3.4",
"net.peer.port": "9876",
"peer.hostname": "test-peer-hostname",
"otel.status_code": "Error",
"otel.status_code": "ERROR",
"error": "404, file not found",
"service.name": "model-test",
"service.version": "0.1.0",
Expand Down Expand Up @@ -630,7 +631,7 @@ func TestModelConversion(t *testing.T) {
Tags: map[string]string{
"attr1": "42",
"attr2": "bar",
"otel.status_code": "Error",
"otel.status_code": "ERROR",
"error": "404, file not found",
"service.name": "model-test",
"service.version": "0.1.0",
Expand Down Expand Up @@ -673,7 +674,7 @@ func TestModelConversion(t *testing.T) {
Tags: map[string]string{
"attr1": "42",
"attr2": "bar",
"otel.status_code": "Error",
"otel.status_code": "ERROR",
"error": "404, file not found",
"service.name": "model-test",
"service.version": "0.1.0",
Expand Down Expand Up @@ -707,7 +708,7 @@ func TestModelConversion(t *testing.T) {
Tags: map[string]string{
"attr1": "42",
"attr2": "bar",
"otel.status_code": "Error",
"otel.status_code": "ERROR",
"error": "404, file not found",
"service.name": "model-test",
"service.version": "0.1.0",
Expand Down Expand Up @@ -823,7 +824,7 @@ func TestTagsTransformation(t *testing.T) {
want: map[string]string{
"error": statusMessage,
"key": keyValue,
"otel.status_code": codes.Error.String(),
"otel.status_code": strings.ToUpper(codes.Error.String()),
},
},
{
Expand Down
4 changes: 2 additions & 2 deletions exporters/zipkin/zipkin_test.go
Expand Up @@ -270,7 +270,7 @@ func TestExportSpans(t *testing.T) {
RemoteEndpoint: nil,
Annotations: nil,
Tags: map[string]string{
"otel.status_code": "Error",
"otel.status_code": "ERROR",
"error": "404, file not found",
"service.name": "exporter-test",
"service.version": "0.1.0",
Expand Down Expand Up @@ -300,7 +300,7 @@ func TestExportSpans(t *testing.T) {
RemoteEndpoint: nil,
Annotations: nil,
Tags: map[string]string{
"otel.status_code": "Error",
"otel.status_code": "ERROR",
"error": "403, forbidden",
"service.name": "exporter-test",
"service.version": "0.1.0",
Expand Down

0 comments on commit 62bd8a8

Please sign in to comment.