Skip to content

Commit

Permalink
Update OTLP to 0.6.0 and use the new Span Status code
Browse files Browse the repository at this point in the history
Contributes to open-telemetry#1841

TODO: need to use deprecated_code as specified in the OTLP spec.
  • Loading branch information
Tigran Najaryan committed Oct 29, 2020
1 parent 371514c commit 415c639
Show file tree
Hide file tree
Showing 22 changed files with 538 additions and 383 deletions.
8 changes: 8 additions & 0 deletions cmd/pdatagen/internal/trace_structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,14 @@ var spanStatus = &messageStruct{
defaultVal: "StatusCode(0)",
testVal: "StatusCode(1)",
},
&primitiveTypedField{
fieldName: "DeprecatedCode",
originFieldName: "DeprecatedCode",
returnType: "DeprecatedStatusCode",
rawType: "otlptrace.Status_DeprecatedStatusCode",
defaultVal: "DeprecatedStatusCode(0)",
testVal: "DeprecatedStatusCode(1)",
},
&primitiveField{
fieldName: "Message",
originFieldName: "Message",
Expand Down
15 changes: 15 additions & 0 deletions consumer/pdata/generated_trace.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions consumer/pdata/generated_trace_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 32 additions & 19 deletions consumer/pdata/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,29 +130,42 @@ const (
SpanKindCONSUMER = SpanKind(otlptrace.Span_SPAN_KIND_CONSUMER)
)

// DeprecatedStatusCode is the deprecated status code used previously.
// https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/api.md#set-status
type DeprecatedStatusCode otlptrace.Status_DeprecatedStatusCode

const (
DeprecatedStatusCodeOk = DeprecatedStatusCode(otlptrace.Status_DEPRECATED_STATUS_CODE_OK)
DeprecatedStatusCodeCancelled = DeprecatedStatusCode(otlptrace.Status_DEPRECATED_STATUS_CODE_CANCELLED)
DeprecatedStatusCodeUnknownError = DeprecatedStatusCode(otlptrace.Status_DEPRECATED_STATUS_CODE_UNKNOWN_ERROR)
DeprecatedStatusCodeInvalidArgument = DeprecatedStatusCode(otlptrace.Status_DEPRECATED_STATUS_CODE_INVALID_ARGUMENT)
DeprecatedStatusCodeDeadlineExceeded = DeprecatedStatusCode(otlptrace.Status_DEPRECATED_STATUS_CODE_DEADLINE_EXCEEDED)
DeprecatedStatusCodeNotFound = DeprecatedStatusCode(otlptrace.Status_DEPRECATED_STATUS_CODE_NOT_FOUND)
DeprecatedStatusCodeAlreadyExists = DeprecatedStatusCode(otlptrace.Status_DEPRECATED_STATUS_CODE_ALREADY_EXISTS)
DeprecatedStatusCodePermissionDenied = DeprecatedStatusCode(otlptrace.Status_DEPRECATED_STATUS_CODE_PERMISSION_DENIED)
DeprecatedStatusCodeResourceExhausted = DeprecatedStatusCode(otlptrace.Status_DEPRECATED_STATUS_CODE_RESOURCE_EXHAUSTED)
DeprecatedStatusCodeFailedPrecondition = DeprecatedStatusCode(otlptrace.Status_DEPRECATED_STATUS_CODE_FAILED_PRECONDITION)
DeprecatedStatusCodeAborted = DeprecatedStatusCode(otlptrace.Status_DEPRECATED_STATUS_CODE_ABORTED)
DeprecatedStatusCodeOutOfRange = DeprecatedStatusCode(otlptrace.Status_DEPRECATED_STATUS_CODE_OUT_OF_RANGE)
DeprecatedStatusCodeUnimplemented = DeprecatedStatusCode(otlptrace.Status_DEPRECATED_STATUS_CODE_UNIMPLEMENTED)
DeprecatedStatusCodeInternalError = DeprecatedStatusCode(otlptrace.Status_DEPRECATED_STATUS_CODE_INTERNAL_ERROR)
DeprecatedStatusCodeUnavailable = DeprecatedStatusCode(otlptrace.Status_DEPRECATED_STATUS_CODE_UNAVAILABLE)
DeprecatedStatusCodeDataLoss = DeprecatedStatusCode(otlptrace.Status_DEPRECATED_STATUS_CODE_DATA_LOSS)
DeprecatedStatusCodeUnauthenticated = DeprecatedStatusCode(otlptrace.Status_DEPRECATED_STATUS_CODE_UNAUTHENTICATED)
)

func (sc DeprecatedStatusCode) String() string {
return otlptrace.Status_DeprecatedStatusCode(sc).String()
}

// StatusCode mirrors the codes defined at
// https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/api-tracing.md#statuscanonicalcode
// and is numerically equal to Standard GRPC codes https://github.com/grpc/grpc/blob/master/doc/statuscodes.md
// https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/api.md#set-status
type StatusCode otlptrace.Status_StatusCode

const (
StatusCodeOk = StatusCode(otlptrace.Status_STATUS_CODE_OK)
StatusCodeCancelled = StatusCode(otlptrace.Status_STATUS_CODE_CANCELLED)
StatusCodeUnknownError = StatusCode(otlptrace.Status_STATUS_CODE_UNKNOWN_ERROR)
StatusCodeInvalidArgument = StatusCode(otlptrace.Status_STATUS_CODE_INVALID_ARGUMENT)
StatusCodeDeadlineExceeded = StatusCode(otlptrace.Status_STATUS_CODE_DEADLINE_EXCEEDED)
StatusCodeNotFound = StatusCode(otlptrace.Status_STATUS_CODE_NOT_FOUND)
StatusCodeAlreadyExists = StatusCode(otlptrace.Status_STATUS_CODE_ALREADY_EXISTS)
StatusCodePermissionDenied = StatusCode(otlptrace.Status_STATUS_CODE_PERMISSION_DENIED)
StatusCodeResourceExhausted = StatusCode(otlptrace.Status_STATUS_CODE_RESOURCE_EXHAUSTED)
StatusCodeFailedPrecondition = StatusCode(otlptrace.Status_STATUS_CODE_FAILED_PRECONDITION)
StatusCodeAborted = StatusCode(otlptrace.Status_STATUS_CODE_ABORTED)
StatusCodeOutOfRange = StatusCode(otlptrace.Status_STATUS_CODE_OUT_OF_RANGE)
StatusCodeUnimplemented = StatusCode(otlptrace.Status_STATUS_CODE_UNIMPLEMENTED)
StatusCodeInternalError = StatusCode(otlptrace.Status_STATUS_CODE_INTERNAL_ERROR)
StatusCodeUnavailable = StatusCode(otlptrace.Status_STATUS_CODE_UNAVAILABLE)
StatusCodeDataLoss = StatusCode(otlptrace.Status_STATUS_CODE_DATA_LOSS)
StatusCodeUnauthenticated = StatusCode(otlptrace.Status_STATUS_CODE_UNAUTHENTICATED)
StatusCodeUnset = StatusCode(otlptrace.Status_STATUS_CODE_UNSET)
StatusCodeOk = StatusCode(otlptrace.Status_STATUS_CODE_OK)
StatusCodeError = StatusCode(otlptrace.Status_STATUS_CODE_ERROR)
)

func (sc StatusCode) String() string { return otlptrace.Status_StatusCode(sc).String() }
Loading

0 comments on commit 415c639

Please sign in to comment.