diff --git a/cmd/pdatagen/internal/base_fields.go b/cmd/pdatagen/internal/base_fields.go index 43d17aaa211..a1d2d2c0d5f 100644 --- a/cmd/pdatagen/internal/base_fields.go +++ b/cmd/pdatagen/internal/base_fields.go @@ -92,6 +92,13 @@ func (ms ${structName}) Set${fieldName}(v ${returnType}) { (*ms.orig).${originFieldName} = ${rawType}(v) }` +const accessorsPrimitiveWithoutSetterTypedTemplate = `// ${fieldName} returns the ${lowerFieldName} associated with this ${structName}. +// +// Important: This causes a runtime error if IsNil() returns "true". +func (ms ${structName}) ${fieldName}() ${returnType} { + return ${returnType}((*ms.orig).${originFieldName}) +}` + type baseField interface { generateAccessors(ms *messageStruct, sb *strings.Builder) @@ -265,10 +272,17 @@ type primitiveTypedField struct { defaultVal string testVal string rawType string + manualSetter bool } func (ptf *primitiveTypedField) generateAccessors(ms *messageStruct, sb *strings.Builder) { - sb.WriteString(os.Expand(accessorsPrimitiveTypedTemplate, func(name string) string { + template := accessorsPrimitiveTypedTemplate + if ptf.manualSetter { + // Generate code without setter. Setter will be manually coded. + template = accessorsPrimitiveWithoutSetterTypedTemplate + } + + sb.WriteString(os.Expand(template, func(name string) string { switch name { case "structName": return ms.structName diff --git a/cmd/pdatagen/internal/trace_structs.go b/cmd/pdatagen/internal/trace_structs.go index 8b228bfd97c..67f3c034799 100644 --- a/cmd/pdatagen/internal/trace_structs.go +++ b/cmd/pdatagen/internal/trace_structs.go @@ -190,6 +190,18 @@ var spanStatus = &messageStruct{ rawType: "otlptrace.Status_StatusCode", defaultVal: "StatusCode(0)", testVal: "StatusCode(1)", + // Generate code without setter. Setter will be manually coded since we + // need to also change DeprecatedCode when Code is changed according + // to OTLP spec https://github.com/open-telemetry/opentelemetry-proto/blob/59c488bfb8fb6d0458ad6425758b70259ff4a2bd/opentelemetry/proto/trace/v1/trace.proto#L231 + manualSetter: true, + }, + &primitiveTypedField{ + fieldName: "DeprecatedCode", + originFieldName: "DeprecatedCode", + returnType: "DeprecatedStatusCode", + rawType: "otlptrace.Status_DeprecatedStatusCode", + defaultVal: "DeprecatedStatusCode(0)", + testVal: "DeprecatedStatusCode(1)", }, &primitiveField{ fieldName: "Message", diff --git a/consumer/pdata/generated_trace.go b/consumer/pdata/generated_trace.go index 5ced62254c5..d9ba5c3215e 100644 --- a/consumer/pdata/generated_trace.go +++ b/consumer/pdata/generated_trace.go @@ -1290,11 +1290,18 @@ func (ms SpanStatus) Code() StatusCode { return StatusCode((*ms.orig).Code) } -// SetCode replaces the code associated with this SpanStatus. +// DeprecatedCode returns the deprecatedcode associated with this SpanStatus. // // Important: This causes a runtime error if IsNil() returns "true". -func (ms SpanStatus) SetCode(v StatusCode) { - (*ms.orig).Code = otlptrace.Status_StatusCode(v) +func (ms SpanStatus) DeprecatedCode() DeprecatedStatusCode { + return DeprecatedStatusCode((*ms.orig).DeprecatedCode) +} + +// SetDeprecatedCode replaces the deprecatedcode associated with this SpanStatus. +// +// Important: This causes a runtime error if IsNil() returns "true". +func (ms SpanStatus) SetDeprecatedCode(v DeprecatedStatusCode) { + (*ms.orig).DeprecatedCode = otlptrace.Status_DeprecatedStatusCode(v) } // Message returns the message associated with this SpanStatus. @@ -1321,5 +1328,6 @@ func (ms SpanStatus) CopyTo(dest SpanStatus) { dest.InitEmpty() } dest.SetCode(ms.Code()) + dest.SetDeprecatedCode(ms.DeprecatedCode()) dest.SetMessage(ms.Message()) } diff --git a/consumer/pdata/generated_trace_test.go b/consumer/pdata/generated_trace_test.go index 6a514968312..333f8dc0db0 100644 --- a/consumer/pdata/generated_trace_test.go +++ b/consumer/pdata/generated_trace_test.go @@ -969,6 +969,15 @@ func TestSpanStatus_Code(t *testing.T) { assert.EqualValues(t, testValCode, ms.Code()) } +func TestSpanStatus_DeprecatedCode(t *testing.T) { + ms := NewSpanStatus() + ms.InitEmpty() + assert.EqualValues(t, DeprecatedStatusCode(0), ms.DeprecatedCode()) + testValDeprecatedCode := DeprecatedStatusCode(1) + ms.SetDeprecatedCode(testValDeprecatedCode) + assert.EqualValues(t, testValDeprecatedCode, ms.DeprecatedCode()) +} + func TestSpanStatus_Message(t *testing.T) { ms := NewSpanStatus() ms.InitEmpty() @@ -1133,5 +1142,6 @@ func generateTestSpanStatus() SpanStatus { func fillTestSpanStatus(tv SpanStatus) { tv.SetCode(StatusCode(1)) + tv.SetDeprecatedCode(DeprecatedStatusCode(1)) tv.SetMessage("cancelled") } diff --git a/consumer/pdata/trace.go b/consumer/pdata/trace.go index 572f4338165..16e23e6dc77 100644 --- a/consumer/pdata/trace.go +++ b/consumer/pdata/trace.go @@ -130,29 +130,70 @@ 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 +// Deprecated: use StatusCode instead. +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() } + +// SetCode replaces the code associated with this SpanStatus. +// +// Important: This causes a runtime error if IsNil() returns "true". +func (ms SpanStatus) SetCode(v StatusCode) { + (*ms.orig).Code = otlptrace.Status_StatusCode(v) + + // According to OTLP spec we also need to set the deprecated_code field. + // See https://github.com/open-telemetry/opentelemetry-proto/blob/59c488bfb8fb6d0458ad6425758b70259ff4a2bd/opentelemetry/proto/trace/v1/trace.proto#L231 + // + // if code==STATUS_CODE_UNSET then `deprecated_code` MUST be + // set to DEPRECATED_STATUS_CODE_OK. + // + // if code==STATUS_CODE_OK then `deprecated_code` MUST be + // set to DEPRECATED_STATUS_CODE_OK. + // + // if code==STATUS_CODE_ERROR then `deprecated_code` MUST be + // set to DEPRECATED_STATUS_CODE_UNKNOWN_ERROR. + switch v { + case StatusCodeUnset: + fallthrough + case StatusCodeOk: + ms.SetDeprecatedCode(DeprecatedStatusCodeOk) + case StatusCodeError: + ms.SetDeprecatedCode(DeprecatedStatusCodeUnknownError) + } +} diff --git a/internal/data/opentelemetry-proto b/internal/data/opentelemetry-proto index 313a868be25..59c488bfb8f 160000 --- a/internal/data/opentelemetry-proto +++ b/internal/data/opentelemetry-proto @@ -1 +1 @@ -Subproject commit 313a868be259dce6c6516dd417d3ad5fd3321acf +Subproject commit 59c488bfb8fb6d0458ad6425758b70259ff4a2bd diff --git a/internal/data/opentelemetry-proto-gen/collector/trace/v1/trace_config.pb.go b/internal/data/opentelemetry-proto-gen/collector/trace/v1/trace_config.pb.go index ab6e04ff346..deebad2314c 100644 --- a/internal/data/opentelemetry-proto-gen/collector/trace/v1/trace_config.pb.go +++ b/internal/data/opentelemetry-proto-gen/collector/trace/v1/trace_config.pb.go @@ -64,7 +64,7 @@ type TraceConfig struct { // // Types that are valid to be assigned to Sampler: // *TraceConfig_ConstantSampler - // *TraceConfig_ProbabilitySampler + // *TraceConfig_TraceIdRatioBased // *TraceConfig_RateLimitingSampler Sampler isTraceConfig_Sampler `protobuf_oneof:"sampler"` // The global default max number of attributes per span. @@ -121,15 +121,15 @@ type isTraceConfig_Sampler interface { type TraceConfig_ConstantSampler struct { ConstantSampler *ConstantSampler `protobuf:"bytes,1,opt,name=constant_sampler,json=constantSampler,proto3,oneof" json:"constant_sampler,omitempty"` } -type TraceConfig_ProbabilitySampler struct { - ProbabilitySampler *ProbabilitySampler `protobuf:"bytes,2,opt,name=probability_sampler,json=probabilitySampler,proto3,oneof" json:"probability_sampler,omitempty"` +type TraceConfig_TraceIdRatioBased struct { + TraceIdRatioBased *TraceIdRatioBased `protobuf:"bytes,2,opt,name=trace_id_ratio_based,json=traceIdRatioBased,proto3,oneof" json:"trace_id_ratio_based,omitempty"` } type TraceConfig_RateLimitingSampler struct { RateLimitingSampler *RateLimitingSampler `protobuf:"bytes,3,opt,name=rate_limiting_sampler,json=rateLimitingSampler,proto3,oneof" json:"rate_limiting_sampler,omitempty"` } func (*TraceConfig_ConstantSampler) isTraceConfig_Sampler() {} -func (*TraceConfig_ProbabilitySampler) isTraceConfig_Sampler() {} +func (*TraceConfig_TraceIdRatioBased) isTraceConfig_Sampler() {} func (*TraceConfig_RateLimitingSampler) isTraceConfig_Sampler() {} func (m *TraceConfig) GetSampler() isTraceConfig_Sampler { @@ -146,9 +146,9 @@ func (m *TraceConfig) GetConstantSampler() *ConstantSampler { return nil } -func (m *TraceConfig) GetProbabilitySampler() *ProbabilitySampler { - if x, ok := m.GetSampler().(*TraceConfig_ProbabilitySampler); ok { - return x.ProbabilitySampler +func (m *TraceConfig) GetTraceIdRatioBased() *TraceIdRatioBased { + if x, ok := m.GetSampler().(*TraceConfig_TraceIdRatioBased); ok { + return x.TraceIdRatioBased } return nil } @@ -199,7 +199,7 @@ func (m *TraceConfig) GetMaxNumberOfAttributesPerLink() int64 { func (*TraceConfig) XXX_OneofWrappers() []interface{} { return []interface{}{ (*TraceConfig_ConstantSampler)(nil), - (*TraceConfig_ProbabilitySampler)(nil), + (*TraceConfig_TraceIdRatioBased)(nil), (*TraceConfig_RateLimitingSampler)(nil), } } @@ -249,25 +249,25 @@ func (m *ConstantSampler) GetDecision() ConstantSampler_ConstantDecision { return ConstantSampler_ALWAYS_OFF } -// Sampler that tries to uniformly sample traces with a given probability. -// The probability of sampling a trace is equal to that of the specified probability. -type ProbabilitySampler struct { - // The desired probability of sampling. Must be within [0.0, 1.0]. - SamplingProbability float64 `protobuf:"fixed64,1,opt,name=samplingProbability,proto3" json:"samplingProbability,omitempty"` +// Sampler that tries to uniformly sample traces with a given ratio. +// The ratio of sampling a trace is equal to that of the specified ratio. +type TraceIdRatioBased struct { + // The desired ratio of sampling. Must be within [0.0, 1.0]. + SamplingRatio float64 `protobuf:"fixed64,1,opt,name=samplingRatio,proto3" json:"samplingRatio,omitempty"` } -func (m *ProbabilitySampler) Reset() { *m = ProbabilitySampler{} } -func (m *ProbabilitySampler) String() string { return proto.CompactTextString(m) } -func (*ProbabilitySampler) ProtoMessage() {} -func (*ProbabilitySampler) Descriptor() ([]byte, []int) { +func (m *TraceIdRatioBased) Reset() { *m = TraceIdRatioBased{} } +func (m *TraceIdRatioBased) String() string { return proto.CompactTextString(m) } +func (*TraceIdRatioBased) ProtoMessage() {} +func (*TraceIdRatioBased) Descriptor() ([]byte, []int) { return fileDescriptor_5936aa8fa6443e6f, []int{2} } -func (m *ProbabilitySampler) XXX_Unmarshal(b []byte) error { +func (m *TraceIdRatioBased) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *ProbabilitySampler) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *TraceIdRatioBased) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_ProbabilitySampler.Marshal(b, m, deterministic) + return xxx_messageInfo_TraceIdRatioBased.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -277,21 +277,21 @@ func (m *ProbabilitySampler) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } -func (m *ProbabilitySampler) XXX_Merge(src proto.Message) { - xxx_messageInfo_ProbabilitySampler.Merge(m, src) +func (m *TraceIdRatioBased) XXX_Merge(src proto.Message) { + xxx_messageInfo_TraceIdRatioBased.Merge(m, src) } -func (m *ProbabilitySampler) XXX_Size() int { +func (m *TraceIdRatioBased) XXX_Size() int { return m.Size() } -func (m *ProbabilitySampler) XXX_DiscardUnknown() { - xxx_messageInfo_ProbabilitySampler.DiscardUnknown(m) +func (m *TraceIdRatioBased) XXX_DiscardUnknown() { + xxx_messageInfo_TraceIdRatioBased.DiscardUnknown(m) } -var xxx_messageInfo_ProbabilitySampler proto.InternalMessageInfo +var xxx_messageInfo_TraceIdRatioBased proto.InternalMessageInfo -func (m *ProbabilitySampler) GetSamplingProbability() float64 { +func (m *TraceIdRatioBased) GetSamplingRatio() float64 { if m != nil { - return m.SamplingProbability + return m.SamplingRatio } return 0 } @@ -346,7 +346,7 @@ func init() { proto.RegisterEnum("opentelemetry.proto.trace.v1.ConstantSampler_ConstantDecision", ConstantSampler_ConstantDecision_name, ConstantSampler_ConstantDecision_value) proto.RegisterType((*TraceConfig)(nil), "opentelemetry.proto.trace.v1.TraceConfig") proto.RegisterType((*ConstantSampler)(nil), "opentelemetry.proto.trace.v1.ConstantSampler") - proto.RegisterType((*ProbabilitySampler)(nil), "opentelemetry.proto.trace.v1.ProbabilitySampler") + proto.RegisterType((*TraceIdRatioBased)(nil), "opentelemetry.proto.trace.v1.TraceIdRatioBased") proto.RegisterType((*RateLimitingSampler)(nil), "opentelemetry.proto.trace.v1.RateLimitingSampler") } @@ -355,42 +355,43 @@ func init() { } var fileDescriptor_5936aa8fa6443e6f = []byte{ - // 554 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0xcd, 0x6e, 0xda, 0x4e, - 0x14, 0xc5, 0x99, 0xf0, 0xcf, 0xd7, 0x8d, 0x92, 0xf8, 0x3f, 0x34, 0x95, 0x15, 0x45, 0x6e, 0xea, - 0x4d, 0xd9, 0x80, 0x43, 0xba, 0xa8, 0xd4, 0x45, 0x25, 0x48, 0x42, 0xbb, 0x40, 0x04, 0x39, 0xa8, - 0x55, 0xd9, 0x58, 0x83, 0x19, 0xac, 0x51, 0xed, 0x19, 0x77, 0x3c, 0x41, 0xc9, 0x03, 0x74, 0xdf, - 0x97, 0xe8, 0x13, 0xf4, 0x25, 0xba, 0xcc, 0xb2, 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2, 0x60, 0xe2, 0x33, 0x28, 0xe8, 0x6b, 0x31, 0x1e, 0x64, 0x54, 0x7d, 0x05, 0xe4, 0xae, 0x92, - 0xec, 0x57, 0x50, 0x58, 0x31, 0x79, 0xd8, 0x80, 0xfc, 0xd7, 0x38, 0xd1, 0xc6, 0xbc, 0x9b, 0x2e, - 0x6b, 0x3f, 0xd0, 0xaf, 0xa1, 0x85, 0x1e, 0x86, 0x16, 0xfa, 0x33, 0xb4, 0xd0, 0xf7, 0x91, 0x95, - 0x7b, 0x18, 0x59, 0xb9, 0xdf, 0x23, 0x2b, 0x07, 0x2f, 0x98, 0x58, 0xfb, 0xeb, 0xd4, 0x8c, 0xcc, - 0x77, 0xde, 0x4a, 0xa5, 0x16, 0xea, 0x7c, 0x0c, 0x16, 0x4d, 0x4c, 0x38, 0xbe, 0x08, 0x43, 0xea, - 0x2b, 0x21, 0x1d, 0xc6, 0x15, 0x95, 0x9c, 0x84, 0x4e, 0x8f, 0x28, 0x32, 0xff, 0x1e, 0x95, 0x34, - 0xbd, 0x14, 0x50, 0x9e, 0xe9, 0x7f, 0x7c, 0x9d, 0xba, 0x5b, 0x5a, 0x7d, 0xfd, 0x37, 0x00, 0x00, - 0xff, 0xff, 0xf6, 0x4f, 0xc0, 0x5d, 0xc4, 0x04, 0x00, 0x00, + // 565 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0xcd, 0x6e, 0xd3, 0x40, + 0x14, 0x85, 0xed, 0x86, 0xfe, 0xdd, 0x2a, 0xad, 0x33, 0x69, 0x91, 0x55, 0x55, 0xa6, 0x58, 0x48, + 0x64, 0x93, 0x58, 0x29, 0x0b, 0x04, 0x0b, 0xa4, 0xa4, 0x3f, 0x14, 0x29, 0x4a, 0x23, 0x37, 0x02, + 0x91, 0x8d, 0x35, 0xb1, 0x27, 0xd6, 0x08, 0x7b, 0x26, 0x8c, 0xa7, 0x51, 0xd9, 0xf3, 0x00, 0xbc, + 0x04, 0x4f, 0xc0, 0x4b, 0xb0, 0xec, 0x92, 0x25, 0x4a, 0x5e, 0x04, 0x79, 0x9c, 0xa6, 0x71, 0xda, + 0x46, 0x62, 0x37, 0x73, 0xce, 0x9c, 0xef, 0xde, 0x49, 0xae, 0x07, 0x1c, 0x3e, 0x24, 0x4c, 0x92, + 0x88, 0xc4, 0x44, 0x8a, 0x6f, 0xce, 0x50, 0x70, 0xc9, 0x1d, 0x29, 0xb0, 0x4f, 0x9c, 0x51, 0x3d, + 0x5b, 0x78, 0x3e, 0x67, 0x03, 0x1a, 0xd6, 0x94, 0x87, 0x0e, 0x72, 0x81, 0x4c, 0xac, 0xa9, 0x73, + 0xb5, 0x51, 0x7d, 0x7f, 0x37, 0xe4, 0x21, 0xcf, 0x20, 0xe9, 0x2a, 0xb3, 0xed, 0xef, 0xab, 0xb0, + 0xd5, 0x4d, 0x8f, 0x1c, 0x2b, 0x12, 0xea, 0x81, 0xe1, 0x73, 0x96, 0x48, 0xcc, 0xa4, 0x97, 0xe0, + 0x78, 0x18, 0x11, 0x61, 0xea, 0x87, 0x7a, 0x65, 0xeb, 0xa8, 0x5a, 0x5b, 0x86, 0xaf, 0x1d, 0x4f, + 0x53, 0x97, 0x59, 0xe8, 0x5c, 0x73, 0x77, 0xfc, 0xbc, 0x84, 0xfa, 0xb0, 0x9b, 0x75, 0x4d, 0x03, + 0x4f, 0x60, 0x49, 0xb9, 0xd7, 0xc7, 0x09, 0x09, 0xcc, 0x15, 0xc5, 0x77, 0x96, 0xf3, 0x55, 0x93, + 0x1f, 0x02, 0x37, 0xcd, 0x35, 0xd3, 0xd8, 0xb9, 0xe6, 0x96, 0xe4, 0xa2, 0x88, 0x42, 0xd8, 0x13, + 0x58, 0x12, 0x2f, 0xa2, 0x31, 0x95, 0x94, 0x85, 0xb3, 0x4b, 0x14, 0x54, 0x91, 0xfa, 0xf2, 0x22, + 0x2e, 0x96, 0xa4, 0x35, 0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0x54, 0x82, 0xe2, 0x74, 0xdb, + 0x69, 0xb8, 0xa7, 0xed, 0xae, 0xb1, 0x62, 0xbf, 0x81, 0xd2, 0xbd, 0xb1, 0x44, 0x2f, 0xa0, 0xa8, + 0x6e, 0x45, 0x59, 0xa8, 0x54, 0xd5, 0xbb, 0xee, 0xe6, 0x45, 0xfb, 0x25, 0x94, 0x1f, 0x18, 0x36, + 0x64, 0x40, 0xe1, 0xeb, 0x30, 0x51, 0x91, 0x82, 0x9b, 0x2e, 0x9b, 0x3f, 0xf5, 0xdf, 0x63, 0x4b, + 0xbf, 0x19, 0x5b, 0xfa, 0xdf, 0xb1, 0xa5, 0xff, 0x98, 0x58, 0xda, 0xcd, 0xc4, 0xd2, 0xfe, 0x4c, + 0x2c, 0x0d, 0x9e, 0x51, 0xbe, 0xf4, 0x07, 0x69, 0x1a, 0x73, 0x5f, 0x76, 0x27, 0xb5, 0x3a, 0x7a, + 0xef, 0x63, 0xb8, 0x18, 0xa2, 0xdc, 0xf1, 0x79, 0x14, 0x11, 0x5f, 0x72, 0xe1, 0x50, 0x26, 0x89, + 0x60, 0x38, 0x72, 0x02, 0x2c, 0x71, 0xfe, 0x05, 0xaa, 0x2a, 0x7a, 0x35, 0x24, 0x6c, 0xee, 0xfc, + 0xed, 0x7b, 0xd4, 0x5f, 0x53, 0xee, 0xab, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x4f, 0xc7, 0xe9, + 0xec, 0xb6, 0x04, 0x00, 0x00, } func (m *TraceConfig) Marshal() (dAtA []byte, err error) { @@ -471,16 +472,16 @@ func (m *TraceConfig_ConstantSampler) MarshalToSizedBuffer(dAtA []byte) (int, er } return len(dAtA) - i, nil } -func (m *TraceConfig_ProbabilitySampler) MarshalTo(dAtA []byte) (int, error) { +func (m *TraceConfig_TraceIdRatioBased) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *TraceConfig_ProbabilitySampler) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *TraceConfig_TraceIdRatioBased) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) - if m.ProbabilitySampler != nil { + if m.TraceIdRatioBased != nil { { - size, err := m.ProbabilitySampler.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.TraceIdRatioBased.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -541,7 +542,7 @@ func (m *ConstantSampler) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *ProbabilitySampler) Marshal() (dAtA []byte, err error) { +func (m *TraceIdRatioBased) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -551,19 +552,19 @@ func (m *ProbabilitySampler) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *ProbabilitySampler) MarshalTo(dAtA []byte) (int, error) { +func (m *TraceIdRatioBased) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ProbabilitySampler) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *TraceIdRatioBased) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.SamplingProbability != 0 { + if m.SamplingRatio != 0 { i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.SamplingProbability)))) + encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.SamplingRatio)))) i-- dAtA[i] = 0x9 } @@ -648,14 +649,14 @@ func (m *TraceConfig_ConstantSampler) Size() (n int) { } return n } -func (m *TraceConfig_ProbabilitySampler) Size() (n int) { +func (m *TraceConfig_TraceIdRatioBased) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.ProbabilitySampler != nil { - l = m.ProbabilitySampler.Size() + if m.TraceIdRatioBased != nil { + l = m.TraceIdRatioBased.Size() n += 1 + l + sovTraceConfig(uint64(l)) } return n @@ -684,13 +685,13 @@ func (m *ConstantSampler) Size() (n int) { return n } -func (m *ProbabilitySampler) Size() (n int) { +func (m *TraceIdRatioBased) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.SamplingProbability != 0 { + if m.SamplingRatio != 0 { n += 9 } return n @@ -780,7 +781,7 @@ func (m *TraceConfig) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProbabilitySampler", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field TraceIdRatioBased", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -807,11 +808,11 @@ func (m *TraceConfig) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - v := &ProbabilitySampler{} + v := &TraceIdRatioBased{} if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } - m.Sampler = &TraceConfig_ProbabilitySampler{v} + m.Sampler = &TraceConfig_TraceIdRatioBased{v} iNdEx = postIndex case 3: if wireType != 2 { @@ -1039,7 +1040,7 @@ func (m *ConstantSampler) Unmarshal(dAtA []byte) error { } return nil } -func (m *ProbabilitySampler) Unmarshal(dAtA []byte) error { +func (m *TraceIdRatioBased) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1062,15 +1063,15 @@ func (m *ProbabilitySampler) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: ProbabilitySampler: wiretype end group for non-group") + return fmt.Errorf("proto: TraceIdRatioBased: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: ProbabilitySampler: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: TraceIdRatioBased: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 1 { - return fmt.Errorf("proto: wrong wireType = %d for field SamplingProbability", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field SamplingRatio", wireType) } var v uint64 if (iNdEx + 8) > l { @@ -1078,7 +1079,7 @@ func (m *ProbabilitySampler) Unmarshal(dAtA []byte) error { } v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) iNdEx += 8 - m.SamplingProbability = float64(math.Float64frombits(v)) + m.SamplingRatio = float64(math.Float64frombits(v)) default: iNdEx = preIndex skippy, err := skipTraceConfig(dAtA[iNdEx:]) diff --git a/internal/data/opentelemetry-proto-gen/trace/v1/trace.pb.go b/internal/data/opentelemetry-proto-gen/trace/v1/trace.pb.go index da336a4ce0b..cc8b4abe467 100644 --- a/internal/data/opentelemetry-proto-gen/trace/v1/trace.pb.go +++ b/internal/data/opentelemetry-proto-gen/trace/v1/trace.pb.go @@ -82,68 +82,100 @@ func (Span_SpanKind) EnumDescriptor() ([]byte, []int) { return fileDescriptor_5c407ac9c675a601, []int{2, 0} } -// StatusCode mirrors the codes defined at -// https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/api-tracing.md#statuscanonicalcode +type Status_DeprecatedStatusCode int32 + +const ( + Status_DEPRECATED_STATUS_CODE_OK Status_DeprecatedStatusCode = 0 + Status_DEPRECATED_STATUS_CODE_CANCELLED Status_DeprecatedStatusCode = 1 + Status_DEPRECATED_STATUS_CODE_UNKNOWN_ERROR Status_DeprecatedStatusCode = 2 + Status_DEPRECATED_STATUS_CODE_INVALID_ARGUMENT Status_DeprecatedStatusCode = 3 + Status_DEPRECATED_STATUS_CODE_DEADLINE_EXCEEDED Status_DeprecatedStatusCode = 4 + Status_DEPRECATED_STATUS_CODE_NOT_FOUND Status_DeprecatedStatusCode = 5 + Status_DEPRECATED_STATUS_CODE_ALREADY_EXISTS Status_DeprecatedStatusCode = 6 + Status_DEPRECATED_STATUS_CODE_PERMISSION_DENIED Status_DeprecatedStatusCode = 7 + Status_DEPRECATED_STATUS_CODE_RESOURCE_EXHAUSTED Status_DeprecatedStatusCode = 8 + Status_DEPRECATED_STATUS_CODE_FAILED_PRECONDITION Status_DeprecatedStatusCode = 9 + Status_DEPRECATED_STATUS_CODE_ABORTED Status_DeprecatedStatusCode = 10 + Status_DEPRECATED_STATUS_CODE_OUT_OF_RANGE Status_DeprecatedStatusCode = 11 + Status_DEPRECATED_STATUS_CODE_UNIMPLEMENTED Status_DeprecatedStatusCode = 12 + Status_DEPRECATED_STATUS_CODE_INTERNAL_ERROR Status_DeprecatedStatusCode = 13 + Status_DEPRECATED_STATUS_CODE_UNAVAILABLE Status_DeprecatedStatusCode = 14 + Status_DEPRECATED_STATUS_CODE_DATA_LOSS Status_DeprecatedStatusCode = 15 + Status_DEPRECATED_STATUS_CODE_UNAUTHENTICATED Status_DeprecatedStatusCode = 16 +) + +var Status_DeprecatedStatusCode_name = map[int32]string{ + 0: "DEPRECATED_STATUS_CODE_OK", + 1: "DEPRECATED_STATUS_CODE_CANCELLED", + 2: "DEPRECATED_STATUS_CODE_UNKNOWN_ERROR", + 3: "DEPRECATED_STATUS_CODE_INVALID_ARGUMENT", + 4: "DEPRECATED_STATUS_CODE_DEADLINE_EXCEEDED", + 5: "DEPRECATED_STATUS_CODE_NOT_FOUND", + 6: "DEPRECATED_STATUS_CODE_ALREADY_EXISTS", + 7: "DEPRECATED_STATUS_CODE_PERMISSION_DENIED", + 8: "DEPRECATED_STATUS_CODE_RESOURCE_EXHAUSTED", + 9: "DEPRECATED_STATUS_CODE_FAILED_PRECONDITION", + 10: "DEPRECATED_STATUS_CODE_ABORTED", + 11: "DEPRECATED_STATUS_CODE_OUT_OF_RANGE", + 12: "DEPRECATED_STATUS_CODE_UNIMPLEMENTED", + 13: "DEPRECATED_STATUS_CODE_INTERNAL_ERROR", + 14: "DEPRECATED_STATUS_CODE_UNAVAILABLE", + 15: "DEPRECATED_STATUS_CODE_DATA_LOSS", + 16: "DEPRECATED_STATUS_CODE_UNAUTHENTICATED", +} + +var Status_DeprecatedStatusCode_value = map[string]int32{ + "DEPRECATED_STATUS_CODE_OK": 0, + "DEPRECATED_STATUS_CODE_CANCELLED": 1, + "DEPRECATED_STATUS_CODE_UNKNOWN_ERROR": 2, + "DEPRECATED_STATUS_CODE_INVALID_ARGUMENT": 3, + "DEPRECATED_STATUS_CODE_DEADLINE_EXCEEDED": 4, + "DEPRECATED_STATUS_CODE_NOT_FOUND": 5, + "DEPRECATED_STATUS_CODE_ALREADY_EXISTS": 6, + "DEPRECATED_STATUS_CODE_PERMISSION_DENIED": 7, + "DEPRECATED_STATUS_CODE_RESOURCE_EXHAUSTED": 8, + "DEPRECATED_STATUS_CODE_FAILED_PRECONDITION": 9, + "DEPRECATED_STATUS_CODE_ABORTED": 10, + "DEPRECATED_STATUS_CODE_OUT_OF_RANGE": 11, + "DEPRECATED_STATUS_CODE_UNIMPLEMENTED": 12, + "DEPRECATED_STATUS_CODE_INTERNAL_ERROR": 13, + "DEPRECATED_STATUS_CODE_UNAVAILABLE": 14, + "DEPRECATED_STATUS_CODE_DATA_LOSS": 15, + "DEPRECATED_STATUS_CODE_UNAUTHENTICATED": 16, +} + +func (x Status_DeprecatedStatusCode) String() string { + return proto.EnumName(Status_DeprecatedStatusCode_name, int32(x)) +} + +func (Status_DeprecatedStatusCode) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_5c407ac9c675a601, []int{3, 0} +} + +// For the semantics of status codes see +// https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/api.md#set-status type Status_StatusCode int32 const ( - Status_STATUS_CODE_OK Status_StatusCode = 0 - Status_STATUS_CODE_CANCELLED Status_StatusCode = 1 - Status_STATUS_CODE_UNKNOWN_ERROR Status_StatusCode = 2 - Status_STATUS_CODE_INVALID_ARGUMENT Status_StatusCode = 3 - Status_STATUS_CODE_DEADLINE_EXCEEDED Status_StatusCode = 4 - Status_STATUS_CODE_NOT_FOUND Status_StatusCode = 5 - Status_STATUS_CODE_ALREADY_EXISTS Status_StatusCode = 6 - Status_STATUS_CODE_PERMISSION_DENIED Status_StatusCode = 7 - Status_STATUS_CODE_RESOURCE_EXHAUSTED Status_StatusCode = 8 - Status_STATUS_CODE_FAILED_PRECONDITION Status_StatusCode = 9 - Status_STATUS_CODE_ABORTED Status_StatusCode = 10 - Status_STATUS_CODE_OUT_OF_RANGE Status_StatusCode = 11 - Status_STATUS_CODE_UNIMPLEMENTED Status_StatusCode = 12 - Status_STATUS_CODE_INTERNAL_ERROR Status_StatusCode = 13 - Status_STATUS_CODE_UNAVAILABLE Status_StatusCode = 14 - Status_STATUS_CODE_DATA_LOSS Status_StatusCode = 15 - Status_STATUS_CODE_UNAUTHENTICATED Status_StatusCode = 16 + // The default status. + Status_STATUS_CODE_UNSET Status_StatusCode = 0 + // The Span has been validated by an Application developers or Operator to have + // completed successfully. + Status_STATUS_CODE_OK Status_StatusCode = 1 + // The Span contains an error. + Status_STATUS_CODE_ERROR Status_StatusCode = 2 ) var Status_StatusCode_name = map[int32]string{ - 0: "STATUS_CODE_OK", - 1: "STATUS_CODE_CANCELLED", - 2: "STATUS_CODE_UNKNOWN_ERROR", - 3: "STATUS_CODE_INVALID_ARGUMENT", - 4: "STATUS_CODE_DEADLINE_EXCEEDED", - 5: "STATUS_CODE_NOT_FOUND", - 6: "STATUS_CODE_ALREADY_EXISTS", - 7: "STATUS_CODE_PERMISSION_DENIED", - 8: "STATUS_CODE_RESOURCE_EXHAUSTED", - 9: "STATUS_CODE_FAILED_PRECONDITION", - 10: "STATUS_CODE_ABORTED", - 11: "STATUS_CODE_OUT_OF_RANGE", - 12: "STATUS_CODE_UNIMPLEMENTED", - 13: "STATUS_CODE_INTERNAL_ERROR", - 14: "STATUS_CODE_UNAVAILABLE", - 15: "STATUS_CODE_DATA_LOSS", - 16: "STATUS_CODE_UNAUTHENTICATED", + 0: "STATUS_CODE_UNSET", + 1: "STATUS_CODE_OK", + 2: "STATUS_CODE_ERROR", } var Status_StatusCode_value = map[string]int32{ - "STATUS_CODE_OK": 0, - "STATUS_CODE_CANCELLED": 1, - "STATUS_CODE_UNKNOWN_ERROR": 2, - "STATUS_CODE_INVALID_ARGUMENT": 3, - "STATUS_CODE_DEADLINE_EXCEEDED": 4, - "STATUS_CODE_NOT_FOUND": 5, - "STATUS_CODE_ALREADY_EXISTS": 6, - "STATUS_CODE_PERMISSION_DENIED": 7, - "STATUS_CODE_RESOURCE_EXHAUSTED": 8, - "STATUS_CODE_FAILED_PRECONDITION": 9, - "STATUS_CODE_ABORTED": 10, - "STATUS_CODE_OUT_OF_RANGE": 11, - "STATUS_CODE_UNIMPLEMENTED": 12, - "STATUS_CODE_INTERNAL_ERROR": 13, - "STATUS_CODE_UNAVAILABLE": 14, - "STATUS_CODE_DATA_LOSS": 15, - "STATUS_CODE_UNAUTHENTICATED": 16, + "STATUS_CODE_UNSET": 0, + "STATUS_CODE_OK": 1, + "STATUS_CODE_ERROR": 2, } func (x Status_StatusCode) String() string { @@ -151,7 +183,7 @@ func (x Status_StatusCode) String() string { } func (Status_StatusCode) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_5c407ac9c675a601, []int{3, 0} + return fileDescriptor_5c407ac9c675a601, []int{3, 1} } // A collection of InstrumentationLibrarySpans from a Resource. @@ -357,9 +389,8 @@ type Span struct { // dropped_links_count is the number of dropped links after the maximum size was // enforced. If this value is 0, then no links were dropped. DroppedLinksCount uint32 `protobuf:"varint,14,opt,name=dropped_links_count,json=droppedLinksCount,proto3" json:"dropped_links_count,omitempty"` - // An optional final status for this span. Semantically when Status - // wasn't set it is means span ended without errors and assume - // Status.Ok (code = 0). + // An optional final status for this span. Semantically when Status isn't set, it means + // span's status code is unset, i.e. assume STATUS_CODE_UNSET (code = 0). Status *Status `protobuf:"bytes,15,opt,name=status,proto3" json:"status,omitempty"` } @@ -632,11 +663,17 @@ func (m *Span_Link) GetDroppedAttributesCount() uint32 { // The Status type defines a logical error model that is suitable for different // programming environments, including REST APIs and RPC APIs. type Status struct { - // The status code. This is optional field. It is safe to assume 0 (OK) - // when not set. - Code Status_StatusCode `protobuf:"varint,1,opt,name=code,proto3,enum=opentelemetry.proto.trace.v1.Status_StatusCode" json:"code,omitempty"` + // The deprecated status code. This is an optional field. + // + // This field is deprecated and is replaced by the `code` field below. See backward + // compatibility notes below. According to our stability guarantees this field + // will be removed in 12 months, on Oct 22, 2021. All usage of old senders and + // receivers that do not understand the `code` field MUST be phased out by then. + DeprecatedCode Status_DeprecatedStatusCode `protobuf:"varint,1,opt,name=deprecated_code,json=deprecatedCode,proto3,enum=opentelemetry.proto.trace.v1.Status_DeprecatedStatusCode" json:"deprecated_code,omitempty"` // Deprecated: Do not use. // A developer-facing human readable error message. Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` + // The status code. + Code Status_StatusCode `protobuf:"varint,3,opt,name=code,proto3,enum=opentelemetry.proto.trace.v1.Status_StatusCode" json:"code,omitempty"` } func (m *Status) Reset() { *m = Status{} } @@ -672,11 +709,12 @@ func (m *Status) XXX_DiscardUnknown() { var xxx_messageInfo_Status proto.InternalMessageInfo -func (m *Status) GetCode() Status_StatusCode { +// Deprecated: Do not use. +func (m *Status) GetDeprecatedCode() Status_DeprecatedStatusCode { if m != nil { - return m.Code + return m.DeprecatedCode } - return Status_STATUS_CODE_OK + return Status_DEPRECATED_STATUS_CODE_OK } func (m *Status) GetMessage() string { @@ -686,8 +724,16 @@ func (m *Status) GetMessage() string { return "" } +func (m *Status) GetCode() Status_StatusCode { + if m != nil { + return m.Code + } + return Status_STATUS_CODE_UNSET +} + func init() { proto.RegisterEnum("opentelemetry.proto.trace.v1.Span_SpanKind", Span_SpanKind_name, Span_SpanKind_value) + proto.RegisterEnum("opentelemetry.proto.trace.v1.Status_DeprecatedStatusCode", Status_DeprecatedStatusCode_name, Status_DeprecatedStatusCode_value) proto.RegisterEnum("opentelemetry.proto.trace.v1.Status_StatusCode", Status_StatusCode_name, Status_StatusCode_value) proto.RegisterType((*ResourceSpans)(nil), "opentelemetry.proto.trace.v1.ResourceSpans") proto.RegisterType((*InstrumentationLibrarySpans)(nil), "opentelemetry.proto.trace.v1.InstrumentationLibrarySpans") @@ -702,80 +748,85 @@ func init() { } var fileDescriptor_5c407ac9c675a601 = []byte{ - // 1163 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x57, 0x4f, 0x6f, 0xdb, 0xc6, - 0x13, 0x35, 0x6d, 0x4a, 0x76, 0xc6, 0xb6, 0xc2, 0x6c, 0xfc, 0x4b, 0x18, 0x3b, 0x91, 0xf5, 0x53, - 0x03, 0x54, 0x6d, 0x10, 0xa9, 0x71, 0x51, 0x20, 0x05, 0x5a, 0xb4, 0x34, 0xb9, 0x4e, 0x08, 0xd3, - 0xa4, 0xb0, 0x24, 0xdd, 0xb4, 0x68, 0x41, 0x30, 0xd6, 0xc2, 0x20, 0x22, 0x2d, 0x0d, 0x92, 0x32, - 0x92, 0x43, 0x2f, 0xbd, 0xf4, 0xda, 0x4b, 0x0e, 0x3d, 0xf6, 0xd3, 0x34, 0xe8, 0x29, 0x97, 0x02, - 0x45, 0x0f, 0x41, 0x91, 0x7c, 0x90, 0x16, 0xbb, 0x24, 0x63, 0x51, 0x71, 0xe4, 0x1c, 0x92, 0x9e, - 0x7a, 0x91, 0x96, 0x33, 0x6f, 0xe6, 0xbd, 0xf9, 0xc3, 0x85, 0x04, 0x9d, 0xf8, 0x88, 0xb2, 0x8c, - 0x0e, 0xe9, 0x88, 0x66, 0xc9, 0xa3, 0xde, 0x51, 0x12, 0x67, 0x71, 0x2f, 0x4b, 0xc2, 0x03, 0xda, - 0x3b, 0xbe, 0x95, 0x1f, 0xba, 0xc2, 0x88, 0xae, 0x56, 0x90, 0xb9, 0xb1, 0x9b, 0x03, 0x8e, 0x6f, - 0xad, 0xaf, 0x1d, 0xc6, 0x87, 0x71, 0x1e, 0xcd, 0x4f, 0xb9, 0x7b, 0xfd, 0xc3, 0xd3, 0xb2, 0x1f, - 0xc4, 0xa3, 0x51, 0xcc, 0x78, 0xfa, 0xfc, 0x54, 0x60, 0xbb, 0xa7, 0x61, 0x13, 0x9a, 0xc6, 0xe3, - 0x24, 0x17, 0x53, 0x9e, 0x73, 0x7c, 0xfb, 0x77, 0x09, 0x56, 0x49, 0x61, 0x72, 0x8f, 0x42, 0x96, - 0x22, 0x0c, 0x4b, 0x25, 0x46, 0x95, 0x5a, 0x52, 0x67, 0x79, 0xeb, 0x83, 0xee, 0x69, 0xa2, 0x5f, - 0x26, 0x3a, 0xbe, 0xd5, 0x2d, 0x33, 0x90, 0x97, 0xa1, 0xe8, 0x7b, 0xb8, 0x16, 0xb1, 0x34, 0x4b, - 0xc6, 0x23, 0xca, 0xb2, 0x30, 0x8b, 0x62, 0x16, 0x0c, 0xa3, 0xfb, 0x49, 0x98, 0x3c, 0x0a, 0x52, - 0xce, 0xa3, 0xce, 0xb7, 0x16, 0x3a, 0xcb, 0x5b, 0x9f, 0x76, 0x67, 0x35, 0xa4, 0x6b, 0x56, 0x53, - 0x58, 0x79, 0x06, 0x21, 0x94, 0x6c, 0x44, 0xaf, 0x77, 0xb6, 0x7f, 0x95, 0x60, 0x63, 0x46, 0x30, - 0x62, 0x70, 0xf9, 0x35, 0xf2, 0x8a, 0xa2, 0x3f, 0x39, 0x55, 0x58, 0xd1, 0xeb, 0xd7, 0x2a, 0x23, - 0x97, 0x4e, 0x17, 0x85, 0x6e, 0x43, 0x6d, 0xb2, 0xec, 0xf6, 0xec, 0xb2, 0xb9, 0x46, 0x92, 0x07, - 0xb4, 0x7f, 0x6c, 0x80, 0xcc, 0x9f, 0xd1, 0x43, 0x58, 0x12, 0x80, 0x20, 0x1a, 0x08, 0x8d, 0x2b, - 0xdb, 0xdf, 0x3d, 0x79, 0xb6, 0x39, 0xf7, 0xe7, 0xb3, 0x4d, 0xff, 0x30, 0x9e, 0xca, 0x17, 0xf1, - 0x05, 0x19, 0x0e, 0xe9, 0x41, 0x16, 0x27, 0xbd, 0x88, 0x65, 0x34, 0x61, 0xe1, 0xb0, 0x37, 0x08, - 0xb3, 0xb0, 0x57, 0x01, 0xde, 0x14, 0xc4, 0x37, 0x0f, 0x29, 0x3b, 0x59, 0xa8, 0xae, 0xc7, 0x59, - 0x4c, 0x83, 0x2c, 0x0a, 0x3a, 0x73, 0x80, 0xc6, 0xb0, 0xc8, 0xb5, 0x70, 0xe2, 0x79, 0x41, 0xfc, - 0x6d, 0x41, 0xec, 0xbd, 0x5d, 0x62, 0x5e, 0xa6, 0x69, 0x90, 0x3a, 0x27, 0x33, 0x07, 0x68, 0x13, - 0x96, 0xf3, 0x82, 0xd3, 0x2c, 0xcc, 0xa8, 0xba, 0xd0, 0x92, 0x3a, 0xe7, 0x08, 0x08, 0x93, 0xcb, - 0x2d, 0xe8, 0x07, 0x09, 0x1a, 0x47, 0x61, 0x42, 0x59, 0x16, 0x94, 0xfa, 0xe4, 0x7f, 0x41, 0xdf, - 0x4a, 0xce, 0xe9, 0xe6, 0x2a, 0x11, 0xc8, 0x2c, 0x1c, 0x51, 0xb5, 0x26, 0xe4, 0x89, 0x33, 0xfa, - 0x02, 0xe4, 0x07, 0x11, 0x1b, 0xa8, 0xf5, 0x96, 0xd4, 0x69, 0x6c, 0xdd, 0x38, 0x7b, 0xd8, 0xe2, - 0x63, 0x37, 0x62, 0x03, 0x22, 0x02, 0x51, 0x0f, 0xd6, 0xd2, 0x2c, 0x4c, 0xb2, 0x20, 0x8b, 0x46, - 0x34, 0x18, 0xb3, 0xe8, 0x61, 0xc0, 0x42, 0x16, 0xab, 0x8b, 0x2d, 0xa9, 0x53, 0x27, 0x17, 0x84, - 0xcf, 0x8b, 0x46, 0xd4, 0x67, 0xd1, 0x43, 0x3b, 0x64, 0x31, 0xba, 0x01, 0x88, 0xb2, 0xc1, 0x34, - 0x7c, 0x49, 0xc0, 0xcf, 0x53, 0x36, 0xa8, 0x80, 0xf7, 0x00, 0xc2, 0x2c, 0x4b, 0xa2, 0xfb, 0xe3, - 0x8c, 0xa6, 0xea, 0x39, 0xb1, 0x91, 0xef, 0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 0x36, 0x61, 0x63, 0x2a, 0xce, 0xf7, 0xee, - 0x62, 0xdb, 0x33, 0x75, 0x8d, 0x13, 0x2b, 0xdb, 0x8f, 0xa5, 0x27, 0xcf, 0x9b, 0xd2, 0xd3, 0xe7, - 0x4d, 0xe9, 0xaf, 0xe7, 0x4d, 0xe9, 0xa7, 0x17, 0xcd, 0xb9, 0xa7, 0x2f, 0x9a, 0x73, 0x7f, 0xbc, - 0x68, 0xce, 0xc1, 0x66, 0x14, 0xcf, 0xdc, 0xc2, 0x6d, 0x10, 0x97, 0x51, 0x9f, 0x1b, 0xfb, 0xd2, - 0x37, 0xd6, 0xdb, 0xb8, 0x6f, 0xca, 0x7f, 0x18, 0xf7, 0xeb, 0xc2, 0xf6, 0xf1, 0x3f, 0x01, 0x00, - 0x00, 0xff, 0xff, 0x28, 0x60, 0xda, 0xae, 0x88, 0x0c, 0x00, 0x00, + // 1235 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x57, 0xb1, 0x6f, 0xdb, 0xc6, + 0x17, 0x16, 0x6d, 0x49, 0x76, 0x9e, 0x6d, 0x99, 0xb9, 0x9f, 0x93, 0x1f, 0xe3, 0x34, 0xb2, 0xa0, + 0xba, 0x89, 0x92, 0x34, 0x52, 0x93, 0xa2, 0x40, 0x0a, 0xb4, 0x68, 0x29, 0xf2, 0x9c, 0x10, 0xa6, + 0x49, 0xe1, 0x48, 0xba, 0x69, 0xd1, 0x82, 0x60, 0xcc, 0xab, 0x41, 0x44, 0x3a, 0x0a, 0x14, 0x65, + 0x24, 0x43, 0x97, 0x2e, 0x5d, 0xbb, 0x74, 0xe8, 0xd8, 0xbf, 0xa6, 0x41, 0xa7, 0x2c, 0x05, 0x8a, + 0x0c, 0x41, 0x91, 0xfc, 0x1b, 0x1d, 0x8a, 0x3b, 0x52, 0xb6, 0xe5, 0x9a, 0x72, 0x86, 0xa4, 0x53, + 0x17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0xe7, 0xe6, 0xd9, + 0x66, 0x8b, 0x3f, 0xdb, 0x11, 0x0b, 0x89, 0x28, 0x44, 0x1d, 0x58, 0x1b, 0xa5, 0x41, 0x92, 0xfa, + 0x69, 0x34, 0xa0, 0xfe, 0x98, 0x45, 0x8f, 0x7d, 0x16, 0xb0, 0x58, 0x59, 0x68, 0x48, 0xad, 0x2a, + 0x39, 0x2f, 0x72, 0x6e, 0x34, 0xa0, 0x1e, 0x8b, 0x1e, 0x5b, 0x01, 0x8b, 0xd1, 0x4d, 0x40, 0x94, + 0x85, 0x27, 0xe1, 0x8b, 0x02, 0xbe, 0x4a, 0x59, 0x38, 0x05, 0xde, 0x01, 0x08, 0xd2, 0x34, 0x89, + 0x1e, 0x8e, 0x53, 0x3a, 0x52, 0xce, 0x89, 0x89, 0xbc, 0x76, 0xc6, 0xbc, 0x6f, 0xd3, 0x27, 0xbb, + 0x41, 0x7f, 0x4c, 0xbb, 0x65, 0x7e, 0xb6, 0xe4, 0x58, 0x03, 0x74, 0x17, 0x94, 0x30, 0x89, 0x87, + 0x43, 0x1a, 0xfa, 0x47, 0x51, 0x7f, 0x2f, 0x1e, 0xb3, 0x54, 0x81, 0x86, 0xd4, 0x5a, 0x21, 0x17, + 0xf3, 0xbc, 0x7a, 0x98, 0xd6, 0x78, 0x16, 0x7d, 0x0e, 0x55, 0x7a, 0x40, 0x59, 0x3a, 0x52, 0x96, + 0x84, 0x88, 0xd6, 0x6b, 0x9c, 0x14, 0xe6, 0x05, 0x24, 0xaf, 0x43, 0x1f, 0xc0, 0xda, 0x84, 0x3b, + 0x8b, 0xe4, 0xbc, 0xcb, 0x82, 0x17, 0xe5, 0x39, 0x51, 0x93, 0x73, 0x7e, 0x0a, 0x95, 0x7e, 0xc4, + 0x1e, 0x8d, 0x94, 0x95, 0x19, 0xfb, 0x9e, 0xa6, 0x34, 0x23, 0xf6, 0x88, 0x64, 0x55, 0xa8, 0x0d, + 0xff, 0x9b, 0x10, 0x8a, 0x40, 0x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xbd, 0xf4, 0xc7, 0xab, 0x7a, 0x09, 0x36, 0xa2, 0x78, 0xe6, 0x05, 0xec, + 0x82, 0xf8, 0x4f, 0xd0, 0xe3, 0xc1, 0x9e, 0xf4, 0x95, 0xf9, 0x26, 0x1e, 0xfb, 0xc9, 0xcf, 0xbb, + 0x87, 0x55, 0x11, 0xfb, 0xf0, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0x59, 0xd4, 0xa2, 0x26, 0x05, + 0x0e, 0x00, 0x00, } func (m *ResourceSpans) Marshal() (dAtA []byte, err error) { @@ -1173,6 +1224,11 @@ func (m *Status) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.Code != 0 { + i = encodeVarintTrace(dAtA, i, uint64(m.Code)) + i-- + dAtA[i] = 0x18 + } if len(m.Message) > 0 { i -= len(m.Message) copy(dAtA[i:], m.Message) @@ -1180,8 +1236,8 @@ func (m *Status) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x12 } - if m.Code != 0 { - i = encodeVarintTrace(dAtA, i, uint64(m.Code)) + if m.DeprecatedCode != 0 { + i = encodeVarintTrace(dAtA, i, uint64(m.DeprecatedCode)) i-- dAtA[i] = 0x8 } @@ -1357,13 +1413,16 @@ func (m *Status) Size() (n int) { } var l int _ = l - if m.Code != 0 { - n += 1 + sovTrace(uint64(m.Code)) + if m.DeprecatedCode != 0 { + n += 1 + sovTrace(uint64(m.DeprecatedCode)) } l = len(m.Message) if l > 0 { n += 1 + l + sovTrace(uint64(l)) } + if m.Code != 0 { + n += 1 + sovTrace(uint64(m.Code)) + } return n } @@ -2452,9 +2511,9 @@ func (m *Status) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Code", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field DeprecatedCode", wireType) } - m.Code = 0 + m.DeprecatedCode = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTrace @@ -2464,7 +2523,7 @@ func (m *Status) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Code |= Status_StatusCode(b&0x7F) << shift + m.DeprecatedCode |= Status_DeprecatedStatusCode(b&0x7F) << shift if b < 0x80 { break } @@ -2501,6 +2560,25 @@ func (m *Status) Unmarshal(dAtA []byte) error { } m.Message = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Code", wireType) + } + m.Code = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTrace + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Code |= Status_StatusCode(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipTrace(dAtA[iNdEx:]) diff --git a/internal/data/testdata/trace.go b/internal/data/testdata/trace.go index 2b88fd8c4c5..b8be8f90412 100644 --- a/internal/data/testdata/trace.go +++ b/internal/data/testdata/trace.go @@ -286,7 +286,7 @@ func fillSpanOne(span pdata.Span) { span.SetDroppedEventsCount(1) status := span.Status() status.InitEmpty() - status.SetCode(pdata.StatusCodeCancelled) + status.SetCode(pdata.StatusCodeError) status.SetMessage("status-cancelled") } @@ -311,8 +311,9 @@ func generateOtlpSpanOne() *otlptrace.Span { }, DroppedEventsCount: 1, Status: &otlptrace.Status{ - Code: otlptrace.Status_STATUS_CODE_CANCELLED, - Message: "status-cancelled", + Code: otlptrace.Status_STATUS_CODE_ERROR, + DeprecatedCode: otlptrace.Status_DEPRECATED_STATUS_CODE_UNKNOWN_ERROR, + Message: "status-cancelled", }, } } diff --git a/internal/goldendataset/pict_tracing_input_defs.go b/internal/goldendataset/pict_tracing_input_defs.go index ecf82492250..1064af6f307 100644 --- a/internal/goldendataset/pict_tracing_input_defs.go +++ b/internal/goldendataset/pict_tracing_input_defs.go @@ -145,6 +145,13 @@ const ( // Enumerates the status values a generated span can be populated with. type PICTInputStatus string +const ( + SpanStatusUnset PICTInputStatus = "Unset" + SpanStatusOk PICTInputStatus = "Ok" + SpanStatusError PICTInputStatus = "Error" +) + +/* const ( SpanStatusNil PICTInputStatus = "Nil" SpanStatusOk PICTInputStatus = "Ok" @@ -165,6 +172,7 @@ const ( SpanStatusDataLoss PICTInputStatus = "DataLoss" SpanStatusUnauthenticated PICTInputStatus = "Unauthenticated" ) +*/ // PICTSpanInputs defines one pairwise combination of Span variations type PICTSpanInputs struct { diff --git a/internal/goldendataset/span_generator.go b/internal/goldendataset/span_generator.go index df4cdd4ba36..ffcaf305efc 100644 --- a/internal/goldendataset/span_generator.go +++ b/internal/goldendataset/span_generator.go @@ -25,45 +25,57 @@ import ( ) var statusCodeMap = map[PICTInputStatus]otlptrace.Status_StatusCode{ - SpanStatusOk: otlptrace.Status_STATUS_CODE_OK, - SpanStatusCancelled: otlptrace.Status_STATUS_CODE_CANCELLED, - SpanStatusUnknownError: otlptrace.Status_STATUS_CODE_UNKNOWN_ERROR, - SpanStatusInvalidArgument: otlptrace.Status_STATUS_CODE_INVALID_ARGUMENT, - SpanStatusDeadlineExceeded: otlptrace.Status_STATUS_CODE_DEADLINE_EXCEEDED, - SpanStatusNotFound: otlptrace.Status_STATUS_CODE_NOT_FOUND, - SpanStatusAlreadyExists: otlptrace.Status_STATUS_CODE_ALREADY_EXISTS, - SpanStatusPermissionDenied: otlptrace.Status_STATUS_CODE_PERMISSION_DENIED, - SpanStatusResourceExhausted: otlptrace.Status_STATUS_CODE_RESOURCE_EXHAUSTED, - SpanStatusFailedPrecondition: otlptrace.Status_STATUS_CODE_FAILED_PRECONDITION, - SpanStatusAborted: otlptrace.Status_STATUS_CODE_ABORTED, - SpanStatusOutOfRange: otlptrace.Status_STATUS_CODE_OUT_OF_RANGE, - SpanStatusUnimplemented: otlptrace.Status_STATUS_CODE_UNIMPLEMENTED, - SpanStatusInternalError: otlptrace.Status_STATUS_CODE_INTERNAL_ERROR, - SpanStatusUnavailable: otlptrace.Status_STATUS_CODE_UNAVAILABLE, - SpanStatusDataLoss: otlptrace.Status_STATUS_CODE_DATA_LOSS, - SpanStatusUnauthenticated: otlptrace.Status_STATUS_CODE_UNAUTHENTICATED, + SpanStatusUnset: otlptrace.Status_STATUS_CODE_UNSET, + SpanStatusOk: otlptrace.Status_STATUS_CODE_OK, + SpanStatusError: otlptrace.Status_STATUS_CODE_ERROR, } var statusMsgMap = map[PICTInputStatus]string{ - SpanStatusOk: "", - SpanStatusCancelled: "Cancellation received", - SpanStatusUnknownError: "", - SpanStatusInvalidArgument: "parameter is required", - SpanStatusDeadlineExceeded: "timed out after 30002 ms", - SpanStatusNotFound: "/dragons/RomanianLonghorn not found", - SpanStatusAlreadyExists: "/dragons/Drogon already exists", - SpanStatusPermissionDenied: "tlannister does not have write permission", - SpanStatusResourceExhausted: "ResourceExhausted", - SpanStatusFailedPrecondition: "33a64df551425fcc55e4d42a148795d9f25f89d4 has been edited", - SpanStatusAborted: "", - SpanStatusOutOfRange: "Range Not Satisfiable", - SpanStatusUnimplemented: "Unimplemented", - SpanStatusInternalError: "java.lang.NullPointerException", - SpanStatusUnavailable: "RecommendationService is currently unavailable", - SpanStatusDataLoss: "", - SpanStatusUnauthenticated: "nstark is unknown user", + SpanStatusOk: "", } +/* +var statusCodeMap = map[PICTInputStatus]otlptrace.Status_DeprecatedStatusCode{ + SpanDeprecatedStatusOk: otlptrace.Status_DEPRECATED_STATUS_CODE_OK, + SpanDeprecatedStatusCancelled: otlptrace.Status_DEPRECATED_STATUS_CODE_CANCELLED, + SpanDeprecatedStatusUnknownError: otlptrace.Status_DEPRECATED_STATUS_CODE_UNKNOWN_ERROR, + SpanDeprecatedStatusInvalidArgument: otlptrace.Status_DEPRECATED_STATUS_CODE_INVALID_ARGUMENT, + SpanDeprecatedStatusDeadlineExceeded: otlptrace.Status_DEPRECATED_STATUS_CODE_DEADLINE_EXCEEDED, + SpanDeprecatedStatusNotFound: otlptrace.Status_DEPRECATED_STATUS_CODE_NOT_FOUND, + SpanDeprecatedStatusAlreadyExists: otlptrace.Status_DEPRECATED_STATUS_CODE_ALREADY_EXISTS, + SpanDeprecatedStatusPermissionDenied: otlptrace.Status_DEPRECATED_STATUS_CODE_PERMISSION_DENIED, + SpanDeprecatedStatusResourceExhausted: otlptrace.Status_DEPRECATED_STATUS_CODE_RESOURCE_EXHAUSTED, + SpanDeprecatedStatusFailedPrecondition: otlptrace.Status_DEPRECATED_STATUS_CODE_FAILED_PRECONDITION, + SpanDeprecatedStatusAborted: otlptrace.Status_DEPRECATED_STATUS_CODE_ABORTED, + SpanDeprecatedStatusOutOfRange: otlptrace.Status_DEPRECATED_STATUS_CODE_OUT_OF_RANGE, + SpanDeprecatedStatusUnimplemented: otlptrace.Status_DEPRECATED_STATUS_CODE_UNIMPLEMENTED, + SpanDeprecatedStatusInternalError: otlptrace.Status_DEPRECATED_STATUS_CODE_INTERNAL_ERROR, + SpanDeprecatedStatusUnavailable: otlptrace.Status_DEPRECATED_STATUS_CODE_UNAVAILABLE, + SpanDeprecatedStatusDataLoss: otlptrace.Status_DEPRECATED_STATUS_CODE_DATA_LOSS, + SpanDeprecatedStatusUnauthenticated: otlptrace.Status_DEPRECATED_STATUS_CODE_UNAUTHENTICATED, +} + +var statusMsgMap = map[PICTInputStatus]string{ + SpanDeprecatedStatusOk: "", + SpanDeprecatedStatusCancelled: "Cancellation received", + SpanDeprecatedStatusUnknownError: "", + SpanDeprecatedStatusInvalidArgument: "parameter is required", + SpanDeprecatedStatusDeadlineExceeded: "timed out after 30002 ms", + SpanDeprecatedStatusNotFound: "/dragons/RomanianLonghorn not found", + SpanDeprecatedStatusAlreadyExists: "/dragons/Drogon already exists", + SpanDeprecatedStatusPermissionDenied: "tlannister does not have write permission", + SpanDeprecatedStatusResourceExhausted: "ResourceExhausted", + SpanDeprecatedStatusFailedPrecondition: "33a64df551425fcc55e4d42a148795d9f25f89d4 has been edited", + SpanDeprecatedStatusAborted: "", + SpanDeprecatedStatusOutOfRange: "Range Not Satisfiable", + SpanDeprecatedStatusUnimplemented: "Unimplemented", + SpanDeprecatedStatusInternalError: "java.lang.NullPointerException", + SpanDeprecatedStatusUnavailable: "RecommendationService is currently unavailable", + SpanDeprecatedStatusDataLoss: "", + SpanDeprecatedStatusUnauthenticated: "nstark is unknown user", +} +*/ + // GenerateSpans generates a slice of OTLP Span objects with the number of spans specified by the count input // parameter. The startPos parameter specifies the line in the PICT tool-generated, test parameter // combination records file specified by the pictFile parameter to start reading from. When the end record @@ -189,7 +201,7 @@ func lookupSpanKind(kind PICTInputKind) otlptrace.Span_SpanKind { } func generateSpanAttributes(spanTypeID PICTInputAttributes, statusStr PICTInputStatus) []otlpcommon.KeyValue { - includeStatus := SpanStatusNil != statusStr + includeStatus := SpanStatusUnset != statusStr var attrs map[string]interface{} switch spanTypeID { case SpanAttrNil: @@ -233,7 +245,7 @@ func generateSpanAttributes(spanTypeID PICTInputAttributes, statusStr PICTInputS } func generateStatus(statusStr PICTInputStatus) *otlptrace.Status { - if SpanStatusNil == statusStr { + if SpanStatusUnset == statusStr { return nil } return &otlptrace.Status{ diff --git a/receiver/jaegerreceiver/trace_receiver_test.go b/receiver/jaegerreceiver/trace_receiver_test.go index af6e17921f2..e99055260b2 100644 --- a/receiver/jaegerreceiver/trace_receiver_test.go +++ b/receiver/jaegerreceiver/trace_receiver_test.go @@ -36,7 +36,6 @@ import ( jaegerthrift "github.com/jaegertracing/jaeger/thrift-gen/jaeger" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.opencensus.io/trace" "go.uber.org/zap" "google.golang.org/grpc" "google.golang.org/grpc/credentials" @@ -206,7 +205,6 @@ func TestGRPCReception(t *testing.T) { defer jr.Shutdown(context.Background()) require.NoError(t, jr.Start(context.Background(), componenttest.NewNopHost())) - t.Log("Start") conn, err := grpc.Dial(fmt.Sprintf("0.0.0.0:%d", config.CollectorGRPCPort), grpc.WithInsecure()) require.NoError(t, err) @@ -264,7 +262,6 @@ func TestGRPCReceptionWithTLS(t *testing.T) { defer jr.Shutdown(context.Background()) require.NoError(t, jr.Start(context.Background(), componenttest.NewNopHost())) - t.Log("Start") creds, err := credentials.NewClientTLSFromFile(path.Join(".", "testdata", "server.crt"), "localhost") require.NoError(t, err) @@ -321,7 +318,7 @@ func expectedTraceData(t1, t2, t3 time.Time) pdata.Traces { span0.SetStartTime(pdata.TimestampUnixNano(uint64(t1.UnixNano()))) span0.SetEndTime(pdata.TimestampUnixNano(uint64(t2.UnixNano()))) span0.Status().InitEmpty() - span0.Status().SetCode(pdata.StatusCodeNotFound) + span0.Status().SetCode(pdata.StatusCodeError) span0.Status().SetMessage("Stale indices") span1 := rs.InstrumentationLibrarySpans().At(0).Spans().At(1) @@ -331,7 +328,7 @@ func expectedTraceData(t1, t2, t3 time.Time) pdata.Traces { span1.SetStartTime(pdata.TimestampUnixNano(uint64(t2.UnixNano()))) span1.SetEndTime(pdata.TimestampUnixNano(uint64(t3.UnixNano()))) span1.Status().InitEmpty() - span1.Status().SetCode(pdata.StatusCodeInternalError) + span1.Status().SetCode(pdata.StatusCodeError) span1.Status().SetMessage("Frontend crash") return traces @@ -362,7 +359,7 @@ func grpcFixture(t1 time.Time, d1, d2 time.Duration) *api_v2.PostSpansRequest { Duration: d1, Tags: []model.KeyValue{ model.String(tracetranslator.TagStatusMsg, "Stale indices"), - model.Int64(tracetranslator.TagStatusCode, trace.StatusCodeNotFound), + model.Int64(tracetranslator.TagStatusCode, int64(pdata.StatusCodeError)), model.Bool("error", true), }, References: []model.SpanRef{ @@ -381,7 +378,7 @@ func grpcFixture(t1 time.Time, d1, d2 time.Duration) *api_v2.PostSpansRequest { Duration: d2, Tags: []model.KeyValue{ model.String(tracetranslator.TagStatusMsg, "Frontend crash"), - model.Int64(tracetranslator.TagStatusCode, trace.StatusCodeInternal), + model.Int64(tracetranslator.TagStatusCode, int64(pdata.StatusCodeError)), model.Bool("error", true), }, }, diff --git a/receiver/otlpreceiver/marshal_jsonpb_test.go b/receiver/otlpreceiver/marshal_jsonpb_test.go index 0f1b07f840d..9ecad8848b9 100644 --- a/receiver/otlpreceiver/marshal_jsonpb_test.go +++ b/receiver/otlpreceiver/marshal_jsonpb_test.go @@ -68,8 +68,9 @@ const expectedJSON = `{ ], "droppedEventsCount": 1, "status": { - "code": "STATUS_CODE_CANCELLED", - "message": "status-cancelled" + "deprecatedCode": "DEPRECATED_STATUS_CODE_UNKNOWN_ERROR", + "message": "status-cancelled", + "code": "STATUS_CODE_ERROR" } } ] diff --git a/receiver/otlpreceiver/trace/otlp.go b/receiver/otlpreceiver/trace/otlp.go index 119a91dc52f..6b277444ddc 100644 --- a/receiver/otlpreceiver/trace/otlp.go +++ b/receiver/otlpreceiver/trace/otlp.go @@ -21,6 +21,7 @@ import ( "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/consumer/pdata" collectortrace "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/collector/trace/v1" + v1 "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/trace/v1" "go.opentelemetry.io/collector/obsreport" ) @@ -53,6 +54,34 @@ func (r *Receiver) Export(ctx context.Context, req *collectortrace.ExportTraceSe // We need to ensure that it propagates the receiver name as a tag ctxWithReceiverName := obsreport.ReceiverContext(ctx, r.instanceName, receiverTransport, receiverTagValue) + // Perform backward compatibility conversion of Span Status code according to + // OTLP specification. + // See https://github.com/open-telemetry/opentelemetry-proto/blob/59c488bfb8fb6d0458ad6425758b70259ff4a2bd/opentelemetry/proto/trace/v1/trace.proto#L231 + // + // If code==STATUS_CODE_UNSET then the value of `deprecated_code` is the + // carrier of the overall status according to these rules: + // + // if deprecated_code==DEPRECATED_STATUS_CODE_OK then the receiver MUST interpret + // the overall status to be STATUS_CODE_UNSET. + // + // if deprecated_code!=DEPRECATED_STATUS_CODE_OK then the receiver MUST interpret + // the overall status to be STATUS_CODE_ERROR. + // + // If code!=STATUS_CODE_UNSET then the value of `deprecated_code` MUST be + // ignored, the `code` field is the sole carrier of the status. + for _, rss := range req.ResourceSpans { + for _, ils := range rss.InstrumentationLibrarySpans { + for _, span := range ils.Spans { + if span.Status != nil { + if span.Status.Code == v1.Status_STATUS_CODE_UNSET && + span.Status.DeprecatedCode != v1.Status_DEPRECATED_STATUS_CODE_OK { + span.Status.Code = v1.Status_STATUS_CODE_ERROR + } + } + } + } + } + td := pdata.TracesFromOtlp(req.ResourceSpans) err := r.sendToNextConsumer(ctxWithReceiverName, td) if err != nil { diff --git a/receiver/otlpreceiver/trace/otlp_test.go b/receiver/otlpreceiver/trace/otlp_test.go index bf9cad3ff84..5d283891238 100644 --- a/receiver/otlpreceiver/trace/otlp_test.go +++ b/receiver/otlpreceiver/trace/otlp_test.go @@ -65,7 +65,7 @@ func TestExport(t *testing.T) { Kind: otlptrace.Span_SPAN_KIND_SERVER, StartTimeUnixNano: unixnanos, EndTimeUnixNano: unixnanos, - Status: &otlptrace.Status{Message: "status-cancelled", Code: otlptrace.Status_STATUS_CODE_CANCELLED}, + Status: &otlptrace.Status{Message: "status-cancelled", Code: otlptrace.Status_STATUS_CODE_ERROR}, TraceState: "a=text,b=123", }, }, @@ -182,3 +182,111 @@ func otlpReceiverOnGRPCServer(t *testing.T, tc consumer.TracesConsumer) (int, fu return port, done } + +func createTraceWithStatus() { + +} + +func TestDeprecatedStatusCode(t *testing.T) { + traceSink := new(consumertest.TracesSink) + + port, doneFn := otlpReceiverOnGRPCServer(t, traceSink) + defer doneFn() + + traceClient, traceClientDoneFn, err := makeTraceServiceClient(port) + require.NoError(t, err, "Failed to create the TraceServiceClient: %v", err) + defer traceClientDoneFn() + + // See specification for handling status code here: + // https://github.com/open-telemetry/opentelemetry-proto/blob/59c488bfb8fb6d0458ad6425758b70259ff4a2bd/opentelemetry/proto/trace/v1/trace.proto#L231 + tests := []struct { + sendCode otlptrace.Status_StatusCode + sendDeprecatedCode otlptrace.Status_DeprecatedStatusCode + expectedRcvCode otlptrace.Status_StatusCode + }{ + { + //If code==STATUS_CODE_UNSET then the value of `deprecated_code` is the + // carrier of the overall status according to these rules: + // + // if deprecated_code==DEPRECATED_STATUS_CODE_OK then the receiver MUST interpret + // the overall status to be STATUS_CODE_UNSET. + sendCode: otlptrace.Status_STATUS_CODE_UNSET, + sendDeprecatedCode: otlptrace.Status_DEPRECATED_STATUS_CODE_OK, + expectedRcvCode: otlptrace.Status_STATUS_CODE_UNSET, + }, + { + // if deprecated_code!=DEPRECATED_STATUS_CODE_OK then the receiver MUST interpret + // the overall status to be STATUS_CODE_ERROR. + sendCode: otlptrace.Status_STATUS_CODE_UNSET, + sendDeprecatedCode: otlptrace.Status_DEPRECATED_STATUS_CODE_UNKNOWN_ERROR, + expectedRcvCode: otlptrace.Status_STATUS_CODE_ERROR, + }, + { + // If code!=STATUS_CODE_UNSET then the value of `deprecated_code` MUST be + // ignored, the `code` field is the sole carrier of the status. + sendCode: otlptrace.Status_STATUS_CODE_OK, + sendDeprecatedCode: otlptrace.Status_DEPRECATED_STATUS_CODE_OK, + expectedRcvCode: otlptrace.Status_STATUS_CODE_OK, + }, + { + // If code!=STATUS_CODE_UNSET then the value of `deprecated_code` MUST be + // ignored, the `code` field is the sole carrier of the status. + sendCode: otlptrace.Status_STATUS_CODE_OK, + sendDeprecatedCode: otlptrace.Status_DEPRECATED_STATUS_CODE_UNKNOWN_ERROR, + expectedRcvCode: otlptrace.Status_STATUS_CODE_OK, + }, + { + // If code!=STATUS_CODE_UNSET then the value of `deprecated_code` MUST be + // ignored, the `code` field is the sole carrier of the status. + sendCode: otlptrace.Status_STATUS_CODE_ERROR, + sendDeprecatedCode: otlptrace.Status_DEPRECATED_STATUS_CODE_OK, + expectedRcvCode: otlptrace.Status_STATUS_CODE_ERROR, + }, + { + // If code!=STATUS_CODE_UNSET then the value of `deprecated_code` MUST be + // ignored, the `code` field is the sole carrier of the status. + sendCode: otlptrace.Status_STATUS_CODE_ERROR, + sendDeprecatedCode: otlptrace.Status_DEPRECATED_STATUS_CODE_UNKNOWN_ERROR, + expectedRcvCode: otlptrace.Status_STATUS_CODE_ERROR, + }, + } + + for _, test := range tests { + resourceSpans := []*otlptrace.ResourceSpans{ + { + InstrumentationLibrarySpans: []*otlptrace.InstrumentationLibrarySpans{ + { + Spans: []*otlptrace.Span{ + { + Status: &otlptrace.Status{ + Code: test.sendCode, + DeprecatedCode: test.sendDeprecatedCode, + }, + }, + }, + }, + }, + }, + } + + req := &collectortrace.ExportTraceServiceRequest{ + ResourceSpans: resourceSpans, + } + + traceSink.Reset() + + resp, err := traceClient.Export(context.Background(), req) + require.NoError(t, err, "Failed to export trace: %v", err) + require.NotNil(t, resp, "The response is missing") + + require.Equal(t, 1, len(traceSink.AllTraces()), "unexpected length: %v", len(traceSink.AllTraces())) + + rcvdStatus := traceSink.AllTraces()[0].ResourceSpans().At(0).InstrumentationLibrarySpans().At(0).Spans().At(0).Status() + + // Check that Code is as expected. + assert.EqualValues(t, rcvdStatus.Code(), test.expectedRcvCode) + + // Check that DeprecatedCode is passed as is. + assert.EqualValues(t, rcvdStatus.DeprecatedCode(), test.sendDeprecatedCode) + } +} diff --git a/translator/internaldata/oc_to_traces.go b/translator/internaldata/oc_to_traces.go index 340f483378f..fca65899146 100644 --- a/translator/internaldata/oc_to_traces.go +++ b/translator/internaldata/oc_to_traces.go @@ -19,6 +19,7 @@ import ( occommon "github.com/census-instrumentation/opencensus-proto/gen-go/agent/common/v1" octrace "github.com/census-instrumentation/opencensus-proto/gen-go/trace/v1" + "go.opencensus.io/trace" "google.golang.org/protobuf/types/known/wrapperspb" "go.opentelemetry.io/collector/consumer/consumerdata" @@ -147,11 +148,12 @@ func ocSpanToInternal(src *octrace.Span, dest pdata.Span) { dest.SetStartTime(pdata.TimestampToUnixNano(src.StartTime)) dest.SetEndTime(pdata.TimestampToUnixNano(src.EndTime)) + ocStatusToInternal(src.Status, src.Attributes, dest.Status()) + initAttributeMapFromOC(src.Attributes, dest.Attributes()) dest.SetDroppedAttributesCount(ocAttrsToDroppedAttributes(src.Attributes)) ocEventsToInternal(src.TimeEvents, dest) ocLinksToInternal(src.Links, dest) - ocStatusToInternal(src.Status, dest.Status()) ocSameProcessAsParentSpanToInternal(src.SameProcessAsParentSpan, dest) } @@ -171,12 +173,36 @@ func spanIDToInternal(spanID []byte) pdata.SpanID { return pdata.NewSpanID(sid) } -func ocStatusToInternal(ocStatus *octrace.Status, dest pdata.SpanStatus) { +func ocStatusToInternal(ocStatus *octrace.Status, ocAttrs *octrace.Span_Attributes, dest pdata.SpanStatus) { if ocStatus == nil { return } dest.InitEmpty() - dest.SetCode(pdata.StatusCode(ocStatus.Code)) + + var code pdata.StatusCode + switch ocStatus.Code { + case trace.StatusCodeOK: + code = pdata.StatusCodeUnset + + case trace.StatusCodeUnknown: + // It is an error. + fallthrough + + default: + // all other OC status codes are also errors. + code = pdata.StatusCodeError + } + + if ocAttrs != nil { + // tracetranslator.TagStatusCode is set it must override the status code value. + // See the reverse translation in traces_to_oc.go:statusToOC(). + if attr, ok := ocAttrs.AttributeMap[tracetranslator.TagStatusCode]; ok { + code = pdata.StatusCode(attr.GetIntValue()) + delete(ocAttrs.AttributeMap, tracetranslator.TagStatusCode) + } + } + + dest.SetCode(code) dest.SetMessage(ocStatus.Message) } diff --git a/translator/internaldata/traces_to_oc.go b/translator/internaldata/traces_to_oc.go index f3afb748377..4b97ccad435 100644 --- a/translator/internaldata/traces_to_oc.go +++ b/translator/internaldata/traces_to_oc.go @@ -19,6 +19,7 @@ import ( "strings" octrace "github.com/census-instrumentation/opencensus-proto/gen-go/trace/v1" + "go.opencensus.io/trace" "google.golang.org/protobuf/types/known/wrapperspb" "go.opentelemetry.io/collector/consumer/consumerdata" @@ -99,6 +100,17 @@ func spanToOC(span pdata.Span) *octrace.Span { attributes.AttributeMap[tracetranslator.TagSpanKind] = kindAttr } + ocStatus, statusAttr := statusToOC(span.Status()) + if statusAttr != nil { + if attributes == nil { + attributes = &octrace.Span_Attributes{ + AttributeMap: make(map[string]*octrace.AttributeValue, 1), + DroppedAttributesCount: 0, + } + } + attributes.AttributeMap[tracetranslator.TagStatusCode] = statusAttr + } + return &octrace.Span{ TraceId: traceIDToOC(span.TraceID()), SpanId: spanIDToOC(span.SpanID()), @@ -111,7 +123,7 @@ func spanToOC(span pdata.Span) *octrace.Span { Attributes: attributes, TimeEvents: eventsToOC(span.Events(), span.DroppedEventsCount()), Links: linksToOC(span.Links(), span.DroppedLinksCount()), - Status: statusToOC(span.Status()), + Status: ocStatus, ChildSpanCount: nil, // TODO(dmitryax): Handle once OTLP supports it SameProcessAsParentSpan: spaps, } @@ -384,14 +396,27 @@ func spanIDToOC(sid pdata.SpanID) []byte { return sidBytes[:] } -func statusToOC(status pdata.SpanStatus) *octrace.Status { +func statusToOC(status pdata.SpanStatus) (*octrace.Status, *octrace.AttributeValue) { if status.IsNil() { - return nil + return nil, nil } - return &octrace.Status{ - Code: int32(status.Code()), - Message: status.Message(), + + var attr *octrace.AttributeValue + var oc int32 + switch status.Code() { + case pdata.StatusCodeUnset: + // Unset in OTLP corresponds to OK in OpenCensus. + oc = trace.StatusCodeOK + case pdata.StatusCodeOk: + // OK in OpenCensus is the closest to OK in OTLP. + oc = trace.StatusCodeOK + // We will also add an attribute to indicate that it is OTLP OK, different from OTLP Unset. + attr = &octrace.AttributeValue{Value: &octrace.AttributeValue_IntValue{IntValue: int64(status.Code())}} + case pdata.StatusCodeError: + oc = trace.StatusCodeUnknown } + + return &octrace.Status{Code: oc, Message: status.Message()}, attr } func stringToTruncatableString(str string) *octrace.TruncatableString { diff --git a/translator/internaldata/traces_to_oc_test.go b/translator/internaldata/traces_to_oc_test.go index d1667c444f3..5d4720d86ee 100644 --- a/translator/internaldata/traces_to_oc_test.go +++ b/translator/internaldata/traces_to_oc_test.go @@ -260,7 +260,7 @@ func TestInternalToOC(t *testing.T) { Attributes: &octrace.Span_Attributes{ DroppedAttributesCount: 1, }, - Status: &octrace.Status{Message: "status-cancelled", Code: 1}, + Status: &octrace.Status{Message: "status-cancelled", Code: 2}, } ocSpan2 := &octrace.Span{ diff --git a/translator/trace/jaeger/jaegerproto_to_traces.go b/translator/trace/jaeger/jaegerproto_to_traces.go index ba6f183b529..32a03c52323 100644 --- a/translator/trace/jaeger/jaegerproto_to_traces.go +++ b/translator/trace/jaeger/jaegerproto_to_traces.go @@ -236,13 +236,13 @@ func jTagsToInternalAttributes(tags []model.KeyValue, dest pdata.AttributeMap) { func setInternalSpanStatus(attrs pdata.AttributeMap, dest pdata.SpanStatus) { - statusCode := pdata.StatusCodeOk + statusCode := pdata.StatusCodeUnset statusMessage := "" statusExists := false if errorVal, ok := attrs.Get(tracetranslator.TagError); ok { if errorVal.BoolVal() { - statusCode = pdata.StatusCodeUnknownError + statusCode = pdata.StatusCodeError attrs.Delete(tracetranslator.TagError) statusExists = true } @@ -250,8 +250,8 @@ func setInternalSpanStatus(attrs pdata.AttributeMap, dest pdata.SpanStatus) { if codeAttr, ok := attrs.Get(tracetranslator.TagStatusCode); ok { statusExists = true - if code, err := getStatusCodeFromAttr(codeAttr); err == nil { - statusCode = code + if code, err := getStatusCodeValFromAttr(codeAttr); err == nil { + statusCode = pdata.StatusCode(code) attrs.Delete(tracetranslator.TagStatusCode) } if msgAttr, ok := attrs.Get(tracetranslator.TagStatusMsg); ok { @@ -262,8 +262,8 @@ func setInternalSpanStatus(attrs pdata.AttributeMap, dest pdata.SpanStatus) { statusExists = true if code, err := getStatusCodeFromHTTPStatusAttr(httpCodeAttr); err == nil { - // Do not set status code to OK in case it was set to Unknown based on "error" tag - if code != pdata.StatusCodeOk { + // Do not set status code in case it was set to Unset. + if code != pdata.StatusCodeUnset { statusCode = code } @@ -280,7 +280,7 @@ func setInternalSpanStatus(attrs pdata.AttributeMap, dest pdata.SpanStatus) { } } -func getStatusCodeFromAttr(attrVal pdata.AttributeValue) (pdata.StatusCode, error) { +func getStatusCodeValFromAttr(attrVal pdata.AttributeValue) (int, error) { var codeVal int64 switch attrVal.Type() { case pdata.AttributeValueINT: @@ -288,26 +288,25 @@ func getStatusCodeFromAttr(attrVal pdata.AttributeValue) (pdata.StatusCode, erro case pdata.AttributeValueSTRING: i, err := strconv.Atoi(attrVal.StringVal()) if err != nil { - return pdata.StatusCodeOk, err + return 0, err } codeVal = int64(i) default: - return pdata.StatusCodeOk, fmt.Errorf("invalid status code attribute type: %s", attrVal.Type().String()) + return 0, fmt.Errorf("invalid status code attribute type: %s", attrVal.Type().String()) } if codeVal > math.MaxInt32 || codeVal < math.MinInt32 { - return pdata.StatusCodeOk, fmt.Errorf("invalid status code value: %d", codeVal) + return 0, fmt.Errorf("invalid status code value: %d", codeVal) } - return pdata.StatusCode(codeVal), nil + return int(codeVal), nil } func getStatusCodeFromHTTPStatusAttr(attrVal pdata.AttributeValue) (pdata.StatusCode, error) { - statusCode, err := getStatusCodeFromAttr(attrVal) + statusCode, err := getStatusCodeValFromAttr(attrVal) if err != nil { return pdata.StatusCodeOk, err } - // TODO: Introduce and use new HTTP -> OTLP code translator instead - return pdata.StatusCode(tracetranslator.OCStatusCodeFromHTTP(int32(statusCode))), nil + return tracetranslator.StatusCodeFromHTTP(statusCode), nil } func jSpanKindToInternal(spanKind string) pdata.SpanKind { diff --git a/translator/trace/jaeger/jaegerproto_to_traces_test.go b/translator/trace/jaeger/jaegerproto_to_traces_test.go index ac09792443f..a3bba2af317 100644 --- a/translator/trace/jaeger/jaegerproto_to_traces_test.go +++ b/translator/trace/jaeger/jaegerproto_to_traces_test.go @@ -41,54 +41,54 @@ var ( testSpanEndTimestamp = pdata.TimestampUnixNano(testSpanEndTime.UnixNano()) ) -func TestGetStatusCodeFromAttr(t *testing.T) { +func TestGetStatusCodeValFromAttr(t *testing.T) { _, invalidNumErr := strconv.Atoi("inf") tests := []struct { name string attr pdata.AttributeValue - code pdata.StatusCode + code int err error }{ { name: "ok-string", attr: pdata.NewAttributeValueString("0"), - code: pdata.StatusCodeOk, + code: 0, err: nil, }, { name: "ok-int", attr: pdata.NewAttributeValueInt(1), - code: pdata.StatusCodeCancelled, + code: 1, err: nil, }, { name: "wrong-type", attr: pdata.NewAttributeValueBool(true), - code: pdata.StatusCodeOk, + code: 0, err: fmt.Errorf("invalid status code attribute type: BOOL"), }, { name: "invalid-string", attr: pdata.NewAttributeValueString("inf"), - code: pdata.StatusCodeOk, + code: 0, err: invalidNumErr, }, { name: "invalid-int", attr: pdata.NewAttributeValueInt(1844674407370955), - code: pdata.StatusCodeOk, + code: 0, err: fmt.Errorf("invalid status code value: 1844674407370955"), }, } for _, test := range tests { t.Run(test.name, func(t *testing.T) { - code, err := getStatusCodeFromAttr(test.attr) + code, err := getStatusCodeValFromAttr(test.attr) assert.EqualValues(t, test.err, err) assert.Equal(t, test.code, code) }) @@ -104,30 +104,30 @@ func TestGetStatusCodeFromHTTPStatusAttr(t *testing.T) { { name: "string-unknown", attr: pdata.NewAttributeValueString("10"), - code: pdata.StatusCodeUnknownError, + code: pdata.StatusCodeError, }, { name: "string-ok", attr: pdata.NewAttributeValueString("101"), - code: pdata.StatusCodeOk, + code: pdata.StatusCodeUnset, }, { name: "int-not-found", attr: pdata.NewAttributeValueInt(404), - code: pdata.StatusCodeNotFound, + code: pdata.StatusCodeError, }, { name: "int-invalid-arg", attr: pdata.NewAttributeValueInt(408), - code: pdata.StatusCodeInvalidArgument, + code: pdata.StatusCodeError, }, { name: "int-internal", attr: pdata.NewAttributeValueInt(500), - code: pdata.StatusCodeInternalError, + code: pdata.StatusCodeError, }, } @@ -331,27 +331,19 @@ func TestSetInternalSpanStatus(t *testing.T) { okStatus.InitEmpty() okStatus.SetCode(pdata.StatusCodeOk) - unknownStatus := pdata.NewSpanStatus() - unknownStatus.InitEmpty() - unknownStatus.SetCode(pdata.StatusCodeUnknownError) - - canceledStatus := pdata.NewSpanStatus() - canceledStatus.InitEmpty() - canceledStatus.SetCode(pdata.StatusCodeCancelled) - - invalidStatusWithMessage := pdata.NewSpanStatus() - invalidStatusWithMessage.InitEmpty() - invalidStatusWithMessage.SetCode(pdata.StatusCodeInvalidArgument) - invalidStatusWithMessage.SetMessage("Error: Invalid argument") + errorStatus := pdata.NewSpanStatus() + errorStatus.InitEmpty() + errorStatus.SetCode(pdata.StatusCodeError) - notFoundStatus := pdata.NewSpanStatus() - notFoundStatus.InitEmpty() - notFoundStatus.SetCode(pdata.StatusCodeNotFound) + errorStatusWithMessage := pdata.NewSpanStatus() + errorStatusWithMessage.InitEmpty() + errorStatusWithMessage.SetCode(pdata.StatusCodeError) + errorStatusWithMessage.SetMessage("Error: Invalid argument") - notFoundStatusWithMessage := pdata.NewSpanStatus() - notFoundStatusWithMessage.InitEmpty() - notFoundStatusWithMessage.SetCode(pdata.StatusCodeNotFound) - notFoundStatusWithMessage.SetMessage("HTTP 404: Not Found") + errorStatusWith404Message := pdata.NewSpanStatus() + errorStatusWith404Message.InitEmpty() + errorStatusWith404Message.SetCode(pdata.StatusCodeError) + errorStatusWith404Message.SetMessage("HTTP 404: Not Found") tests := []struct { name string @@ -366,11 +358,11 @@ func TestSetInternalSpanStatus(t *testing.T) { attrsModifiedLen: 0, }, { - name: "error tag set -> Unknown status", + name: "error tag set -> Error status", attrs: pdata.NewAttributeMap().InitFromMap(map[string]pdata.AttributeValue{ tracetranslator.TagError: pdata.NewAttributeValueBool(true), }), - status: unknownStatus, + status: errorStatus, attrsModifiedLen: 0, }, { @@ -378,17 +370,17 @@ func TestSetInternalSpanStatus(t *testing.T) { attrs: pdata.NewAttributeMap().InitFromMap(map[string]pdata.AttributeValue{ tracetranslator.TagStatusCode: pdata.NewAttributeValueInt(1), }), - status: canceledStatus, + status: okStatus, attrsModifiedLen: 0, }, { name: "status.code, status.message and error tags are set", attrs: pdata.NewAttributeMap().InitFromMap(map[string]pdata.AttributeValue{ tracetranslator.TagError: pdata.NewAttributeValueBool(true), - tracetranslator.TagStatusCode: pdata.NewAttributeValueInt(3), + tracetranslator.TagStatusCode: pdata.NewAttributeValueInt(int64(pdata.StatusCodeError)), tracetranslator.TagStatusMsg: pdata.NewAttributeValueString("Error: Invalid argument"), }), - status: invalidStatusWithMessage, + status: errorStatusWithMessage, attrsModifiedLen: 0, }, { @@ -396,7 +388,7 @@ func TestSetInternalSpanStatus(t *testing.T) { attrs: pdata.NewAttributeMap().InitFromMap(map[string]pdata.AttributeValue{ tracetranslator.TagHTTPStatusCode: pdata.NewAttributeValueString("404"), }), - status: notFoundStatus, + status: errorStatus, attrsModifiedLen: 1, }, { @@ -406,7 +398,7 @@ func TestSetInternalSpanStatus(t *testing.T) { tracetranslator.TagHTTPStatusCode: pdata.NewAttributeValueInt(404), tracetranslator.TagHTTPStatusMsg: pdata.NewAttributeValueString("HTTP 404: Not Found"), }), - status: notFoundStatusWithMessage, + status: errorStatusWith404Message, attrsModifiedLen: 2, }, { @@ -416,7 +408,7 @@ func TestSetInternalSpanStatus(t *testing.T) { tracetranslator.TagHTTPStatusCode: pdata.NewAttributeValueInt(500), tracetranslator.TagHTTPStatusMsg: pdata.NewAttributeValueString("Server Error"), }), - status: canceledStatus, + status: okStatus, attrsModifiedLen: 2, }, { @@ -425,7 +417,7 @@ func TestSetInternalSpanStatus(t *testing.T) { tracetranslator.TagError: pdata.NewAttributeValueBool(true), tracetranslator.TagHTTPStatusCode: pdata.NewAttributeValueInt(200), }), - status: unknownStatus, + status: errorStatus, attrsModifiedLen: 1, }, } @@ -623,7 +615,7 @@ func generateProtoSpan() *model.Span { { Key: tracetranslator.TagStatusCode, VType: model.ValueType_INT64, - VInt64: tracetranslator.OCCancelled, + VInt64: int64(pdata.StatusCodeError), }, { Key: tracetranslator.TagError, @@ -701,7 +693,7 @@ func generateProtoSpanWithTraceState() *model.Span { { Key: tracetranslator.TagStatusCode, VType: model.ValueType_INT64, - VInt64: tracetranslator.OCCancelled, + VInt64: int64(pdata.StatusCodeError), }, { Key: tracetranslator.TagError, @@ -736,7 +728,7 @@ func generateTraceDataTwoSpansChildParent() pdata.Traces { span.SetStartTime(spans.At(0).StartTime()) span.SetEndTime(spans.At(0).EndTime()) span.Status().InitEmpty() - span.Status().SetCode(pdata.StatusCodeNotFound) + span.Status().SetCode(pdata.StatusCodeError) span.Attributes().InitFromMap(map[string]pdata.AttributeValue{ tracetranslator.TagHTTPStatusCode: pdata.NewAttributeValueInt(404), }) @@ -818,7 +810,7 @@ func generateProtoFollowerSpan() *model.Span { { Key: tracetranslator.TagStatusCode, VType: model.ValueType_INT64, - VInt64: tracetranslator.OCOK, + VInt64: int64(pdata.StatusCodeOk), }, { Key: tracetranslator.TagStatusMsg, diff --git a/translator/trace/jaeger/jaegerthrift_to_traces_test.go b/translator/trace/jaeger/jaegerthrift_to_traces_test.go index 064154d3841..ee3315f9c52 100644 --- a/translator/trace/jaeger/jaegerthrift_to_traces_test.go +++ b/translator/trace/jaeger/jaegerthrift_to_traces_test.go @@ -154,7 +154,7 @@ func generateThriftSpan() *jaeger.Span { intAttrVal := int64(123) eventName := "event-with-attr" eventStrAttrVal := "span-event-attr-val" - statusCode := int64(tracetranslator.OCCancelled) + statusCode := int64(pdata.StatusCodeError) statusMsg := "status-cancelled" kind := string(tracetranslator.OpenTracingSpanKindClient) @@ -242,7 +242,7 @@ func generateThriftChildSpan() *jaeger.Span { } func generateThriftFollowerSpan() *jaeger.Span { - statusCode := int64(tracetranslator.OCOK) + statusCode := int64(pdata.StatusCodeOk) statusMsg := "status-ok" kind := string(tracetranslator.OpenTracingSpanKindConsumer) diff --git a/translator/trace/jaeger/traces_to_jaegerproto_test.go b/translator/trace/jaeger/traces_to_jaegerproto_test.go index bbdd38c3967..6897b7e956f 100644 --- a/translator/trace/jaeger/traces_to_jaegerproto_test.go +++ b/translator/trace/jaeger/traces_to_jaegerproto_test.go @@ -48,21 +48,11 @@ func TestGetTagFromStatusCode(t *testing.T) { }, { - name: "unknown", - code: pdata.StatusCodeUnknownError, + name: "error", + code: pdata.StatusCodeError, tag: model.KeyValue{ Key: tracetranslator.TagStatusCode, - VInt64: int64(pdata.StatusCodeUnknownError), - VType: model.ValueType_INT64, - }, - }, - - { - name: "not-found", - code: pdata.StatusCodeNotFound, - tag: model.KeyValue{ - Key: tracetranslator.TagStatusCode, - VInt64: int64(pdata.StatusCodeNotFound), + VInt64: int64(pdata.StatusCodeError), VType: model.ValueType_INT64, }, }, @@ -87,11 +77,7 @@ func TestGetErrorTagFromStatusCode(t *testing.T) { _, ok := getErrorTagFromStatusCode(pdata.StatusCodeOk) assert.False(t, ok) - got, ok := getErrorTagFromStatusCode(pdata.StatusCodeUnknownError) - assert.True(t, ok) - assert.EqualValues(t, errTag, got) - - got, ok = getErrorTagFromStatusCode(pdata.StatusCodeNotFound) + got, ok := getErrorTagFromStatusCode(pdata.StatusCodeError) assert.True(t, ok) assert.EqualValues(t, errTag, got) } @@ -365,7 +351,7 @@ func generateProtoChildSpanWithErrorTags() *model.Span { span.Tags = append(span.Tags, model.KeyValue{ Key: tracetranslator.TagStatusCode, VType: model.ValueType_INT64, - VInt64: tracetranslator.OCNotFound, + VInt64: int64(pdata.StatusCodeError), }) span.Tags = append(span.Tags, model.KeyValue{ Key: tracetranslator.TagError, diff --git a/translator/trace/protospan_translation.go b/translator/trace/protospan_translation.go index 57eefe573a7..6657edf7bec 100644 --- a/translator/trace/protospan_translation.go +++ b/translator/trace/protospan_translation.go @@ -304,3 +304,12 @@ func jsonArrayToAttributeArray(jArray []interface{}, dest pdata.AnyValueArray) { } } } + +// StatusCodeFromHTTP takes an HTTP status code and return the appropriate OpenTelemetry status code +// See: https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/semantic_conventions/http.md#status +func StatusCodeFromHTTP(httpStatusCode int) pdata.StatusCode { + if httpStatusCode >= 100 && httpStatusCode < 399 { + return pdata.StatusCodeUnset + } + return pdata.StatusCodeError +} diff --git a/translator/trace/zipkin/traces_to_zipkinv2_test.go b/translator/trace/zipkin/traces_to_zipkinv2_test.go index 89f725d7bbc..4ac740e211e 100644 --- a/translator/trace/zipkin/traces_to_zipkinv2_test.go +++ b/translator/trace/zipkin/traces_to_zipkinv2_test.go @@ -154,7 +154,7 @@ func zipkinOneSpan() *zipkinmodel.SpanModel { }, Tags: map[string]string{ "resource-attr": "resource-attr-val-1", - "status.code": "STATUS_CODE_CANCELLED", + "status.code": "STATUS_CODE_ERROR", "status.message": "status-cancelled", }, Name: "operationA",