diff --git a/Makefile b/Makefile index 7689b19b500..57d5c7b3fb5 100644 --- a/Makefile +++ b/Makefile @@ -277,6 +277,9 @@ genproto_sub: sed -f proto_patch.sed $(OPENTELEMETRY_PROTO_SRC_DIR)/opentelemetry/proto/logs/v1/logs.proto \ > $(PROTO_INTERMEDIATE_DIR)/opentelemetry/proto/logs/v1/logs.proto + sed -f proto_patch.sed $(OPENTELEMETRY_PROTO_SRC_DIR)/opentelemetry/proto/metrics/v1/metrics.proto \ + > $(PROTO_INTERMEDIATE_DIR)/opentelemetry/proto/metrics/v1/metrics.proto + @echo Generate Go code from .proto files in intermediate directory. $(foreach file,$(OPENTELEMETRY_PROTO_FILES),$(call exec-command,cd $(PROTO_INTERMEDIATE_DIR) && protoc --gogofaster_out=plugins=grpc:./ -I./ -I$(GO_PKG_DIR) $(file))) diff --git a/cmd/pdatagen/internal/log_structs.go b/cmd/pdatagen/internal/log_structs.go index 5b599f8c588..56085dd74e4 100644 --- a/cmd/pdatagen/internal/log_structs.go +++ b/cmd/pdatagen/internal/log_structs.go @@ -17,6 +17,7 @@ package internal var logFile = &File{ Name: "log", imports: []string{ + `otlpcommon "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/common/v1"`, `otlplogs "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/logs/v1"`, }, testImports: []string{ diff --git a/cmd/pdatagen/internal/trace_structs.go b/cmd/pdatagen/internal/trace_structs.go index 16017c61c3d..54449fade92 100644 --- a/cmd/pdatagen/internal/trace_structs.go +++ b/cmd/pdatagen/internal/trace_structs.go @@ -17,6 +17,7 @@ package internal var traceFile = &File{ Name: "trace", imports: []string{ + `otlpcommon "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/common/v1"`, `otlptrace "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/trace/v1"`, }, testImports: []string{ @@ -204,7 +205,7 @@ var traceIDField = &primitiveTypedField{ fieldName: "TraceID", originFieldName: "TraceId", returnType: "TraceID", - rawType: "[]byte", + rawType: "otlpcommon.TraceID", defaultVal: "NewTraceID(nil)", testVal: "NewTraceID([]byte{1, 2, 3, 4, 5, 6, 7, 8, 8, 7, 6, 5, 4, 3, 2, 1})", } diff --git a/consumer/pdata/generated_log.go b/consumer/pdata/generated_log.go index 9b055336ab0..c48f949e92a 100644 --- a/consumer/pdata/generated_log.go +++ b/consumer/pdata/generated_log.go @@ -18,6 +18,7 @@ package pdata import ( + otlpcommon "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/common/v1" otlplogs "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/logs/v1" ) @@ -590,7 +591,7 @@ func (ms LogRecord) TraceID() TraceID { // // Important: This causes a runtime error if IsNil() returns "true". func (ms LogRecord) SetTraceID(v TraceID) { - (*ms.orig).TraceId = []byte(v) + (*ms.orig).TraceId = otlpcommon.TraceID(v) } // SpanID returns the spanid associated with this LogRecord. diff --git a/consumer/pdata/generated_trace.go b/consumer/pdata/generated_trace.go index 8841ad90fa3..d5eec86e535 100644 --- a/consumer/pdata/generated_trace.go +++ b/consumer/pdata/generated_trace.go @@ -18,6 +18,7 @@ package pdata import ( + otlpcommon "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/common/v1" otlptrace "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/trace/v1" ) @@ -576,7 +577,7 @@ func (ms Span) TraceID() TraceID { // // Important: This causes a runtime error if IsNil() returns "true". func (ms Span) SetTraceID(v TraceID) { - (*ms.orig).TraceId = []byte(v) + (*ms.orig).TraceId = otlpcommon.TraceID(v) } // SpanID returns the spanid associated with this Span. @@ -1175,7 +1176,7 @@ func (ms SpanLink) TraceID() TraceID { // // Important: This causes a runtime error if IsNil() returns "true". func (ms SpanLink) SetTraceID(v TraceID) { - (*ms.orig).TraceId = []byte(v) + (*ms.orig).TraceId = otlpcommon.TraceID(v) } // SpanID returns the spanid associated with this SpanLink. diff --git a/consumer/pdata/metric_test.go b/consumer/pdata/metric_test.go index 8cad1e17b98..48299701d52 100644 --- a/consumer/pdata/metric_test.go +++ b/consumer/pdata/metric_test.go @@ -156,7 +156,7 @@ func TestResourceMetricsWireCompatibility(t *testing.T) { // Now compare that the original and final ProtoBuf messages are the same. // This proves that goproto and gogoproto marshaling/unmarshaling are wire compatible. - assert.True(t, gogoproto.Equal(*pdataRM.orig, &gogoprotoRM)) + assert.True(t, assert.EqualValues(t, *pdataRM.orig, &gogoprotoRM)) } func TestMetricCount(t *testing.T) { diff --git a/consumer/pdata/trace.go b/consumer/pdata/trace.go index 2483bcd3c4e..e4b962b4b4a 100644 --- a/consumer/pdata/trace.go +++ b/consumer/pdata/trace.go @@ -105,17 +105,6 @@ func (td Traces) ResourceSpans() ResourceSpansSlice { return newResourceSpansSlice(td.orig) } -type TraceID []byte - -// NewTraceID returns a new TraceID. -func NewTraceID(bytes []byte) TraceID { return bytes } - -func (t TraceID) Bytes() []byte { - return t -} - -func (t TraceID) String() string { return hex.EncodeToString(t) } - type SpanID []byte // NewSpanID returns a new SpanID. diff --git a/consumer/pdata/trace_test.go b/consumer/pdata/trace_test.go index 499b0fc1274..0d00d1f2ef9 100644 --- a/consumer/pdata/trace_test.go +++ b/consumer/pdata/trace_test.go @@ -140,7 +140,7 @@ func TestResourceSpansWireCompatibility(t *testing.T) { // Now compare that the original and final ProtoBuf messages are the same. // This proves that goproto and gogoproto marshaling/unmarshaling are wire compatible. - assert.True(t, gogoproto.Equal(*pdataRS.orig, &gogoprotoRS2)) + assert.EqualValues(t, *pdataRS.orig, &gogoprotoRS2) } func TestTraces_ToOtlpProtoBytes(t *testing.T) { diff --git a/consumer/pdata/traceid.go b/consumer/pdata/traceid.go new file mode 100644 index 00000000000..a5c63cfdd2e --- /dev/null +++ b/consumer/pdata/traceid.go @@ -0,0 +1,34 @@ +// Copyright The OpenTelemetry Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package pdata + +import ( + otlpcommon "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/common/v1" +) + +// TraceID is an alias of OTLP TraceID data type. +type TraceID otlpcommon.TraceID + +func NewTraceID(bytes []byte) TraceID { + return TraceID(otlpcommon.NewTraceID(bytes)) +} + +func (t TraceID) Bytes() []byte { + return otlpcommon.TraceID(t).Bytes() +} + +func (t TraceID) HexString() string { + return otlpcommon.TraceID(t).HexString() +} diff --git a/exporter/jaegerexporter/exporter_test.go b/exporter/jaegerexporter/exporter_test.go index b441d8de099..c9ed79a43c4 100644 --- a/exporter/jaegerexporter/exporter_test.go +++ b/exporter/jaegerexporter/exporter_test.go @@ -32,6 +32,7 @@ import ( "go.opentelemetry.io/collector/config/configgrpc" "go.opentelemetry.io/collector/config/configtls" "go.opentelemetry.io/collector/consumer/pdata" + otlpcommon "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/common/v1" tracev1 "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/trace/v1" "go.opentelemetry.io/collector/internal/data/testdata" ) @@ -226,7 +227,7 @@ func TestMutualTLS(t *testing.T) { require.NoError(t, err) defer exporter.Shutdown(context.Background()) - traceID := []byte("0123456789abcdef") + traceID := otlpcommon.NewTraceID([]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}) spanID := []byte("01234567") traces := pdata.TracesFromOtlp([]*tracev1.ResourceSpans{ {InstrumentationLibrarySpans: []*tracev1.InstrumentationLibrarySpans{{Spans: []*tracev1.Span{{TraceId: traceID, SpanId: spanID}}}}}, @@ -235,7 +236,7 @@ func TestMutualTLS(t *testing.T) { require.NoError(t, err) requestes := spanHandler.getRequests() assert.Equal(t, 1, len(requestes)) - jTraceID, err := model.TraceIDFromBytes(traceID) + jTraceID, err := model.TraceIDFromBytes(traceID.Bytes()) require.NoError(t, err) assert.Equal(t, jTraceID, requestes[0].GetBatch().Spans[0].TraceID) } diff --git a/exporter/loggingexporter/logging_exporter.go b/exporter/loggingexporter/logging_exporter.go index 7ad4feb3553..d6d2b58a126 100644 --- a/exporter/loggingexporter/logging_exporter.go +++ b/exporter/loggingexporter/logging_exporter.go @@ -254,7 +254,7 @@ func (b *logDataBuffer) logLinks(description string, sl pdata.SpanLinkSlice) { continue } b.logEntry("SpanLink #%d", i) - b.logEntry(" -> Trace ID: %s", l.TraceID().String()) + b.logEntry(" -> Trace ID: %s", l.TraceID().HexString()) b.logEntry(" -> ID: %s", l.SpanID().String()) b.logEntry(" -> TraceState: %s", l.TraceState()) b.logEntry(" -> DroppedAttributesCount: %d", l.DroppedAttributesCount()) @@ -332,7 +332,7 @@ func (s *loggingExporter) pushTraceData( continue } - buf.logAttr("Trace ID", span.TraceID().String()) + buf.logAttr("Trace ID", span.TraceID().HexString()) buf.logAttr("Parent ID", span.ParentSpanID().String()) buf.logAttr("ID", span.SpanID().String()) buf.logAttr("Name", span.Name()) diff --git a/internal/data/opentelemetry-proto-gen/logs/v1/logs.pb.go b/internal/data/opentelemetry-proto-gen/logs/v1/logs.pb.go index 7451f9227e4..eb42c2a6556 100644 --- a/internal/data/opentelemetry-proto-gen/logs/v1/logs.pb.go +++ b/internal/data/opentelemetry-proto-gen/logs/v1/logs.pb.go @@ -13,6 +13,7 @@ import ( _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" + go_opentelemetry_io_collector_internal_data_opentelemetry_proto_gen_common_v1 "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/common/v1" v11 "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/common/v1" v1 "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/resource/v1" ) @@ -296,7 +297,7 @@ type LogRecord struct { // the same `trace_id`. The ID is a 16-byte array. An ID with all zeroes // is considered invalid. Can be set for logs that are part of request processing // and have an assigned trace id. [Optional]. - TraceId []byte `protobuf:"bytes,9,opt,name=trace_id,json=traceId,proto3" json:"trace_id,omitempty"` + TraceId go_opentelemetry_io_collector_internal_data_opentelemetry_proto_gen_common_v1.TraceID `protobuf:"bytes,9,opt,name=trace_id,json=traceId,proto3,customtype=go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/common/v1.TraceID" json:"trace_id"` // A unique identifier for a span within a trace, assigned when the span // is created. The ID is an 8-byte array. An ID with all zeroes is considered // invalid. Can be set for logs that are part of a particular processing span. @@ -393,13 +394,6 @@ func (m *LogRecord) GetFlags() uint32 { return 0 } -func (m *LogRecord) GetTraceId() []byte { - if m != nil { - return m.TraceId - } - return nil -} - func (m *LogRecord) GetSpanId() []byte { if m != nil { return m.SpanId @@ -420,59 +414,61 @@ func init() { } var fileDescriptor_d1c030a3ec7e961e = []byte{ - // 829 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x95, 0xdf, 0x6e, 0xe2, 0x46, - 0x14, 0xc6, 0x33, 0x09, 0x81, 0x64, 0x42, 0xd8, 0xe9, 0x34, 0x9b, 0x78, 0x49, 0xc5, 0xa2, 0xb4, - 0xdd, 0xd2, 0x54, 0x6b, 0x84, 0xa1, 0x6a, 0xd5, 0xde, 0x94, 0x24, 0x26, 0x42, 0x61, 0x49, 0x34, - 0x90, 0xed, 0x9f, 0x1b, 0xcb, 0xc0, 0xac, 0x6b, 0xc9, 0x9e, 0x41, 0xf6, 0x18, 0x85, 0xb7, 0xa8, - 0xfa, 0x4a, 0xbd, 0x59, 0xf5, 0x2a, 0x97, 0xbd, 0xac, 0x92, 0x07, 0x69, 0xe5, 0x31, 0xb0, 0x0b, - 0xf2, 0x90, 0x2b, 0xce, 0x9c, 0xdf, 0xf7, 0x9d, 0x73, 0xe6, 0xc8, 0xd8, 0xf0, 0x15, 0x1f, 0x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10, 0x24, 0x53, 0xc0, 0xff, 0x07, 0x00, 0x00, + // 864 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x96, 0x4d, 0x6f, 0xe2, 0x46, + 0x18, 0xc7, 0x99, 0x84, 0x40, 0x32, 0x21, 0xec, 0x74, 0x9a, 0x4d, 0x5c, 0x52, 0x01, 0x4a, 0xdb, + 0x2d, 0x4d, 0xb5, 0x46, 0x18, 0xaa, 0x56, 0xed, 0xa5, 0x90, 0x98, 0x08, 0x85, 0x25, 0xd1, 0x00, + 0xdb, 0x97, 0x8b, 0x65, 0x60, 0xd6, 0x6b, 0x09, 0x66, 0x90, 0x3d, 0x46, 0xe1, 0xdc, 0x2f, 0x50, + 0xf5, 0xbb, 0xf4, 0x13, 0xf4, 0x92, 0x63, 0x8e, 0x55, 0x0f, 0x51, 0x95, 0x7c, 0x90, 0x56, 0x1e, + 0x3b, 0xec, 0x82, 0x6c, 0x72, 0xd9, 0x53, 0x9e, 0x79, 0x7e, 0xcf, 0xff, 0x79, 0x8b, 0x67, 0x04, + 0x7c, 0xc1, 0xa7, 0x94, 0x09, 0x3a, 0xa6, 0x13, 0x2a, 0x9c, 0x79, 0x79, 0xea, 0x70, 0xc1, 0xcb, + 0x63, 0x6e, 0xb9, 0xe5, 0x59, 0x45, 0xfe, 0x55, 0xa5, 0x0b, 0x1f, 0x2d, 0xc5, 0x05, 0x4e, 0x55, + 0xf2, 0x59, 0x25, 0x57, 0xb3, 0x6c, 0xf1, 0xd6, 0x1b, 0xa8, 0x43, 0x3e, 0x29, 0x5b, 0xdc, 0xe2, + 0x41, 0x9a, 0x81, 0xf7, 0xe6, 0xc7, 0x59, 0x45, 0xad, 0xaa, 0x15, 0xe9, 0x0c, 0x52, 0xfb, 0x56, + 0xa0, 0xce, 0x9d, 0x44, 0x95, 0x1e, 0xf2, 0xc9, 0x84, 0x33, 0xbf, 0x78, 0x60, 0x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x86, 0x70, 0x2c, 0xab, 0xa2, 0x8f, 0x63, 0x59, 0x0d, 0xed, 0x47, 0x95, 0x6b, 0xd6, + 0x7b, 0xf5, 0x36, 0x7a, 0x1e, 0x25, 0x93, 0x48, 0x43, 0x07, 0xb1, 0xac, 0x8a, 0x0e, 0x63, 0x59, + 0x0d, 0x29, 0x27, 0x3f, 0xc3, 0xec, 0xe2, 0xf1, 0x6b, 0xca, 0x6b, 0x57, 0x80, 0x47, 0xed, 0xcb, + 0x73, 0x83, 0xe8, 0xa7, 0x97, 0xe4, 0xcc, 0x68, 0xb6, 0xeb, 0xe7, 0x2b, 0x1f, 0xf1, 0x17, 0xb0, + 0xb8, 0x1a, 0x20, 0xbf, 0x38, 0x69, 0x76, 0x8d, 0x57, 0xf5, 0xee, 0x05, 0xfa, 0x0f, 0x34, 0xfe, + 0x00, 0x37, 0xf7, 0x79, 0x70, 0x7b, 0x9f, 0x07, 0xff, 0xde, 0xe7, 0xc1, 0xef, 0x0f, 0xf9, 0xc4, + 0xed, 0x43, 0x3e, 0xf1, 0xf7, 0x43, 0x3e, 0x01, 0xf3, 0x36, 0x5f, 0xf7, 0x4e, 0x36, 0xfc, 0xf7, + 0xd8, 0xbd, 0xf2, 0x5d, 0x57, 0xe0, 0xd7, 0x8b, 0x0f, 0x71, 0xd7, 0xc3, 0x1f, 0x11, 0x83, 0x94, + 0x74, 0x55, 0xff, 0x0f, 0x00, 0x00, 0xff, 0xff, 0x00, 0xc2, 0xc4, 0xbb, 0x6a, 0x08, 0x00, 0x00, } func (m *ResourceLogs) Marshal() (dAtA []byte, err error) { @@ -600,13 +596,16 @@ func (m *LogRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x52 } - if len(m.TraceId) > 0 { - i -= len(m.TraceId) - copy(dAtA[i:], m.TraceId) - i = encodeVarintLogs(dAtA, i, uint64(len(m.TraceId))) - i-- - dAtA[i] = 0x4a + { + size := m.TraceId.Size() + i -= size + if _, err := m.TraceId.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLogs(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x4a if m.Flags != 0 { i -= 4 encoding_binary.LittleEndian.PutUint32(dAtA[i:], uint32(m.Flags)) @@ -757,10 +756,8 @@ func (m *LogRecord) Size() (n int) { if m.Flags != 0 { n += 5 } - l = len(m.TraceId) - if l > 0 { - n += 1 + l + sovLogs(uint64(l)) - } + l = m.TraceId.Size() + n += 1 + l + sovLogs(uint64(l)) l = len(m.SpanId) if l > 0 { n += 1 + l + sovLogs(uint64(l)) @@ -1270,9 +1267,8 @@ func (m *LogRecord) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.TraceId = append(m.TraceId[:0], dAtA[iNdEx:postIndex]...) - if m.TraceId == nil { - m.TraceId = []byte{} + if err := m.TraceId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex case 10: diff --git a/internal/data/opentelemetry-proto-gen/metrics/v1/metrics.pb.go b/internal/data/opentelemetry-proto-gen/metrics/v1/metrics.pb.go index d5812baf022..692c7d74700 100644 --- a/internal/data/opentelemetry-proto-gen/metrics/v1/metrics.pb.go +++ b/internal/data/opentelemetry-proto-gen/metrics/v1/metrics.pb.go @@ -10,8 +10,10 @@ import ( math "math" math_bits "math/bits" + _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" + go_opentelemetry_io_collector_internal_data_opentelemetry_proto_gen_common_v1 "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/common/v1" v11 "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/common/v1" v1 "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/resource/v1" ) @@ -1338,7 +1340,7 @@ type IntExemplar struct { // (Optional) Trace ID of the exemplar trace. // trace_id may be missing if the measurement is not recorded inside a trace // or if the trace is not sampled. - TraceId []byte `protobuf:"bytes,5,opt,name=trace_id,json=traceId,proto3" json:"trace_id,omitempty"` + TraceId go_opentelemetry_io_collector_internal_data_opentelemetry_proto_gen_common_v1.TraceID `protobuf:"bytes,5,opt,name=trace_id,json=traceId,proto3,customtype=go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/common/v1.TraceID" json:"trace_id"` } func (m *IntExemplar) Reset() { *m = IntExemplar{} } @@ -1402,13 +1404,6 @@ func (m *IntExemplar) GetSpanId() []byte { return nil } -func (m *IntExemplar) GetTraceId() []byte { - if m != nil { - return m.TraceId - } - return nil -} - // A representation of an exemplar, which is a sample input double measurement. // Exemplars also hold information about the environment when the measurement // was recorded, for example the span and trace ID of the active span when the @@ -1432,7 +1427,7 @@ type DoubleExemplar struct { // (Optional) Trace ID of the exemplar trace. // trace_id may be missing if the measurement is not recorded inside a trace // or if the trace is not sampled. - TraceId []byte `protobuf:"bytes,5,opt,name=trace_id,json=traceId,proto3" json:"trace_id,omitempty"` + TraceId go_opentelemetry_io_collector_internal_data_opentelemetry_proto_gen_common_v1.TraceID `protobuf:"bytes,5,opt,name=trace_id,json=traceId,proto3,customtype=go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/common/v1.TraceID" json:"trace_id"` } func (m *DoubleExemplar) Reset() { *m = DoubleExemplar{} } @@ -1496,13 +1491,6 @@ func (m *DoubleExemplar) GetSpanId() []byte { return nil } -func (m *DoubleExemplar) GetTraceId() []byte { - if m != nil { - return m.TraceId - } - return nil -} - func init() { proto.RegisterEnum("opentelemetry.proto.metrics.v1.AggregationTemporality", AggregationTemporality_name, AggregationTemporality_value) proto.RegisterType((*ResourceMetrics)(nil), "opentelemetry.proto.metrics.v1.ResourceMetrics") @@ -1527,76 +1515,80 @@ func init() { } var fileDescriptor_3c3112f9fa006917 = []byte{ - // 1099 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x58, 0x41, 0x4f, 0xe3, 0xc6, - 0x17, 0xcf, 0x24, 0xe0, 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 0x43, 0x69, 0x8f, 0xbf, 0x43, 0x30, 0x97, 0xfc, 0x0e, 0xc4, 0x8f, 0xe0, 0x61, 0x7d, - 0x7b, 0x5b, 0x6b, 0x6c, 0xd7, 0x3b, 0xcd, 0xe7, 0x7b, 0x7a, 0xa7, 0xb1, 0xdb, 0x7e, 0xae, 0xd5, - 0x5b, 0xcd, 0xce, 0x91, 0x7e, 0xb0, 0xb7, 0xdf, 0x6e, 0x6c, 0x36, 0x3f, 0x6d, 0x36, 0xb6, 0x4a, - 0x29, 0xbc, 0x04, 0x0b, 0x37, 0x05, 0x6e, 0x35, 0x5a, 0x9d, 0x7a, 0x09, 0xe1, 0x65, 0xa8, 0xdc, - 0x14, 0xb2, 0x79, 0xb0, 0x7b, 0xd0, 0xaa, 0x77, 0x9a, 0x87, 0x8d, 0x52, 0x7a, 0xe3, 0x27, 0xf4, - 0xcb, 0x59, 0x19, 0xbd, 0x38, 0x2b, 0xa3, 0x57, 0x67, 0x65, 0xf4, 0xc3, 0x79, 0x39, 0xf5, 0xe2, - 0xbc, 0x9c, 0x7a, 0x79, 0x5e, 0x4e, 0xc1, 0x12, 0xe5, 0x23, 0x26, 0x73, 0xa3, 0x18, 0xfd, 0xa9, - 0xdb, 0x0e, 0x2e, 0xda, 0xe8, 0x8b, 0xbd, 0xde, 0xd5, 0x14, 0xca, 0x6b, 0x26, 0xb7, 0x6d, 0x62, - 0x0a, 0xee, 0xd6, 0x28, 0x13, 0xc4, 0x65, 0x86, 0x5d, 0x0b, 0xbe, 0x28, 0x6a, 0x43, 0x81, 0xab, - 0x12, 0x7b, 0xb5, 0x47, 0xd8, 0xc0, 0x3f, 0x34, 0xba, 0x8a, 0xf4, 0x7e, 0xf0, 0x6f, 0x00, 0x00, - 0x00, 0xff, 0xff, 0x5b, 0xe2, 0x24, 0x7c, 0xf9, 0x10, 0x00, 0x00, + // 1164 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00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d8, 0x66, 0x60, 0x63, 0x75, 0x4a, 0x16, 0xbe, 0x30, 0xbe, 0x33, 0x7c, 0x45, + 0xc4, 0xaf, 0xa6, 0xf4, 0x3c, 0x89, 0x6c, 0xd4, 0x86, 0x92, 0xc5, 0x82, 0xae, 0x83, 0x23, 0xac, + 0x69, 0x89, 0x75, 0x7f, 0x1c, 0xd6, 0xb2, 0xcc, 0x89, 0xe1, 0x8a, 0xd6, 0xe0, 0x88, 0xea, 0x90, + 0x13, 0xd4, 0xfc, 0xc0, 0x55, 0xb3, 0x12, 0xec, 0xce, 0x04, 0xc4, 0x36, 0x02, 0x77, 0x35, 0xa5, + 0x67, 0x89, 0xb4, 0xd0, 0xa7, 0x00, 0x11, 0x29, 0x81, 0x92, 0x3b, 0x65, 0xae, 0x8f, 0x51, 0x0a, + 0x81, 0x0a, 0x56, 0x7c, 0x40, 0x1b, 0x70, 0x45, 0xd0, 0x79, 0x45, 0x7c, 0xce, 0x6c, 0xcf, 0x74, + 0xd5, 0xbc, 0x84, 0x7b, 0x30, 0x01, 0xa9, 0xd5, 0x38, 0x67, 0x35, 0xa5, 0x97, 0xc8, 0xd0, 0x19, + 0x7d, 0x01, 0xe5, 0x88, 0xe0, 0x00, 0xb7, 0x20, 0x71, 0x6b, 0x93, 0xd1, 0x1c, 0x86, 0x9e, 0xb5, + 0x46, 0x5d, 0x4b, 0x59, 0x98, 0xb2, 0x4c, 0x6e, 0x56, 0x5f, 0x40, 0x3e, 0xee, 0x19, 0x5a, 0x83, + 0xa2, 0xf0, 0x19, 0x7d, 0x46, 0x28, 0xf7, 0x55, 0x45, 0xce, 0xe2, 0x24, 0x45, 0x2c, 0x9b, 0xdc, + 0x6c, 0x8b, 0x24, 0x1d, 0xac, 0xd8, 0xf4, 0xab, 0x06, 0x14, 0x87, 0x5a, 0x88, 0xda, 0x49, 0xe8, + 0x13, 0x96, 0x92, 0xfc, 0x80, 0x3f, 0x15, 0xc8, 0x86, 0x7d, 0x3d, 0x67, 0xea,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2b, 0xca, + 0x9b, 0xfd, 0x8a, 0xf2, 0x76, 0xbf, 0xa2, 0x7c, 0x77, 0x50, 0x49, 0xbd, 0x39, 0xa8, 0xa4, 0x7e, + 0x3b, 0xa8, 0xa4, 0xe0, 0x16, 0x61, 0x63, 0xf6, 0x6d, 0xa9, 0x14, 0x7d, 0xc0, 0xb7, 0xc5, 0x45, + 0x5b, 0xf9, 0x7c, 0xfd, 0x3c, 0x74, 0x1c, 0xfc, 0x73, 0xa7, 0x9b, 0x95, 0xde, 0xc7, 0xff, 0x06, + 0x00, 0x00, 0xff, 0xff, 0x70, 0x04, 0x32, 0x6e, 0x05, 0x12, 0x00, 0x00, } func (m *ResourceMetrics) Marshal() (dAtA []byte, err error) { @@ -2484,13 +2476,16 @@ func (m *IntExemplar) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.TraceId) > 0 { - i -= len(m.TraceId) - copy(dAtA[i:], m.TraceId) - i = encodeVarintMetrics(dAtA, i, uint64(len(m.TraceId))) - i-- - dAtA[i] = 0x2a + { + size := m.TraceId.Size() + i -= size + if _, err := m.TraceId.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintMetrics(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x2a if len(m.SpanId) > 0 { i -= len(m.SpanId) copy(dAtA[i:], m.SpanId) @@ -2547,13 +2542,16 @@ func (m *DoubleExemplar) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.TraceId) > 0 { - i -= len(m.TraceId) - copy(dAtA[i:], m.TraceId) - i = encodeVarintMetrics(dAtA, i, uint64(len(m.TraceId))) - i-- - dAtA[i] = 0x2a + { + size := m.TraceId.Size() + i -= size + if _, err := m.TraceId.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintMetrics(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x2a if len(m.SpanId) > 0 { i -= len(m.SpanId) copy(dAtA[i:], m.SpanId) @@ -3003,10 +3001,8 @@ func (m *IntExemplar) Size() (n int) { if l > 0 { n += 1 + l + sovMetrics(uint64(l)) } - l = len(m.TraceId) - if l > 0 { - n += 1 + l + sovMetrics(uint64(l)) - } + l = m.TraceId.Size() + n += 1 + l + sovMetrics(uint64(l)) return n } @@ -3032,10 +3028,8 @@ func (m *DoubleExemplar) Size() (n int) { if l > 0 { n += 1 + l + sovMetrics(uint64(l)) } - l = len(m.TraceId) - if l > 0 { - n += 1 + l + sovMetrics(uint64(l)) - } + l = m.TraceId.Size() + n += 1 + l + sovMetrics(uint64(l)) return n } @@ -5272,9 +5266,8 @@ func (m *IntExemplar) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.TraceId = append(m.TraceId[:0], dAtA[iNdEx:postIndex]...) - if m.TraceId == nil { - m.TraceId = []byte{} + if err := m.TraceId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex default: @@ -5448,9 +5441,8 @@ func (m *DoubleExemplar) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.TraceId = append(m.TraceId[:0], dAtA[iNdEx:postIndex]...) - if m.TraceId == nil { - m.TraceId = []byte{} + if err := m.TraceId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex default: 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 d16713c4698..1ddf1c91ae0 100644 --- a/internal/data/opentelemetry-proto-gen/trace/v1/trace.pb.go +++ b/internal/data/opentelemetry-proto-gen/trace/v1/trace.pb.go @@ -13,6 +13,7 @@ import ( _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" + go_opentelemetry_io_collector_internal_data_opentelemetry_proto_gen_common_v1 "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/common/v1" v11 "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/common/v1" v1 "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/resource/v1" ) @@ -283,7 +284,7 @@ type Span struct { // random trace_id if empty or invalid trace_id was received. // // This field is required. - TraceId []byte `protobuf:"bytes,1,opt,name=trace_id,json=traceId,proto3" json:"trace_id,omitempty"` + TraceId go_opentelemetry_io_collector_internal_data_opentelemetry_proto_gen_common_v1.TraceID `protobuf:"bytes,1,opt,name=trace_id,json=traceId,proto3,customtype=go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/common/v1.TraceID" json:"trace_id"` // A unique identifier for a span within a trace, assigned when the span // is created. The ID is an 8-byte array. An ID with all zeroes is considered // invalid. @@ -395,13 +396,6 @@ func (m *Span) XXX_DiscardUnknown() { var xxx_messageInfo_Span proto.InternalMessageInfo -func (m *Span) GetTraceId() []byte { - if m != nil { - return m.TraceId - } - return nil -} - func (m *Span) GetSpanId() []byte { if m != nil { return m.SpanId @@ -583,7 +577,7 @@ func (m *Span_Event) GetDroppedAttributesCount() uint32 { type Span_Link struct { // A unique identifier of a trace that this linked span is part of. The ID is a // 16-byte array. - TraceId []byte `protobuf:"bytes,1,opt,name=trace_id,json=traceId,proto3" json:"trace_id,omitempty"` + TraceId go_opentelemetry_io_collector_internal_data_opentelemetry_proto_gen_common_v1.TraceID `protobuf:"bytes,1,opt,name=trace_id,json=traceId,proto3,customtype=go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/common/v1.TraceID" json:"trace_id"` // A unique identifier for the linked span. The ID is an 8-byte array. SpanId []byte `protobuf:"bytes,2,opt,name=span_id,json=spanId,proto3" json:"span_id,omitempty"` // The trace_state associated with the link. @@ -628,13 +622,6 @@ func (m *Span_Link) XXX_DiscardUnknown() { var xxx_messageInfo_Span_Link proto.InternalMessageInfo -func (m *Span_Link) GetTraceId() []byte { - if m != nil { - return m.TraceId - } - return nil -} - func (m *Span_Link) GetSpanId() []byte { if m != nil { return m.SpanId @@ -736,78 +723,81 @@ func init() { } var fileDescriptor_5c407ac9c675a601 = []byte{ - // 1133 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0x4d, 0x6f, 0xdb, 0x46, - 0x10, 0x35, 0x6d, 0x4a, 0x76, 0xc6, 0x1f, 0x61, 0x36, 0x69, 0xcc, 0xd8, 0x89, 0xac, 0xaa, 0x01, + // 1172 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x56, 0xcd, 0x6e, 0xdb, 0x46, + 0x10, 0x36, 0x6d, 0x49, 0x76, 0xc6, 0x3f, 0x61, 0x36, 0x69, 0xcc, 0xd8, 0x89, 0xa4, 0xaa, 0x01, 0xaa, 0x36, 0x88, 0x54, 0x3b, 0x2d, 0x90, 0x02, 0x2d, 0x1a, 0x9a, 0x5c, 0x27, 0x84, 0x69, 0x52, - 0x58, 0x92, 0x6e, 0xda, 0x0b, 0x41, 0x9b, 0x5b, 0x97, 0x88, 0xb4, 0x14, 0x48, 0xca, 0x48, 0x0e, - 0xfd, 0x0f, 0xbd, 0xe4, 0x50, 0xa0, 0x3f, 0xa7, 0x40, 0x7b, 0xcc, 0xa5, 0x40, 0x4f, 0x45, 0x91, - 0xfc, 0x90, 0x16, 0xbb, 0xa4, 0x6c, 0x51, 0x75, 0x94, 0x5c, 0x7c, 0xb1, 0x97, 0x6f, 0xde, 0x9b, - 0x37, 0x33, 0x3b, 0x84, 0x08, 0xed, 0x64, 0x48, 0x59, 0x4e, 0xfb, 0x74, 0x40, 0xf3, 0xf4, 0x45, - 0x77, 0x98, 0x26, 0x79, 0xd2, 0xcd, 0xd3, 0xf0, 0x98, 0x76, 0x4f, 0xb7, 0x8b, 0x43, 0x47, 0x80, - 0xe8, 0x76, 0x85, 0x59, 0x80, 0x9d, 0x82, 0x70, 0xba, 0xbd, 0xf1, 0xf9, 0x49, 0x9c, 0xff, 0x38, - 0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c, 0xe1, 0x68, 0xfd, 0x72, 0x87, 0x97, 0xd1, 0x3a, 0xac, 0x16, 0xe9, 0xfa, 0x9e, + 0x6e, 0xd9, 0xfa, 0x96, 0x8d, 0xd5, 0x95, 0x49, 0xe7, 0x4c, 0xdd, 0xd7, 0x43, 0xdb, 0xf5, 0x3c, + 0xf5, 0x22, 0xaa, 0xc1, 0xfa, 0x04, 0x2f, 0xf0, 0x1f, 0x60, 0xc7, 0xb7, 0x0c, 0x5d, 0x08, 0xab, + 0x5b, 0xcf, 0x94, 0xe7, 0x27, 0x55, 0xe5, 0xc5, 0x49, 0x55, 0xf9, 0xf3, 0xa4, 0xaa, 0xfc, 0xf8, + 0xaa, 0x3a, 0xf3, 0xe2, 0x55, 0x75, 0xe6, 0xf7, 0x57, 0xd5, 0x19, 0xa8, 0xc5, 0xc9, 0xd4, 0x2d, + 0xdc, 0x02, 0xf9, 0xa2, 0xe8, 0x88, 0x60, 0x47, 0xf9, 0xd6, 0xfe, 0x2f, 0xde, 0x47, 0xa3, 0x1f, + 0xdb, 0xfb, 0x15, 0x19, 0xbb, 0xf3, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7d, 0x0f, 0x03, 0xf1, + 0x93, 0x0b, 0x00, 0x00, } func (m *ResourceSpans) Marshal() (dAtA []byte, err error) { @@ -1042,13 +1032,16 @@ func (m *Span) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x12 } - if len(m.TraceId) > 0 { - i -= len(m.TraceId) - copy(dAtA[i:], m.TraceId) - i = encodeVarintTrace(dAtA, i, uint64(len(m.TraceId))) - i-- - dAtA[i] = 0xa + { + size := m.TraceId.Size() + i -= size + if _, err := m.TraceId.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTrace(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -1160,13 +1153,16 @@ func (m *Span_Link) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x12 } - if len(m.TraceId) > 0 { - i -= len(m.TraceId) - copy(dAtA[i:], m.TraceId) - i = encodeVarintTrace(dAtA, i, uint64(len(m.TraceId))) - i-- - dAtA[i] = 0xa + { + size := m.TraceId.Size() + i -= size + if _, err := m.TraceId.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTrace(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -1260,10 +1256,8 @@ func (m *Span) Size() (n int) { } var l int _ = l - l = len(m.TraceId) - if l > 0 { - n += 1 + l + sovTrace(uint64(l)) - } + l = m.TraceId.Size() + n += 1 + l + sovTrace(uint64(l)) l = len(m.SpanId) if l > 0 { n += 1 + l + sovTrace(uint64(l)) @@ -1354,10 +1348,8 @@ func (m *Span_Link) Size() (n int) { } var l int _ = l - l = len(m.TraceId) - if l > 0 { - n += 1 + l + sovTrace(uint64(l)) - } + l = m.TraceId.Size() + n += 1 + l + sovTrace(uint64(l)) l = len(m.SpanId) if l > 0 { n += 1 + l + sovTrace(uint64(l)) @@ -1704,9 +1696,8 @@ func (m *Span) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.TraceId = append(m.TraceId[:0], dAtA[iNdEx:postIndex]...) - if m.TraceId == nil { - m.TraceId = []byte{} + if err := m.TraceId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex case 2: @@ -2305,9 +2296,8 @@ func (m *Span_Link) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.TraceId = append(m.TraceId[:0], dAtA[iNdEx:postIndex]...) - if m.TraceId == nil { - m.TraceId = []byte{} + if err := m.TraceId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } iNdEx = postIndex case 2: diff --git a/internal/data/testdata/log.go b/internal/data/testdata/log.go index b7f7c607cc2..1eece8d5616 100644 --- a/internal/data/testdata/log.go +++ b/internal/data/testdata/log.go @@ -270,7 +270,7 @@ func fillLogOne(log pdata.LogRecord) { log.SetSeverityNumber(pdata.SeverityNumberINFO) log.SetSeverityText("Info") log.SetSpanID([]byte{0x01, 0x02, 0x04, 0x08}) - log.SetTraceID([]byte{0x08, 0x04, 0x02, 0x01}) + log.SetTraceID(pdata.NewTraceID([]byte{0x08, 0x04, 0x02, 0x01})) attrs := log.Attributes() attrs.InsertString("app", "server") @@ -288,7 +288,7 @@ func generateOtlpLogOne() *otlplogs.LogRecord { SeverityText: "Info", Body: &otlpcommon.AnyValue{Value: &otlpcommon.AnyValue_StringValue{StringValue: "This is a log message"}}, SpanId: []byte{0x01, 0x02, 0x04, 0x08}, - TraceId: []byte{0x08, 0x04, 0x02, 0x01}, + TraceId: otlpcommon.NewTraceID([]byte{0x08, 0x04, 0x02, 0x01}), Attributes: []*otlpcommon.KeyValue{ { Key: "app", diff --git a/internal/goldendataset/generator_commons.go b/internal/goldendataset/generator_commons.go index 919341ea5d3..db09852b81d 100644 --- a/internal/goldendataset/generator_commons.go +++ b/internal/goldendataset/generator_commons.go @@ -93,13 +93,13 @@ func loadPictOutputFile(fileName string) ([][]string, error) { return reader.ReadAll() } -func generateTraceID(random io.Reader) []byte { +func generateTraceID(random io.Reader) otlpcommon.TraceID { var r [16]byte _, err := random.Read(r[:]) if err != nil { panic(err) } - return r[:] + return otlpcommon.NewTraceID(r[:]) } func generateSpanID(random io.Reader) []byte { diff --git a/internal/goldendataset/span_generator.go b/internal/goldendataset/span_generator.go index 070a0c5ccd2..dc96657d385 100644 --- a/internal/goldendataset/span_generator.go +++ b/internal/goldendataset/span_generator.go @@ -84,7 +84,7 @@ func GenerateSpans(count int, startPos int, pictFile string, random io.Reader) ( index := startPos + 1 var inputs []string var spanInputs *PICTSpanInputs - var traceID []byte + var traceID otlpcommon.TraceID var parentID []byte for i := 0; i < count; i++ { if index >= pairsTotal { @@ -106,7 +106,7 @@ func GenerateSpans(count int, startPos int, pictFile string, random io.Reader) ( parentID = nil case SpanParentChild: // use existing if available - if traceID == nil { + if traceID.Bytes() == nil { traceID = generateTraceID(random) } if parentID == nil { @@ -134,7 +134,7 @@ func generateSpanName(spanInputs *PICTSpanInputs) string { // random - the random number generator to use in generating ID values // // The generated span is returned. -func GenerateSpan(traceID []byte, parentID []byte, spanName string, spanInputs *PICTSpanInputs, +func GenerateSpan(traceID otlpcommon.TraceID, parentID []byte, spanName string, spanInputs *PICTSpanInputs, random io.Reader) *otlptrace.Span { endTime := time.Now().Add(-50 * time.Microsecond) return &otlptrace.Span{ diff --git a/processor/groupbytraceprocessor/processor.go b/processor/groupbytraceprocessor/processor.go index 36d30a5fa74..e7cfdf8a875 100644 --- a/processor/groupbytraceprocessor/processor.go +++ b/processor/groupbytraceprocessor/processor.go @@ -124,7 +124,8 @@ func (sp *groupByTraceProcessor) processResourceSpans(rs pdata.ResourceSpans) er for _, batch := range splitByTrace(rs) { if err := sp.processBatch(batch); err != nil { - sp.logger.Info("failed to process batch", zap.Error(err), zap.Stringer("traceID", batch.traceID)) + sp.logger.Info("failed to process batch", zap.Error(err), + zap.String("traceID", batch.traceID.HexString())) } } @@ -148,7 +149,7 @@ func (sp *groupByTraceProcessor) processBatch(batch *singleTraceBatch) error { // place the trace ID in the buffer, and check if an item had to be evicted evicted := sp.ringBuffer.put(traceID) - if evicted != nil { + if evicted.Bytes() != nil { // delete from the storage sp.eventMachine.fire(event{ typ: traceRemoved, @@ -156,7 +157,8 @@ func (sp *groupByTraceProcessor) processBatch(batch *singleTraceBatch) error { }) // TODO: do we want another channel that receives evicted items? record a metric perhaps? - sp.logger.Info("trace evicted: in order to avoid this in the future, adjust the wait duration and/or number of traces to keep in memory", zap.Stringer("traceID", evicted)) + sp.logger.Info("trace evicted: in order to avoid this in the future, adjust the wait duration and/or number of traces to keep in memory", + zap.String("traceID", evicted.HexString())) } // we have the traceID in the memory, place the spans in the storage too @@ -178,12 +180,14 @@ func (sp *groupByTraceProcessor) processBatch(batch *singleTraceBatch) error { } func (sp *groupByTraceProcessor) onTraceExpired(traceID pdata.TraceID) error { - sp.logger.Debug("processing expired", zap.Stringer("traceID", traceID)) + sp.logger.Debug("processing expired", zap.String("traceID", + traceID.HexString())) if !sp.ringBuffer.contains(traceID) { // we likely received multiple batches with spans for the same trace // and released this trace already - sp.logger.Debug("skipping the processing of expired trace", zap.Stringer("traceID", traceID)) + sp.logger.Debug("skipping the processing of expired trace", + zap.String("traceID", traceID.HexString())) return nil } @@ -191,7 +195,8 @@ func (sp *groupByTraceProcessor) onTraceExpired(traceID pdata.TraceID) error { sp.ringBuffer.delete(traceID) // this might block, but we don't need to wait - sp.logger.Debug("marking the trace as released", zap.Stringer("traceID", traceID)) + sp.logger.Debug("marking the trace as released", + zap.String("traceID", traceID.HexString())) go sp.markAsReleased(traceID) return nil @@ -209,7 +214,7 @@ func (sp *groupByTraceProcessor) markAsReleased(traceID pdata.TraceID) error { } // signal that the trace is ready to be released - sp.logger.Debug("trace marked as released", zap.Stringer("traceID", traceID)) + sp.logger.Debug("trace marked as released", zap.String("traceID", traceID.HexString())) // atomically fire the two events, so that a concurrent shutdown won't leave // an orphaned trace in the storage @@ -234,18 +239,18 @@ func (sp *groupByTraceProcessor) onTraceReleased(rss []pdata.ResourceSpans) erro func (sp *groupByTraceProcessor) onTraceRemoved(traceID pdata.TraceID) error { trace, err := sp.st.delete(traceID) if err != nil { - return fmt.Errorf("couldn't delete trace %q from the storage: %w", traceID.String(), err) + return fmt.Errorf("couldn't delete trace %q from the storage: %w", traceID.HexString(), err) } if trace == nil { - return fmt.Errorf("trace %q not found at the storage", traceID.String()) + return fmt.Errorf("trace %q not found at the storage", traceID.HexString()) } return nil } func (sp *groupByTraceProcessor) addSpans(traceID pdata.TraceID, trace pdata.ResourceSpans) error { - sp.logger.Debug("creating trace at the storage", zap.Stringer("traceID", traceID)) + sp.logger.Debug("creating trace at the storage", zap.String("traceID", traceID.HexString())) return sp.st.createOrAppend(traceID, trace) } @@ -266,13 +271,13 @@ func splitByTrace(rs pdata.ResourceSpans) []*singleTraceBatch { ils := rs.InstrumentationLibrarySpans().At(i) for j := 0; j < ils.Spans().Len(); j++ { span := ils.Spans().At(j) - if span.TraceID() == nil { + if span.TraceID().Bytes() == nil { // this should have already been caught before our processor, but let's // protect ourselves against bad clients continue } - sTraceID := span.TraceID().String() + sTraceID := span.TraceID().HexString() // for the first traceID in the ILS, initialize the map entry // and add the singleTraceBatch to the result list diff --git a/processor/groupbytraceprocessor/processor_test.go b/processor/groupbytraceprocessor/processor_test.go index 55cfb92df43..31a759fd4bb 100644 --- a/processor/groupbytraceprocessor/processor_test.go +++ b/processor/groupbytraceprocessor/processor_test.go @@ -28,6 +28,7 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/consumer/pdata" + otlpcommon "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/common/v1" v1 "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/trace/v1" ) @@ -40,7 +41,7 @@ func TestTraceIsDispatchedAfterDuration(t *testing.T) { traces := []*v1.ResourceSpans{{ InstrumentationLibrarySpans: []*v1.InstrumentationLibrarySpans{{ Spans: []*v1.Span{{ - TraceId: []byte{1, 2, 3, 4}, // no need to be 100% correct here + TraceId: otlpcommon.NewTraceID([]byte{1, 2, 3, 4}), // no need to be 100% correct here }}, }}, }} @@ -121,7 +122,7 @@ func TestInternalCacheLimit(t *testing.T) { defer p.Shutdown(ctx) // test - traceIDs := []pdata.TraceID{ + traceIDs := [][]byte{ {1, 2, 3, 4}, {2, 3, 4, 5}, {3, 4, 5, 6}, @@ -135,7 +136,7 @@ func TestInternalCacheLimit(t *testing.T) { batch := []*v1.ResourceSpans{{ InstrumentationLibrarySpans: []*v1.InstrumentationLibrarySpans{{ Spans: []*v1.Span{{ - TraceId: traceID, + TraceId: otlpcommon.NewTraceID(traceID), }}, }}, }} @@ -150,7 +151,7 @@ func TestInternalCacheLimit(t *testing.T) { assert.Equal(t, 5, len(receivedTraceIDs)) for i := 5; i > 0; i-- { // last 5 traces - traceID := traceIDs[i] + traceID := pdata.NewTraceID(traceIDs[i]) assert.Contains(t, receivedTraceIDs, traceID) } @@ -231,7 +232,7 @@ func TestTraceDisappearedFromStorageBeforeReleasing(t *testing.T) { require.NoError(t, err) require.NotNil(t, p) - traceID := []byte{1, 2, 3, 4} + traceID := otlpcommon.NewTraceID([]byte{1, 2, 3, 4}) batch := []*v1.ResourceSpans{{ InstrumentationLibrarySpans: []*v1.InstrumentationLibrarySpans{{ Spans: []*v1.Span{{ @@ -249,7 +250,7 @@ func TestTraceDisappearedFromStorageBeforeReleasing(t *testing.T) { // test // we trigger this manually, instead of waiting the whole duration - err = p.markAsReleased(traceID) + err = p.markAsReleased(pdata.TraceID(traceID)) // verify assert.Error(t, err) @@ -273,7 +274,7 @@ func TestTraceErrorFromStorageWhileReleasing(t *testing.T) { require.NoError(t, err) require.NotNil(t, p) - traceID := []byte{1, 2, 3, 4} + traceID := otlpcommon.NewTraceID([]byte{1, 2, 3, 4}) batch := []*v1.ResourceSpans{{ InstrumentationLibrarySpans: []*v1.InstrumentationLibrarySpans{{ Spans: []*v1.Span{{ @@ -291,7 +292,7 @@ func TestTraceErrorFromStorageWhileReleasing(t *testing.T) { // test // we trigger this manually, instead of waiting the whole duration - err = p.markAsReleased(traceID) + err = p.markAsReleased(pdata.TraceID(traceID)) // verify assert.True(t, errors.Is(err, expectedError)) @@ -383,7 +384,7 @@ func TestAddSpansToExistingTrace(t *testing.T) { p.Start(ctx, nil) defer p.Shutdown(ctx) - traceID := []byte{1, 2, 3, 4} + traceID := otlpcommon.NewTraceID([]byte{1, 2, 3, 4}) // test first := []*v1.ResourceSpans{{ @@ -474,7 +475,7 @@ func TestErrorFromStorageWhileRemovingTrace(t *testing.T) { require.NoError(t, err) require.NotNil(t, p) - traceID := []byte{1, 2, 3, 4} + traceID := pdata.NewTraceID([]byte{1, 2, 3, 4}) // test err = p.onTraceRemoved(traceID) @@ -500,7 +501,7 @@ func TestTraceNotFoundWhileRemovingTrace(t *testing.T) { require.NoError(t, err) require.NotNil(t, p) - traceID := []byte{1, 2, 3, 4} + traceID := pdata.NewTraceID([]byte{1, 2, 3, 4}) // test err = p.onTraceRemoved(traceID) @@ -547,8 +548,7 @@ func TestTracesAreDispatchedInIndividualBatches(t *testing.T) { span := ils.Spans().At(0) span.SetTraceID(traceID) - secondTraceID := []byte{2, 3, 4, 5} - + secondTraceID := pdata.NewTraceID([]byte{2, 3, 4, 5}) secondResourceSpans := pdata.NewResourceSpans() secondResourceSpans.InitEmpty() secondResourceSpans.InstrumentationLibrarySpans().Resize(1) @@ -588,10 +588,10 @@ func TestSplitSameTraceIntoDifferentBatches(t *testing.T) { firstILS.Spans().Resize(2) firstSpan := firstILS.Spans().At(0) firstSpan.SetName("first-batch-first-span") - firstSpan.SetTraceID([]byte{1, 2, 3, 4}) + firstSpan.SetTraceID(pdata.NewTraceID([]byte{1, 2, 3, 4})) secondSpan := firstILS.Spans().At(1) secondSpan.SetName("first-batch-second-span") - secondSpan.SetTraceID([]byte{1, 2, 3, 4}) + secondSpan.SetTraceID(pdata.NewTraceID([]byte{1, 2, 3, 4})) // the second ILS has one span secondILS := input.InstrumentationLibrarySpans().At(1) @@ -601,7 +601,7 @@ func TestSplitSameTraceIntoDifferentBatches(t *testing.T) { secondILS.Spans().Resize(1) thirdSpan := secondILS.Spans().At(0) thirdSpan.SetName("second-batch-first-span") - thirdSpan.SetTraceID([]byte{1, 2, 3, 4}) + thirdSpan.SetTraceID(pdata.NewTraceID([]byte{1, 2, 3, 4})) // test batches := splitByTrace(input) @@ -637,10 +637,10 @@ func TestSplitDifferentTracesIntoDifferentBatches(t *testing.T) { ils.Spans().Resize(2) firstSpan := ils.Spans().At(0) firstSpan.SetName("first-batch-first-span") - firstSpan.SetTraceID([]byte{1, 2, 3, 4}) + firstSpan.SetTraceID(pdata.NewTraceID([]byte{1, 2, 3, 4})) secondSpan := ils.Spans().At(1) secondSpan.SetName("first-batch-second-span") - secondSpan.SetTraceID([]byte{2, 3, 4, 5}) + secondSpan.SetTraceID(pdata.NewTraceID([]byte{2, 3, 4, 5})) // test batches := splitByTrace(input) @@ -667,7 +667,7 @@ func TestSplitByTraceWithNilTraceID(t *testing.T) { ils := input.InstrumentationLibrarySpans().At(0) ils.Spans().Resize(1) firstSpan := ils.Spans().At(0) - firstSpan.SetTraceID(nil) + firstSpan.SetTraceID(pdata.NewTraceID(nil)) // test batches := splitByTrace(input) @@ -733,7 +733,7 @@ func BenchmarkConsumeTracesCompleteOnFirstBatch(b *testing.B) { defer p.Shutdown(ctx) for n := 0; n < b.N; n++ { - traceID := []byte{byte(1 + n), 2, 3, 4} + traceID := otlpcommon.NewTraceID([]byte{byte(1 + n), 2, 3, 4}) trace := []*v1.ResourceSpans{{ InstrumentationLibrarySpans: []*v1.InstrumentationLibrarySpans{{ Spans: []*v1.Span{{ diff --git a/processor/groupbytraceprocessor/ring_buffer.go b/processor/groupbytraceprocessor/ring_buffer.go index bed3f283ca5..d0928a44650 100644 --- a/processor/groupbytraceprocessor/ring_buffer.go +++ b/processor/groupbytraceprocessor/ring_buffer.go @@ -40,31 +40,31 @@ func (r *ringBuffer) put(traceID pdata.TraceID) pdata.TraceID { // see if the ring has an item already evicted := r.ids[r.index] - if evicted != nil { + if evicted.Bytes() != nil { // clear space for the new item r.delete(evicted) } // place the traceID in memory r.ids[r.index] = traceID - r.idToIndex[traceID.String()] = r.index + r.idToIndex[traceID.HexString()] = r.index return evicted } func (r *ringBuffer) contains(traceID pdata.TraceID) bool { - _, found := r.idToIndex[traceID.String()] + _, found := r.idToIndex[traceID.HexString()] return found } func (r *ringBuffer) delete(traceID pdata.TraceID) bool { - sTraceID := traceID.String() + sTraceID := traceID.HexString() index, found := r.idToIndex[sTraceID] if !found { return false } delete(r.idToIndex, sTraceID) - r.ids[index] = nil + r.ids[index] = pdata.NewTraceID(nil) return true } diff --git a/processor/groupbytraceprocessor/ring_buffer_test.go b/processor/groupbytraceprocessor/ring_buffer_test.go index cc4c53de481..ee92fffc0bd 100644 --- a/processor/groupbytraceprocessor/ring_buffer_test.go +++ b/processor/groupbytraceprocessor/ring_buffer_test.go @@ -28,12 +28,12 @@ func TestRingBufferCapacity(t *testing.T) { // test traceIDs := []pdata.TraceID{ - {1, 2, 3, 4}, - {2, 3, 4, 5}, - {3, 4, 5, 6}, - {4, 5, 6, 7}, - {5, 6, 7, 8}, - {6, 7, 8, 9}, + pdata.NewTraceID([]byte{1, 2, 3, 4}), + pdata.NewTraceID([]byte{2, 3, 4, 5}), + pdata.NewTraceID([]byte{3, 4, 5, 6}), + pdata.NewTraceID([]byte{4, 5, 6, 7}), + pdata.NewTraceID([]byte{5, 6, 7, 8}), + pdata.NewTraceID([]byte{6, 7, 8, 9}), } for _, traceID := range traceIDs { buffer.put(traceID) diff --git a/processor/groupbytraceprocessor/storage_memory.go b/processor/groupbytraceprocessor/storage_memory.go index 9c7872b1ee3..8012198f90b 100644 --- a/processor/groupbytraceprocessor/storage_memory.go +++ b/processor/groupbytraceprocessor/storage_memory.go @@ -41,7 +41,7 @@ func (st *memoryStorage) createOrAppend(traceID pdata.TraceID, rs pdata.Resource return errStorageNilResourceSpans } - sTraceID := traceID.String() + sTraceID := traceID.HexString() st.Lock() if _, ok := st.content[sTraceID]; !ok { @@ -57,7 +57,7 @@ func (st *memoryStorage) createOrAppend(traceID pdata.TraceID, rs pdata.Resource return nil } func (st *memoryStorage) get(traceID pdata.TraceID) ([]pdata.ResourceSpans, error) { - sTraceID := traceID.String() + sTraceID := traceID.HexString() st.RLock() rss, ok := st.content[sTraceID] @@ -79,7 +79,7 @@ func (st *memoryStorage) get(traceID pdata.TraceID) ([]pdata.ResourceSpans, erro // delete will return a reference to a ResourceSpans. Changes to the returned object may not be applied // to the version in the storage. func (st *memoryStorage) delete(traceID pdata.TraceID) ([]pdata.ResourceSpans, error) { - sTraceID := traceID.String() + sTraceID := traceID.HexString() st.Lock() rss := st.content[sTraceID] diff --git a/processor/groupbytraceprocessor/storage_memory_test.go b/processor/groupbytraceprocessor/storage_memory_test.go index 12a6d6bd286..a3202dcfa3a 100644 --- a/processor/groupbytraceprocessor/storage_memory_test.go +++ b/processor/groupbytraceprocessor/storage_memory_test.go @@ -27,9 +27,9 @@ func TestMemoryCreateAndGetTrace(t *testing.T) { // prepare st := newMemoryStorage() - traceIDs := [][]byte{ - {1, 2, 3, 4}, - {2, 3, 4, 5}, + traceIDs := []pdata.TraceID{ + pdata.NewTraceID([]byte{1, 2, 3, 4}), + pdata.NewTraceID([]byte{2, 3, 4, 5}), } baseTrace := pdata.NewResourceSpans() @@ -41,7 +41,7 @@ func TestMemoryCreateAndGetTrace(t *testing.T) { // test for _, traceID := range traceIDs { - span.SetTraceID(pdata.NewTraceID(traceID)) + span.SetTraceID(traceID) st.createOrAppend(traceID, baseTrace) } @@ -171,7 +171,7 @@ func TestMemoryTraceIsBeingCloned(t *testing.T) { func TestCreateWithNilParameter(t *testing.T) { // prepare st := newMemoryStorage() - traceID := []byte{1, 2, 3, 4} + traceID := pdata.NewTraceID([]byte{1, 2, 3, 4}) // test err := st.createOrAppend(traceID, pdata.NewResourceSpans()) diff --git a/processor/samplingprocessor/probabilisticsamplerprocessor/probabilisticsampler.go b/processor/samplingprocessor/probabilisticsamplerprocessor/probabilisticsampler.go index cd6cd89ee7f..07c99da666a 100644 --- a/processor/samplingprocessor/probabilisticsamplerprocessor/probabilisticsampler.go +++ b/processor/samplingprocessor/probabilisticsamplerprocessor/probabilisticsampler.go @@ -112,7 +112,7 @@ func (tsp *tracesamplerprocessor) processTraces(ctx context.Context, resourceSpa // with various different criteria to generate trace id and perhaps were already sampled without hashing. // Hashing here prevents bias due to such systems. sampled := sp == mustSampleSpan || - hash(span.TraceID(), tsp.hashSeed)&bitMaskHashBuckets < scaledSamplingRate + hash(span.TraceID().Bytes(), tsp.hashSeed)&bitMaskHashBuckets < scaledSamplingRate if sampled { spns.Append(span) diff --git a/processor/samplingprocessor/probabilisticsamplerprocessor/probabilisticsampler_test.go b/processor/samplingprocessor/probabilisticsamplerprocessor/probabilisticsampler_test.go index a84cc592dba..a095d7e32c2 100644 --- a/processor/samplingprocessor/probabilisticsamplerprocessor/probabilisticsampler_test.go +++ b/processor/samplingprocessor/probabilisticsamplerprocessor/probabilisticsampler_test.go @@ -464,7 +464,7 @@ func genRandomTestData(numBatches, numTracesPerBatch int, serviceName string, re for k := 0; k < numTracesPerBatch; k++ { span := ils.Spans().At(k) - span.SetTraceID(tracetranslator.UInt64ToByteTraceID(r.Uint64(), r.Uint64())) + span.SetTraceID(tracetranslator.UInt64ToTraceID(r.Uint64(), r.Uint64())) span.SetSpanID(tracetranslator.UInt64ToByteSpanID(r.Uint64())) attributes := make(map[string]pdata.AttributeValue) attributes[tracetranslator.TagHTTPStatusCode] = pdata.NewAttributeValueInt(404) @@ -502,7 +502,7 @@ func assertSampledData(t *testing.T, sampled []pdata.Traces, serviceName string) for k := 0; k < ils.Spans().Len(); k++ { spanCount++ span := ils.Spans().At(k) - key := string(span.TraceID()) + key := string(span.TraceID().Bytes()) if traceIDs[key] { t.Errorf("same traceID used more than once %q", key) return diff --git a/processor/samplingprocessor/tailsamplingprocessor/idbatcher/id_batcher.go b/processor/samplingprocessor/tailsamplingprocessor/idbatcher/id_batcher.go index 2bfac74607b..d18baaaa264 100644 --- a/processor/samplingprocessor/tailsamplingprocessor/idbatcher/id_batcher.go +++ b/processor/samplingprocessor/tailsamplingprocessor/idbatcher/id_batcher.go @@ -19,6 +19,8 @@ package idbatcher import ( "errors" "sync" + + "go.opentelemetry.io/collector/consumer/pdata" ) var ( @@ -28,11 +30,8 @@ var ( ErrInvalidBatchChannelSize = errors.New("invalid batch channel size, it must be greater than zero") ) -// ID is the type of each element in the batch. -type ID []byte - // Batch is the type of batches held by the Batcher. -type Batch []ID +type Batch []pdata.TraceID // Batcher behaves like a pipeline of batches that has a fixed number of batches in the pipe // and a new batch being built outside of the pipe. Items can be concurrently added to the batch @@ -45,7 +44,7 @@ type Batcher interface { // of limiting the growth of the current batch if appropriate for its scenario. It can // either call CloseCurrentAndTakeFirstBatch earlier or stop adding new items depending on what is // required by the scenario. - AddToCurrentBatch(id ID) + AddToCurrentBatch(id pdata.TraceID) // CloseCurrentAndTakeFirstBatch takes the batch at the front of the pipe, and moves the current // batch to the end of the pipe, creating a new batch to receive new items. This operation should // be atomic. @@ -60,8 +59,8 @@ type Batcher interface { var _ Batcher = (*batcher)(nil) type batcher struct { - pendingIds chan ID // Channel for the ids to be added to the next batch. - batches chan Batch // Channel with already captured batches. + pendingIds chan pdata.TraceID // Channel for the ids to be added to the next batch. + batches chan Batch // Channel with already captured batches. // cbMutex protects the currentBatch storing ids. cbMutex sync.Mutex @@ -93,7 +92,7 @@ func New(numBatches, newBatchesInitialCapacity, batchChannelSize uint64) (Batche } batcher := &batcher{ - pendingIds: make(chan ID, batchChannelSize), + pendingIds: make(chan pdata.TraceID, batchChannelSize), batches: batches, currentBatch: make(Batch, 0, newBatchesInitialCapacity), newBatchesInitialCapacity: newBatchesInitialCapacity, @@ -114,7 +113,7 @@ func New(numBatches, newBatchesInitialCapacity, batchChannelSize uint64) (Batche return batcher, nil } -func (b *batcher) AddToCurrentBatch(id ID) { +func (b *batcher) AddToCurrentBatch(id pdata.TraceID) { b.pendingIds <- id } diff --git a/processor/samplingprocessor/tailsamplingprocessor/idbatcher/id_batcher_test.go b/processor/samplingprocessor/tailsamplingprocessor/idbatcher/id_batcher_test.go index ef49f89d022..d1c73dabd58 100644 --- a/processor/samplingprocessor/tailsamplingprocessor/idbatcher/id_batcher_test.go +++ b/processor/samplingprocessor/tailsamplingprocessor/idbatcher/id_batcher_test.go @@ -23,6 +23,7 @@ import ( "github.com/stretchr/testify/require" + "go.opentelemetry.io/collector/consumer/pdata" tracetranslator "go.opentelemetry.io/collector/translator/trace" ) @@ -119,7 +120,7 @@ func concurrencyTest(t *testing.T, numBatches, newBatchesInitialCapacity, batchC wg := &sync.WaitGroup{} for i := 0; i < len(ids); i++ { wg.Add(1) - go func(id []byte) { + go func(id pdata.TraceID) { batcher.AddToCurrentBatch(id) wg.Done() }(ids[i]) @@ -143,18 +144,18 @@ func concurrencyTest(t *testing.T, numBatches, newBatchesInitialCapacity, batchC idSeen := make(map[string]bool, len(ids)) for _, id := range got { - idSeen[string(id)] = true + idSeen[string(id.Bytes())] = true } for i := 0; i < len(ids); i++ { - require.True(t, idSeen[string(ids[i])], "want id %v but id was not seen", ids[i]) + require.True(t, idSeen[string(ids[i].Bytes())], "want id %v but id was not seen", ids[i]) } } -func generateSequentialIds(numIds uint64) [][]byte { - ids := make([][]byte, numIds) +func generateSequentialIds(numIds uint64) []pdata.TraceID { + ids := make([]pdata.TraceID, numIds) for i := uint64(0); i < numIds; i++ { - ids[i] = tracetranslator.UInt64ToByteTraceID(0, i) + ids[i] = tracetranslator.UInt64ToTraceID(0, i) } return ids } diff --git a/processor/samplingprocessor/tailsamplingprocessor/processor.go b/processor/samplingprocessor/tailsamplingprocessor/processor.go index 1bf12c393f5..3301922f286 100644 --- a/processor/samplingprocessor/tailsamplingprocessor/processor.go +++ b/processor/samplingprocessor/tailsamplingprocessor/processor.go @@ -145,7 +145,7 @@ func (tsp *tailSamplingSpanProcessor) samplingPolicyOnTick() { batchLen := len(batch) tsp.logger.Debug("Sampling Policy Evaluation ticked") for _, id := range batch { - d, ok := tsp.idToTrace.Load(traceKey(id)) + d, ok := tsp.idToTrace.Load(traceKey(id.Bytes())) if !ok { idNotFoundOnMapCount++ continue @@ -265,7 +265,7 @@ func (tsp *tailSamplingSpanProcessor) processTraces(td consumerdata.TraceData) e atomic.AddInt64(&actualData.SpanCount, lenSpans) } else { newTraceIDs++ - tsp.decisionBatcher.AddToCurrentBatch([]byte(id)) + tsp.decisionBatcher.AddToCurrentBatch(pdata.NewTraceID([]byte(id))) atomic.AddUint64(&tsp.numTracesOnMap, 1) postDeletion := false currTime := time.Now() @@ -354,7 +354,7 @@ func (tsp *tailSamplingSpanProcessor) dropTrace(traceID traceKey, deletionTime t for j := 0; j < policiesLen; j++ { if trace.Decisions[j] == sampling.Pending { policy := tsp.policies[j] - if decision, err := policy.Evaluator.OnDroppedSpans([]byte(traceID), trace); err != nil { + if decision, err := policy.Evaluator.OnDroppedSpans(pdata.NewTraceID([]byte(traceID)), trace); err != nil { tsp.logger.Warn("OnDroppedSpans", zap.String("policy", policy.Name), zap.Int("decision", int(decision)), diff --git a/processor/samplingprocessor/tailsamplingprocessor/processor_test.go b/processor/samplingprocessor/tailsamplingprocessor/processor_test.go index dbbfa5b3a8f..aa98cd1f0a2 100644 --- a/processor/samplingprocessor/tailsamplingprocessor/processor_test.go +++ b/processor/samplingprocessor/tailsamplingprocessor/processor_test.go @@ -53,7 +53,7 @@ func TestSequentialTraceArrival(t *testing.T) { } for i := range traceIds { - d, ok := tsp.idToTrace.Load(traceKey(traceIds[i])) + d, ok := tsp.idToTrace.Load(traceKey(traceIds[i].Bytes())) require.True(t, ok, "Missing expected traceId") v := d.(*sampling.TraceData) require.Equal(t, int64(i+1), v.SpanCount, "Incorrect number of spans for entry %d", i) @@ -88,7 +88,7 @@ func TestConcurrentTraceArrival(t *testing.T) { wg.Wait() for i := range traceIds { - d, ok := tsp.idToTrace.Load(traceKey(traceIds[i])) + d, ok := tsp.idToTrace.Load(traceKey(traceIds[i].Bytes())) require.True(t, ok, "Missing expected traceId") v := d.(*sampling.TraceData) require.Equal(t, int64(i+1)*2, v.SpanCount, "Incorrect number of spans for entry %d", i) @@ -112,7 +112,7 @@ func TestSequentialTraceMapSize(t *testing.T) { // On sequential insertion it is possible to know exactly which traces should be still on the map. for i := 0; i < len(traceIds)-maxSize; i++ { - _, ok := tsp.idToTrace.Load(traceKey(traceIds[i])) + _, ok := tsp.idToTrace.Load(traceKey(traceIds[i].Bytes())) require.False(t, ok, "Found unexpected traceId[%d] still on map (id: %v)", i, traceIds[i]) } } @@ -205,11 +205,11 @@ func TestSamplingPolicyTypicalPath(t *testing.T) { require.Equal(t, 1, mpe.LateArrivingSpansCount, "policy was not notified of the late span") } -func generateIdsAndBatches(numIds int) ([][]byte, []pdata.Traces) { - traceIds := make([][]byte, numIds) +func generateIdsAndBatches(numIds int) ([]pdata.TraceID, []pdata.Traces) { + traceIds := make([]pdata.TraceID, numIds) var tds []pdata.Traces for i := 0; i < numIds; i++ { - traceIds[i] = tracetranslator.UInt64ToByteTraceID(1, uint64(i+1)) + traceIds[i] = tracetranslator.UInt64ToTraceID(1, uint64(i+1)) // Send each span in a separate batch for j := 0; j <= i; j++ { td := testdata.GenerateTraceDataOneSpan() @@ -237,11 +237,11 @@ func (m *mockPolicyEvaluator) OnLateArrivingSpans(sampling.Decision, []*tracepb. m.LateArrivingSpansCount++ return m.NextError } -func (m *mockPolicyEvaluator) Evaluate([]byte, *sampling.TraceData) (sampling.Decision, error) { +func (m *mockPolicyEvaluator) Evaluate(pdata.TraceID, *sampling.TraceData) (sampling.Decision, error) { m.EvaluationCount++ return m.NextDecision, m.NextError } -func (m *mockPolicyEvaluator) OnDroppedSpans([]byte, *sampling.TraceData) (sampling.Decision, error) { +func (m *mockPolicyEvaluator) OnDroppedSpans(pdata.TraceID, *sampling.TraceData) (sampling.Decision, error) { m.OnDroppedSpansCount++ return m.NextDecision, m.NextError } @@ -280,7 +280,7 @@ func newSyncIDBatcher(numBatches uint64) idbatcher.Batcher { } } -func (s *syncIDBatcher) AddToCurrentBatch(id idbatcher.ID) { +func (s *syncIDBatcher) AddToCurrentBatch(id pdata.TraceID) { s.Lock() s.openBatch = append(s.openBatch, id) s.Unlock() diff --git a/processor/samplingprocessor/tailsamplingprocessor/sampling/always_sample.go b/processor/samplingprocessor/tailsamplingprocessor/sampling/always_sample.go index c624854a30e..d81663ce385 100644 --- a/processor/samplingprocessor/tailsamplingprocessor/sampling/always_sample.go +++ b/processor/samplingprocessor/tailsamplingprocessor/sampling/always_sample.go @@ -17,6 +17,8 @@ package sampling import ( tracepb "github.com/census-instrumentation/opencensus-proto/gen-go/trace/v1" "go.uber.org/zap" + + "go.opentelemetry.io/collector/consumer/pdata" ) type alwaysSample struct { @@ -42,14 +44,14 @@ func (as *alwaysSample) OnLateArrivingSpans(Decision, []*tracepb.Span) error { } // Evaluate looks at the trace data and returns a corresponding SamplingDecision. -func (as *alwaysSample) Evaluate([]byte, *TraceData) (Decision, error) { +func (as *alwaysSample) Evaluate(pdata.TraceID, *TraceData) (Decision, error) { as.logger.Debug("Evaluating spans in always-sample filter") return Sampled, nil } // OnDroppedSpans is called when the trace needs to be dropped, due to memory // pressure, before the decision_wait time has been reached. -func (as *alwaysSample) OnDroppedSpans([]byte, *TraceData) (Decision, error) { +func (as *alwaysSample) OnDroppedSpans(pdata.TraceID, *TraceData) (Decision, error) { as.logger.Debug("Triggering action for dropped spans in always-sample filter") return Sampled, nil } diff --git a/processor/samplingprocessor/tailsamplingprocessor/sampling/numeric_tag_filter.go b/processor/samplingprocessor/tailsamplingprocessor/sampling/numeric_tag_filter.go index 9b883a2ed7b..25e1fda8c3b 100644 --- a/processor/samplingprocessor/tailsamplingprocessor/sampling/numeric_tag_filter.go +++ b/processor/samplingprocessor/tailsamplingprocessor/sampling/numeric_tag_filter.go @@ -17,6 +17,8 @@ package sampling import ( tracepb "github.com/census-instrumentation/opencensus-proto/gen-go/trace/v1" "go.uber.org/zap" + + "go.opentelemetry.io/collector/consumer/pdata" ) type numericAttributeFilter struct { @@ -48,7 +50,7 @@ func (naf *numericAttributeFilter) OnLateArrivingSpans(Decision, []*tracepb.Span } // Evaluate looks at the trace data and returns a corresponding SamplingDecision. -func (naf *numericAttributeFilter) Evaluate(_ []byte, trace *TraceData) (Decision, error) { +func (naf *numericAttributeFilter) Evaluate(_ pdata.TraceID, trace *TraceData) (Decision, error) { naf.logger.Debug("Evaluating spans in numeric-attribute filter") trace.Lock() batches := trace.ReceivedBatches @@ -72,7 +74,7 @@ func (naf *numericAttributeFilter) Evaluate(_ []byte, trace *TraceData) (Decisio // OnDroppedSpans is called when the trace needs to be dropped, due to memory // pressure, before the decision_wait time has been reached. -func (naf *numericAttributeFilter) OnDroppedSpans([]byte, *TraceData) (Decision, error) { +func (naf *numericAttributeFilter) OnDroppedSpans(pdata.TraceID, *TraceData) (Decision, error) { naf.logger.Debug("Triggering action for dropped spans in numeric-attribute filter") return NotSampled, nil } diff --git a/processor/samplingprocessor/tailsamplingprocessor/sampling/numeric_tag_filter_test.go b/processor/samplingprocessor/tailsamplingprocessor/sampling/numeric_tag_filter_test.go index 968db11e799..e8bd9fc9aed 100644 --- a/processor/samplingprocessor/tailsamplingprocessor/sampling/numeric_tag_filter_test.go +++ b/processor/samplingprocessor/tailsamplingprocessor/sampling/numeric_tag_filter_test.go @@ -24,6 +24,7 @@ import ( "go.uber.org/zap" "go.opentelemetry.io/collector/consumer/consumerdata" + "go.opentelemetry.io/collector/consumer/pdata" ) func TestNumericTagFilter(t *testing.T) { @@ -65,7 +66,7 @@ func TestNumericTagFilter(t *testing.T) { for _, c := range cases { t.Run(c.Desc, func(t *testing.T) { u, _ := uuid.NewRandom() - decision, err := filter.Evaluate(u[:], c.Trace) + decision, err := filter.Evaluate(pdata.NewTraceID(u[:]), c.Trace) assert.NoError(t, err) assert.Equal(t, decision, c.Decision) }) diff --git a/processor/samplingprocessor/tailsamplingprocessor/sampling/policy.go b/processor/samplingprocessor/tailsamplingprocessor/sampling/policy.go index 29711de1aee..a3a4e66c27a 100644 --- a/processor/samplingprocessor/tailsamplingprocessor/sampling/policy.go +++ b/processor/samplingprocessor/tailsamplingprocessor/sampling/policy.go @@ -21,6 +21,7 @@ import ( tracepb "github.com/census-instrumentation/opencensus-proto/gen-go/trace/v1" "go.opentelemetry.io/collector/consumer/consumerdata" + "go.opentelemetry.io/collector/consumer/pdata" ) // TraceData stores the sampling related trace data. @@ -67,9 +68,9 @@ type PolicyEvaluator interface { OnLateArrivingSpans(earlyDecision Decision, spans []*tracepb.Span) error // Evaluate looks at the trace data and returns a corresponding SamplingDecision. - Evaluate(traceID []byte, trace *TraceData) (Decision, error) + Evaluate(traceID pdata.TraceID, trace *TraceData) (Decision, error) // OnDroppedSpans is called when the trace needs to be dropped, due to memory // pressure, before the decision_wait time has been reached. - OnDroppedSpans(traceID []byte, trace *TraceData) (Decision, error) + OnDroppedSpans(traceID pdata.TraceID, trace *TraceData) (Decision, error) } diff --git a/processor/samplingprocessor/tailsamplingprocessor/sampling/rate_limiting.go b/processor/samplingprocessor/tailsamplingprocessor/sampling/rate_limiting.go index 0397870992d..fa5918e6448 100644 --- a/processor/samplingprocessor/tailsamplingprocessor/sampling/rate_limiting.go +++ b/processor/samplingprocessor/tailsamplingprocessor/sampling/rate_limiting.go @@ -19,6 +19,8 @@ import ( tracepb "github.com/census-instrumentation/opencensus-proto/gen-go/trace/v1" "go.uber.org/zap" + + "go.opentelemetry.io/collector/consumer/pdata" ) type rateLimiting struct { @@ -48,7 +50,7 @@ func (r *rateLimiting) OnLateArrivingSpans(Decision, []*tracepb.Span) error { } // Evaluate looks at the trace data and returns a corresponding SamplingDecision. -func (r *rateLimiting) Evaluate(_ []byte, trace *TraceData) (Decision, error) { +func (r *rateLimiting) Evaluate(_ pdata.TraceID, trace *TraceData) (Decision, error) { r.logger.Debug("Evaluating spans in rate-limiting filter") currSecond := time.Now().Unix() if r.currentSecond != currSecond { @@ -67,7 +69,7 @@ func (r *rateLimiting) Evaluate(_ []byte, trace *TraceData) (Decision, error) { // OnDroppedSpans is called when the trace needs to be dropped, due to memory // pressure, before the decision_wait time has been reached. -func (r *rateLimiting) OnDroppedSpans([]byte, *TraceData) (Decision, error) { +func (r *rateLimiting) OnDroppedSpans(pdata.TraceID, *TraceData) (Decision, error) { r.logger.Debug("Triggering action for dropped spans in rate-limiting filter") return Sampled, nil } diff --git a/processor/samplingprocessor/tailsamplingprocessor/sampling/string_tag_filter.go b/processor/samplingprocessor/tailsamplingprocessor/sampling/string_tag_filter.go index accea48a6fc..d8bc23ea254 100644 --- a/processor/samplingprocessor/tailsamplingprocessor/sampling/string_tag_filter.go +++ b/processor/samplingprocessor/tailsamplingprocessor/sampling/string_tag_filter.go @@ -17,6 +17,8 @@ package sampling import ( tracepb "github.com/census-instrumentation/opencensus-proto/gen-go/trace/v1" "go.uber.org/zap" + + "go.opentelemetry.io/collector/consumer/pdata" ) type stringAttributeFilter struct { @@ -53,7 +55,7 @@ func (saf *stringAttributeFilter) OnLateArrivingSpans(Decision, []*tracepb.Span) } // Evaluate looks at the trace data and returns a corresponding SamplingDecision. -func (saf *stringAttributeFilter) Evaluate(_ []byte, trace *TraceData) (Decision, error) { +func (saf *stringAttributeFilter) Evaluate(_ pdata.TraceID, trace *TraceData) (Decision, error) { saf.logger.Debug("Evaluting spans in string-tag filter") trace.Lock() batches := trace.ReceivedBatches @@ -87,7 +89,7 @@ func (saf *stringAttributeFilter) Evaluate(_ []byte, trace *TraceData) (Decision // OnDroppedSpans is called when the trace needs to be dropped, due to memory // pressure, before the decision_wait time has been reached. -func (saf *stringAttributeFilter) OnDroppedSpans([]byte, *TraceData) (Decision, error) { +func (saf *stringAttributeFilter) OnDroppedSpans(pdata.TraceID, *TraceData) (Decision, error) { saf.logger.Debug("Triggering action for dropped spans in string-tag filter") return NotSampled, nil } diff --git a/processor/samplingprocessor/tailsamplingprocessor/sampling/string_tag_filter_test.go b/processor/samplingprocessor/tailsamplingprocessor/sampling/string_tag_filter_test.go index 6abc57eec36..2b9f5183dfb 100644 --- a/processor/samplingprocessor/tailsamplingprocessor/sampling/string_tag_filter_test.go +++ b/processor/samplingprocessor/tailsamplingprocessor/sampling/string_tag_filter_test.go @@ -24,6 +24,7 @@ import ( "go.uber.org/zap" "go.opentelemetry.io/collector/consumer/consumerdata" + "go.opentelemetry.io/collector/consumer/pdata" ) func TestStringTagFilter(t *testing.T) { @@ -71,7 +72,7 @@ func TestStringTagFilter(t *testing.T) { for _, c := range cases { t.Run(c.Desc, func(t *testing.T) { u, _ := uuid.NewRandom() - decision, err := filter.Evaluate(u[:], c.Trace) + decision, err := filter.Evaluate(pdata.NewTraceID(u[:]), c.Trace) assert.NoError(t, err) assert.Equal(t, decision, c.Decision) }) diff --git a/proto_patch.sed b/proto_patch.sed index 9ab872bb612..b465d738e87 100644 --- a/proto_patch.sed +++ b/proto_patch.sed @@ -3,3 +3,11 @@ s+github.com/open-telemetry/opentelemetry-proto/gen/go/+go.opentelemetry.io/coll s+package opentelemetry.proto.\(.*\).v1;+package opentelemetry.proto.\1.v1;\ \ import "github.com/gogo/protobuf@v1.3.1/gogoproto/gogo.proto";+g + +s+bytes trace_id = \(.*\);+bytes trace_id = \1\ + [\ + // Use custom TraceId data type for this field.\ + (gogoproto.nullable) = false,\ + (gogoproto.customtype) = "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/common/v1.TraceID",\ + (gogoproto.customname) = "TraceId"\ + ];+g diff --git a/receiver/jaegerreceiver/jaeger_agent_test.go b/receiver/jaegerreceiver/jaeger_agent_test.go index 2f7c975eb42..bde2d9517b4 100644 --- a/receiver/jaegerreceiver/jaeger_agent_test.go +++ b/receiver/jaegerreceiver/jaeger_agent_test.go @@ -242,7 +242,7 @@ func generateTraceData() pdata.Traces { td.ResourceSpans().At(0).InstrumentationLibrarySpans().At(0).Spans().Resize(1) span := td.ResourceSpans().At(0).InstrumentationLibrarySpans().At(0).Spans().At(0) span.SetSpanID([]byte{0, 1, 2, 3, 4, 5, 6, 7}) - span.SetTraceID([]byte{0, 1, 2, 3, 4, 5, 6, 7, 7, 6, 5, 4, 3, 2, 1, 0}) + span.SetTraceID(pdata.NewTraceID([]byte{0, 1, 2, 3, 4, 5, 6, 7, 7, 6, 5, 4, 3, 2, 1, 0})) span.SetStartTime(1581452772000000000) span.SetEndTime(1581452773000000000) return td diff --git a/receiver/jaegerreceiver/trace_receiver_test.go b/receiver/jaegerreceiver/trace_receiver_test.go index 2719eafbc05..ca5c144d66b 100644 --- a/receiver/jaegerreceiver/trace_receiver_test.go +++ b/receiver/jaegerreceiver/trace_receiver_test.go @@ -297,7 +297,7 @@ func TestGRPCReceptionWithTLS(t *testing.T) { } func expectedTraceData(t1, t2, t3 time.Time) pdata.Traces { - traceID := pdata.TraceID( + traceID := pdata.NewTraceID( []byte{0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, 0x80}) parentSpanID := pdata.SpanID([]byte{0x1F, 0x1E, 0x1D, 0x1C, 0x1B, 0x1A, 0x19, 0x18}) childSpanID := pdata.SpanID([]byte{0xAF, 0xAE, 0xAD, 0xAC, 0xAB, 0xAA, 0xA9, 0xA8}) diff --git a/receiver/otlpreceiver/logs/otlp_test.go b/receiver/otlpreceiver/logs/otlp_test.go index 43340b744b9..c670a03cce4 100644 --- a/receiver/otlpreceiver/logs/otlp_test.go +++ b/receiver/otlpreceiver/logs/otlp_test.go @@ -30,6 +30,7 @@ import ( "go.opentelemetry.io/collector/exporter/exportertest" "go.opentelemetry.io/collector/internal" collectorlog "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/collector/logs/v1" + v1 "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/common/v1" otlplog "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/logs/v1" "go.opentelemetry.io/collector/obsreport" "go.opentelemetry.io/collector/testutil" @@ -65,7 +66,7 @@ func TestExport(t *testing.T) { { Logs: []*otlplog.LogRecord{ { - TraceId: traceID, + TraceId: v1.NewTraceID(traceID), SpanId: spanID, Name: "operationB", TimeUnixNano: unixnanos, diff --git a/receiver/otlpreceiver/marshal_jsonpb_test.go b/receiver/otlpreceiver/marshal_jsonpb_test.go index 5e5d25d57b1..8d151043dc1 100644 --- a/receiver/otlpreceiver/marshal_jsonpb_test.go +++ b/receiver/otlpreceiver/marshal_jsonpb_test.go @@ -39,6 +39,7 @@ const expectedJSON = `{ { "spans": [ { + "traceId": "", "name": "operationA", "startTimeUnixNano": "1581452772000000321", "endTimeUnixNano": "1581452773000000789", diff --git a/receiver/otlpreceiver/otlp_test.go b/receiver/otlpreceiver/otlp_test.go index 5b647ab1562..af954f0a6ae 100644 --- a/receiver/otlpreceiver/otlp_test.go +++ b/receiver/otlpreceiver/otlp_test.go @@ -27,7 +27,7 @@ import ( "testing" "time" - gogoproto "github.com/gogo/protobuf/proto" + "github.com/gogo/protobuf/jsonpb" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" spb "google.golang.org/genproto/googleapis/rpc/status" @@ -58,6 +58,74 @@ import ( const otlpReceiverName = "otlp_receiver_test" +var traceJSON = []byte(` + { + "resource_spans": [ + { + "resource": { + "attributes": [ + { + "key": "host.hostname", + "value": { "stringValue": "testHost" } + } + ] + }, + "instrumentation_library_spans": [ + { + "spans": [ + { + "trace_id": "5B8EFFF798038103D269B633813FC60C", + "span_id": "7uGbfsPBsXM=", + "name": "testSpan", + "start_time_unix_nano": 1544712660000000000, + "end_time_unix_nano": 1544712661000000000, + "attributes": [ + { + "key": "attr1", + "value": { "intValue": 55 } + } + ] + } + ] + } + ] + } + ] + }`) + +var resourceSpansOtlp = otlptrace.ResourceSpans{ + + Resource: &otlpresource.Resource{ + Attributes: []*otlpcommon.KeyValue{ + { + Key: conventions.AttributeHostHostname, + Value: &otlpcommon.AnyValue{Value: &otlpcommon.AnyValue_StringValue{StringValue: "testHost"}}, + }, + }, + }, + InstrumentationLibrarySpans: []*otlptrace.InstrumentationLibrarySpans{ + { + Spans: []*otlptrace.Span{ + { + TraceId: otlpcommon.NewTraceID([]byte{0x5B, 0x8E, 0xFF, 0xF7, 0x98, 0x3, 0x81, 0x3, 0xD2, 0x69, 0xB6, 0x33, 0x81, 0x3F, 0xC6, 0xC}), + SpanId: []byte{0xEE, 0xE1, 0x9B, 0x7E, 0xC3, 0xC1, 0xB1, 0x73}, + Name: "testSpan", + StartTimeUnixNano: 1544712660000000000, + EndTimeUnixNano: 1544712661000000000, + Attributes: []*otlpcommon.KeyValue{ + { + Key: "attr1", + Value: &otlpcommon.AnyValue{Value: &otlpcommon.AnyValue_IntValue{IntValue: 55}}, + }, + }, + }, + }, + }, + }, +} + +var traceOtlp = pdata.TracesFromOtlp([]*otlptrace.ResourceSpans{&resourceSpansOtlp}) + func TestJsonHttp(t *testing.T) { tests := []struct { name string @@ -98,40 +166,6 @@ func TestJsonHttp(t *testing.T) { url := fmt.Sprintf("http://%s/v1/trace", addr) - traceJSON := []byte(` - { - "resource_spans": [ - { - "resource": { - "attributes": [ - { - "key": "host.hostname", - "value": { "stringValue": "testHost" } - } - ] - }, - "instrumentation_library_spans": [ - { - "spans": [ - { - "trace_id": "W47/95gDgQPSabYzgT/GDA==", - "span_id": "7uGbfsPBsXM=", - "name": "testSpan", - "start_time_unix_nano": 1544712660000000000, - "end_time_unix_nano": 1544712661000000000, - "attributes": [ - { - "key": "attr1", - "value": { "intValue": 55 } - } - ] - } - ] - } - ] - } - ] - }`) for _, test := range tests { t.Run(test.name, func(t *testing.T) { var buf *bytes.Buffer @@ -158,7 +192,6 @@ func TestJsonHttp(t *testing.T) { t.Errorf("Error reading response from trace grpc-gateway, %v", err) } respStr := string(respBytes) - err = resp.Body.Close() if err != nil { t.Errorf("Error closing response body, %v", err) @@ -182,39 +215,74 @@ func TestJsonHttp(t *testing.T) { } got := sink.AllTraces()[0] + assert.EqualValues(t, got, traceOtlp) + }) + } +} + +func TestJsonMarshaling(t *testing.T) { + m := jsonpb.Marshaler{} + json, err := m.MarshalToString(&resourceSpansOtlp) + assert.NoError(t, err) + + var resourceSpansOtlp2 otlptrace.ResourceSpans + err = jsonpb.UnmarshalString(json, &resourceSpansOtlp2) + assert.NoError(t, err) + + assert.EqualValues(t, resourceSpansOtlp, resourceSpansOtlp2) +} - want := pdata.TracesFromOtlp([]*otlptrace.ResourceSpans{ +func TestJsonUnmarshaling(t *testing.T) { + var resourceSpansOtlp2 otlptrace.ResourceSpans + err := jsonpb.UnmarshalString(` + { + "instrumentation_library_spans": [ + { + "spans": [ { - Resource: &otlpresource.Resource{ - Attributes: []*otlpcommon.KeyValue{ - { - Key: conventions.AttributeHostHostname, - Value: &otlpcommon.AnyValue{Value: &otlpcommon.AnyValue_StringValue{StringValue: "testHost"}}, - }, - }, - }, - InstrumentationLibrarySpans: []*otlptrace.InstrumentationLibrarySpans{ - { - Spans: []*otlptrace.Span{ - { - TraceId: []byte{0x5B, 0x8E, 0xFF, 0xF7, 0x98, 0x3, 0x81, 0x3, 0xD2, 0x69, 0xB6, 0x33, 0x81, 0x3F, 0xC6, 0xC}, - SpanId: []byte{0xEE, 0xE1, 0x9B, 0x7E, 0xC3, 0xC1, 0xB1, 0x73}, - Name: "testSpan", - StartTimeUnixNano: 1544712660000000000, - EndTimeUnixNano: 1544712661000000000, - Attributes: []*otlpcommon.KeyValue{ - { - Key: "attr1", - Value: &otlpcommon.AnyValue{Value: &otlpcommon.AnyValue_IntValue{IntValue: 55}}, - }, - }, - }, - }, - }, - }, - }, - }) - assert.EqualValues(t, got, want) + } + ] + } + ] + }`, &resourceSpansOtlp2) + assert.NoError(t, err) + assert.EqualValues(t, otlpcommon.TraceID{}, resourceSpansOtlp2.InstrumentationLibrarySpans[0].Spans[0].TraceId) + + tests := []struct { + name string + json string + bytes []byte + }{ + { + name: "empty string trace id", + json: `""`, + bytes: nil, + }, + { + name: "zero bytes trace id", + json: `"00000000000000000000000000000000"`, + bytes: []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + var resourceSpansOtlp2 otlptrace.ResourceSpans + jsonStr := fmt.Sprintf(` + { + "instrumentation_library_spans": [ + { + "spans": [ + { + "trace_id": %v + } + ] + } + ] + }`, test.json) + err := jsonpb.UnmarshalString(jsonStr, &resourceSpansOtlp2) + assert.NoError(t, err) + assert.EqualValues(t, otlpcommon.NewTraceID(test.bytes), resourceSpansOtlp2.InstrumentationLibrarySpans[0].Spans[0].TraceId) }) } } @@ -321,9 +389,7 @@ func TestProtoHttp(t *testing.T) { got := gotOtlp[0] want := wantOtlp[0] - // assert.Equal doesn't work on protos, see: - // https://github.com/stretchr/testify/issues/758 - if !gogoproto.Equal(got, want) { + if !assert.EqualValues(t, got, want) { t.Errorf("Sending trace proto over http failed\nGot:\n%v\nWant:\n%v\n", got.String(), want.String()) @@ -492,10 +558,12 @@ func TestOTLPReceiverTrace_HandleNextConsumerResponse(t *testing.T) { { Spans: []*otlptrace.Span{ { - TraceId: []byte{ - 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, - 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, - }, + TraceId: otlpcommon.NewTraceID( + []byte{ + 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, + 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, + }, + ), }, }, }, diff --git a/receiver/otlpreceiver/trace/otlp_test.go b/receiver/otlpreceiver/trace/otlp_test.go index 01e28fff776..7f7e8f0eebd 100644 --- a/receiver/otlpreceiver/trace/otlp_test.go +++ b/receiver/otlpreceiver/trace/otlp_test.go @@ -29,6 +29,7 @@ import ( "go.opentelemetry.io/collector/consumer/pdata" "go.opentelemetry.io/collector/exporter/exportertest" collectortrace "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/collector/trace/v1" + v1 "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/common/v1" otlptrace "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/trace/v1" "go.opentelemetry.io/collector/obsreport" "go.opentelemetry.io/collector/testutil" @@ -64,7 +65,7 @@ func TestExport(t *testing.T) { { Spans: []*otlptrace.Span{ { - TraceId: traceID, + TraceId: v1.NewTraceID(traceID), SpanId: spanID, Name: "operationB", Kind: otlptrace.Span_SPAN_KIND_SERVER, diff --git a/receiver/zipkinreceiver/proto_parse_test.go b/receiver/zipkinreceiver/proto_parse_test.go index fb952a859a6..3ceedc68057 100644 --- a/receiver/zipkinreceiver/proto_parse_test.go +++ b/receiver/zipkinreceiver/proto_parse_test.go @@ -127,7 +127,7 @@ func TestConvertSpansToTraceSpans_protobuf(t *testing.T) { { Spans: []*otlptrace.Span{ { - TraceId: []byte{0x7F, 0x6F, 0x5F, 0x4F, 0x3F, 0x2F, 0x1F, 0x0F, 0xF7, 0xF6, 0xF5, 0xF4, 0xF3, 0xF2, 0xF1, 0xF0}, + TraceId: otlpcommon.NewTraceID([]byte{0x7F, 0x6F, 0x5F, 0x4F, 0x3F, 0x2F, 0x1F, 0x0F, 0xF7, 0xF6, 0xF5, 0xF4, 0xF3, 0xF2, 0xF1, 0xF0}), SpanId: []byte{0xF7, 0xF6, 0xF5, 0xF4, 0xF3, 0xF2, 0xF1, 0xF0}, ParentSpanId: []byte{0xF7, 0xF6, 0xF5, 0xF4, 0xF3, 0xF2, 0xF1, 0xF0}, Name: "ProtoSpan1", @@ -205,7 +205,7 @@ func TestConvertSpansToTraceSpans_protobuf(t *testing.T) { { Spans: []*otlptrace.Span{ { - TraceId: []byte{0x7A, 0x6A, 0x5A, 0x4A, 0x3A, 0x2A, 0x1A, 0x0A, 0xC7, 0xC6, 0xC5, 0xC4, 0xC3, 0xC2, 0xC1, 0xC0}, + TraceId: otlpcommon.NewTraceID([]byte{0x7A, 0x6A, 0x5A, 0x4A, 0x3A, 0x2A, 0x1A, 0x0A, 0xC7, 0xC6, 0xC5, 0xC4, 0xC3, 0xC2, 0xC1, 0xC0}), SpanId: []byte{0x67, 0x66, 0x65, 0x64, 0x63, 0x62, 0x61, 0x60}, ParentSpanId: []byte{0x17, 0x16, 0x15, 0x14, 0x13, 0x12, 0x11, 0x10}, Name: "CacheWarmUp", diff --git a/service/internal/resources.go b/service/internal/resources.go index 23e8c93fe9b..0e8b2e7bd0d 100644 --- a/service/internal/resources.go +++ b/service/internal/resources.go @@ -227,7 +227,7 @@ var _escData = map[string]*_escFile{ name: "component_header.html", local: "templates/component_header.html", size: 156, - modtime: 1589224191, + modtime: 1600087369, compressed: ` H4sIAAAAAAAC/1SMsQqDMBRFd7/iIq7q5lBiltKt9B8CPklQX6R1e9x/L6ZQ2vXcc65ZE3AZ0V3ztmcV PW467TnpQVZmzZp0Kfs96VJQizTjw1uyAgAXB+8C4lPmsT4fydqbdY+wCen64F0fB19iWV/yF/54X0en @@ -239,7 +239,7 @@ U3kHAAD//zT+SdCcAAAA name: "extensions_table.html", local: "templates/extensions_table.html", size: 353, - modtime: 1589224191, + modtime: 1600087369, compressed: ` H4sIAAAAAAAC/2SQwU7DMBBE7/2KlemRNJwjxxwQHDnwB248DRbOOnK2tGD531HTQIvqk1fzZjU7Wuw2 gCb5CmjVNiaHVE2j7Tz3DT0osyIiynltqWlp8xSHMTJYntmN0bOUsgDJcg9ap3jw7HC8n7+z5y0epgU7 @@ -252,7 +252,7 @@ oxX5HeETfMGv9NPTkv4i2e6jT3HPrqE7AEui8yaECbdWkzPYUXWlaHFkg++5VR1YkJTRlt4Tdq06HVfK name: "footer.html", local: "templates/footer.html", size: 15, - modtime: 1589224191, + modtime: 1600087369, compressed: ` H4sIAAAAAAAC/7LRT8pPqbTjstHPKMnNsQMEAAD//wEFevAPAAAA `, @@ -262,7 +262,7 @@ H4sIAAAAAAAC/7LRT8pPqbTjstHPKMnNsQMEAAD//wEFevAPAAAA name: "header.html", local: "templates/header.html", size: 467, - modtime: 1589224191, + modtime: 1600087369, compressed: ` H4sIAAAAAAAC/5TRMU8sIRAH8P4+BY/25eC9szGGxUItLIwW11giO7uMB8wG5rxsLvfdDdnTxNhoBeFP fpnM3/y5fbzZPj/dicAp2pVph4guj52ELK0J4Hq7EkIIk4Cd8MGVCtzJPQ/rS3mOGDmCPR7Vtl1OJ6OX @@ -276,7 +276,7 @@ vuDEoocBiqjF/5RszGuV1uhFsCujl0bMC/Vz62vzZe1hY98DAAD//7qRGmLTAQAA name: "pipelines_table.html", local: "templates/pipelines_table.html", size: 1946, - modtime: 1589224191, + modtime: 1600087369, compressed: ` H4sIAAAAAAAC/7SVwXLTMBCG7zyFxnRyIjVcU1scSpnhAMN0eAFZ2gRNlZVmJbdujd+dsWyrTp0LtL5k rOjX/tlv/8hFEJUB5sOjgTKrLCmgrXdCajzs2MeMv2OMsSLQ8DAsFJPWeCew/MSE0QcsDewDLyr+tTbm @@ -293,7 +293,7 @@ QeMmXNC4hCvdNKvQgsYtacFoGWFFxSvCNl+lu3HQFXl8JfO/AQAA//9We3KLmgcAAA== name: "properties_table.html", local: "templates/properties_table.html", size: 420, - modtime: 1589224191, + modtime: 1600087369, compressed: ` H4sIAAAAAAAC/2SRwW7DIBBE7/6KVRr1VMc5u5gfqFT11Ds2U8sqWVuwqRoR/r1yTCpb4YAEO48ZDarV MR7ezQkp1apqdaHEtA4U5OLQ7NrRW/gyTKYbuK/puNMFEVGMtB/Y4pfqho6UUr71hnvk0Qvt4XACyyw6 diff --git a/testbed/testbed/data_providers.go b/testbed/testbed/data_providers.go index 4e90775b42f..34eca697a6a 100644 --- a/testbed/testbed/data_providers.go +++ b/testbed/testbed/data_providers.go @@ -41,7 +41,7 @@ type DataProvider interface { // GenerateMetrics returns an internal MetricData instance with an OTLP ResourceMetrics slice of test data. GenerateMetrics() (pdata.Metrics, bool) // GetGeneratedSpan returns the generated Span matching the provided traceId and spanId or else nil if no match found. - GetGeneratedSpan(traceID []byte, spanID []byte) *otlptrace.Span + GetGeneratedSpan(traceID pdata.TraceID, spanID []byte) *otlptrace.Span // GenerateLogs returns the internal pdata.Logs format GenerateLogs() (pdata.Logs, bool) } @@ -104,10 +104,10 @@ func (dp *PerfTestDataProvider) GenerateTraces() (pdata.Traces, bool) { return traceData, false } -func GenerateSequentialTraceID(id uint64) []byte { +func GenerateSequentialTraceID(id uint64) pdata.TraceID { var traceID [16]byte binary.PutUvarint(traceID[:], id) - return traceID[:] + return pdata.NewTraceID(traceID[:]) } func GenerateSequentialSpanID(id uint64) []byte { @@ -161,7 +161,7 @@ func (dp *PerfTestDataProvider) GenerateMetrics() (pdata.Metrics, bool) { return md, false } -func (dp *PerfTestDataProvider) GetGeneratedSpan([]byte, []byte) *otlptrace.Span { +func (dp *PerfTestDataProvider) GetGeneratedSpan(pdata.TraceID, []byte) *otlptrace.Span { // function not supported for this data provider return nil } @@ -287,7 +287,7 @@ func (dp *GoldenDataProvider) GenerateLogs() (pdata.Logs, bool) { return pdata.NewLogs(), true } -func (dp *GoldenDataProvider) GetGeneratedSpan(traceID []byte, spanID []byte) *otlptrace.Span { +func (dp *GoldenDataProvider) GetGeneratedSpan(traceID pdata.TraceID, spanID []byte) *otlptrace.Span { if dp.spansMap == nil { dp.spansMap = populateSpansMap(dp.resourceSpans) } @@ -300,7 +300,7 @@ func populateSpansMap(resourceSpansList []*otlptrace.ResourceSpans) map[string]* for _, resourceSpans := range resourceSpansList { for _, libSpans := range resourceSpans.InstrumentationLibrarySpans { for _, span := range libSpans.Spans { - key := traceIDAndSpanIDToString(span.TraceId, span.SpanId) + key := traceIDAndSpanIDToString(pdata.TraceID(span.TraceId), span.SpanId) spansMap[key] = span } } @@ -308,6 +308,6 @@ func populateSpansMap(resourceSpansList []*otlptrace.ResourceSpans) map[string]* return spansMap } -func traceIDAndSpanIDToString(traceID []byte, spanID []byte) string { - return fmt.Sprintf("%s-%s", hex.EncodeToString(traceID), hex.EncodeToString(spanID)) +func traceIDAndSpanIDToString(traceID pdata.TraceID, spanID []byte) string { + return fmt.Sprintf("%s-%s", hex.EncodeToString(traceID.Bytes()), hex.EncodeToString(spanID)) } diff --git a/testbed/testbed/validator.go b/testbed/testbed/validator.go index 21d25794581..741a1fa069e 100644 --- a/testbed/testbed/validator.go +++ b/testbed/testbed/validator.go @@ -128,7 +128,7 @@ func (v *CorrectnessTestValidator) assertSentRecdTracingDataEqual(tracesList []p for _, rs := range resourceSpansList { for _, ils := range rs.InstrumentationLibrarySpans { for _, recdSpan := range ils.Spans { - sentSpan := v.dataProvider.GetGeneratedSpan(recdSpan.TraceId, recdSpan.SpanId) + sentSpan := v.dataProvider.GetGeneratedSpan(pdata.TraceID(recdSpan.TraceId), recdSpan.SpanId) v.diffSpan(sentSpan, recdSpan) } } @@ -160,13 +160,13 @@ func (v *CorrectnessTestValidator) diffSpan(sentSpan *otlptrace.Span, recdSpan * } func (v *CorrectnessTestValidator) diffSpanTraceID(sentSpan *otlptrace.Span, recdSpan *otlptrace.Span) { - if hex.EncodeToString(sentSpan.TraceId) != hex.EncodeToString(recdSpan.TraceId) { + if sentSpan.TraceId.HexString() != recdSpan.TraceId.HexString() { af := &TraceAssertionFailure{ typeName: "Span", dataComboName: sentSpan.Name, fieldPath: "TraceId", - expectedValue: hex.EncodeToString(sentSpan.TraceId), - actualValue: hex.EncodeToString(recdSpan.TraceId), + expectedValue: sentSpan.TraceId.HexString(), + actualValue: recdSpan.TraceId.HexString(), } v.assertionFailures = append(v.assertionFailures, af) } diff --git a/translator/internaldata/oc_to_traces.go b/translator/internaldata/oc_to_traces.go index d6835d079e3..081f14ae383 100644 --- a/translator/internaldata/oc_to_traces.go +++ b/translator/internaldata/oc_to_traces.go @@ -341,6 +341,7 @@ func ocLinksToInternal(ocLinks *octrace.Span_Links, dest pdata.Span) { i++ link.SetTraceID(pdata.NewTraceID(ocLink.TraceId)) + link.SetSpanID(pdata.NewSpanID(ocLink.SpanId)) link.SetTraceState(ocTraceStateToInternal(ocLink.Tracestate)) initAttributeMapFromOC(ocLink.Attributes, link.Attributes()) diff --git a/translator/trace/big_endian_converter.go b/translator/trace/big_endian_converter.go index ca65e4f593c..98779aeca45 100644 --- a/translator/trace/big_endian_converter.go +++ b/translator/trace/big_endian_converter.go @@ -17,6 +17,8 @@ package tracetranslator import ( "encoding/binary" "errors" + + "go.opentelemetry.io/collector/consumer/pdata" ) var ( @@ -30,6 +32,15 @@ var ( ErrWrongLenSpanID = errors.New("SpanID does not have 8 bytes") ) +// UInt64ToByteTraceID takes a two uint64 representation of a TraceID and +// converts it to a []byte representation. +func UInt64ToTraceID(high, low uint64) pdata.TraceID { + traceID := make([]byte, 16) + binary.BigEndian.PutUint64(traceID[:8], high) + binary.BigEndian.PutUint64(traceID[8:], low) + return pdata.NewTraceID(traceID) +} + // UInt64ToByteTraceID takes a two uint64 representation of a TraceID and // converts it to a []byte representation. func UInt64ToByteTraceID(high, low uint64) []byte { @@ -39,6 +50,12 @@ func UInt64ToByteTraceID(high, low uint64) []byte { return traceID } +// Int64ToByteTraceID takes a two int64 representation of a TraceID and +// converts it to a []byte representation. +func Int64ToTraceID(high, low int64) pdata.TraceID { + return UInt64ToTraceID(uint64(high), uint64(low)) +} + // Int64ToByteTraceID takes a two int64 representation of a TraceID and // converts it to a []byte representation. func Int64ToByteTraceID(high, low int64) []byte { @@ -64,6 +81,11 @@ func BytesToInt64TraceID(traceID []byte) (int64, int64, error) { return int64(traceIDHigh), int64(traceIDLow), err } +// TraceIDToUInt64Pair takes a pdata.TraceID and converts it to a pair of uint64 representation. +func TraceIDToUInt64Pair(traceID pdata.TraceID) (uint64, uint64, error) { + return BytesToUInt64TraceID(traceID.Bytes()) +} + // UInt64ToByteSpanID takes a uint64 representation of a SpanID and // converts it to a []byte representation. func UInt64ToByteSpanID(id uint64) []byte { diff --git a/translator/trace/jaeger/jaegerproto_to_traces.go b/translator/trace/jaeger/jaegerproto_to_traces.go index 6f6bd00ad1a..923e5079806 100644 --- a/translator/trace/jaeger/jaegerproto_to_traces.go +++ b/translator/trace/jaeger/jaegerproto_to_traces.go @@ -172,7 +172,7 @@ type instrumentationLibrary struct { func jSpanToInternal(span *model.Span) (pdata.Span, instrumentationLibrary) { dest := pdata.NewSpan() dest.InitEmpty() - dest.SetTraceID(tracetranslator.UInt64ToByteTraceID(span.TraceID.High, span.TraceID.Low)) + dest.SetTraceID(tracetranslator.UInt64ToTraceID(span.TraceID.High, span.TraceID.Low)) dest.SetSpanID(tracetranslator.UInt64ToByteSpanID(uint64(span.SpanID))) dest.SetName(span.OperationName) dest.SetStartTime(pdata.TimestampUnixNano(uint64(span.StartTime.UnixNano()))) @@ -365,7 +365,7 @@ func jReferencesToSpanLinks(refs []model.SpanRef, excludeParentID model.SpanID, continue } - link.SetTraceID(pdata.NewTraceID(tracetranslator.UInt64ToByteTraceID(ref.TraceID.High, ref.TraceID.Low))) + link.SetTraceID(tracetranslator.UInt64ToTraceID(ref.TraceID.High, ref.TraceID.Low)) link.SetSpanID(pdata.NewSpanID(tracetranslator.UInt64ToByteSpanID(uint64(ref.SpanID)))) i++ } diff --git a/translator/trace/jaeger/jaegerthrift_to_traces.go b/translator/trace/jaeger/jaegerthrift_to_traces.go index 54859beadbb..e3e3a6075b2 100644 --- a/translator/trace/jaeger/jaegerthrift_to_traces.go +++ b/translator/trace/jaeger/jaegerthrift_to_traces.go @@ -99,7 +99,7 @@ func jThriftSpansToInternal(spans []*jaeger.Span, dest pdata.SpanSlice) { } func jThriftSpanToInternal(span *jaeger.Span, dest pdata.Span) { - dest.SetTraceID(tracetranslator.Int64ToByteTraceID(span.TraceIdHigh, span.TraceIdLow)) + dest.SetTraceID(tracetranslator.Int64ToTraceID(span.TraceIdHigh, span.TraceIdLow)) dest.SetSpanID(tracetranslator.Int64ToByteSpanID(span.SpanId)) dest.SetName(span.OperationName) dest.SetStartTime(microsecondsToUnixNano(span.StartTime)) @@ -186,7 +186,7 @@ func jThriftReferencesToSpanLinks(refs []*jaeger.SpanRef, excludeParentID int64, continue } - link.SetTraceID(pdata.NewTraceID(tracetranslator.Int64ToByteTraceID(ref.TraceIdHigh, ref.TraceIdLow))) + link.SetTraceID(tracetranslator.Int64ToTraceID(ref.TraceIdHigh, ref.TraceIdLow)) link.SetSpanID(pdata.NewSpanID(tracetranslator.Int64ToByteSpanID(ref.SpanId))) i++ } diff --git a/translator/trace/jaeger/traces_to_jaegerproto.go b/translator/trace/jaeger/traces_to_jaegerproto.go index 9ac79b9c6ea..368835a68b0 100644 --- a/translator/trace/jaeger/traces_to_jaegerproto.go +++ b/translator/trace/jaeger/traces_to_jaegerproto.go @@ -274,7 +274,7 @@ func getJaegerProtoSpanTags(span pdata.Span, instrumentationLibrary pdata.Instru } func traceIDToJaegerProto(traceID pdata.TraceID) (model.TraceID, error) { - traceIDHigh, traceIDLow, err := tracetranslator.BytesToUInt64TraceID(traceID) + traceIDHigh, traceIDLow, err := tracetranslator.TraceIDToUInt64Pair(traceID) if err != nil { return model.TraceID{}, err } diff --git a/translator/trace/zipkin/traces_to_zipkinv2.go b/translator/trace/zipkin/traces_to_zipkinv2.go index 44d9b67a4a7..912de53e8ce 100644 --- a/translator/trace/zipkin/traces_to_zipkinv2.go +++ b/translator/trace/zipkin/traces_to_zipkinv2.go @@ -111,7 +111,7 @@ func spanToZipkinSpan( zs := &zipkinmodel.SpanModel{} - hi, lo, err := tracetranslator.BytesToUInt64TraceID(span.TraceID().Bytes()) + hi, lo, err := tracetranslator.TraceIDToUInt64Pair(span.TraceID()) if err != nil { return nil, err } @@ -230,7 +230,7 @@ func spanLinksToZipkinTags(links pdata.SpanLinkSlice, zTags map[string]string) e if err != nil { return err } - zTags[key] = fmt.Sprintf(tracetranslator.SpanLinkDataFormat, link.TraceID().String(), + zTags[key] = fmt.Sprintf(tracetranslator.SpanLinkDataFormat, link.TraceID().HexString(), link.SpanID().String(), link.TraceState(), jsonStr, link.DroppedAttributesCount()) } } diff --git a/translator/trace/zipkin/zipkinv2_to_traces.go b/translator/trace/zipkin/zipkinv2_to_traces.go index 8d01e0c517b..3a56bf6c478 100644 --- a/translator/trace/zipkin/zipkinv2_to_traces.go +++ b/translator/trace/zipkin/zipkinv2_to_traces.go @@ -127,7 +127,7 @@ func V2SpansToInternalTraces(zipkinSpans []*zipkinmodel.SpanModel) (pdata.Traces func zSpanToInternal(zspan *zipkinmodel.SpanModel, tags map[string]string, dest pdata.Span) error { dest.InitEmpty() - dest.SetTraceID(tracetranslator.UInt64ToByteTraceID(zspan.TraceID.High, zspan.TraceID.Low)) + dest.SetTraceID(tracetranslator.UInt64ToTraceID(zspan.TraceID.High, zspan.TraceID.Low)) dest.SetSpanID(tracetranslator.UInt64ToByteSpanID(uint64(zspan.ID))) if value, ok := tags[tracetranslator.TagW3CTraceState]; ok { dest.SetTraceState(pdata.TraceState(value)) @@ -211,16 +211,21 @@ func zTagsToSpanLinks(tags map[string]string, dest pdata.SpanLinkSlice) error { link := dest.At(index) index++ link.InitEmpty() + + // Convert trace id. rawTrace, errTrace := hex.DecodeString(parts[0]) if errTrace != nil { return errTrace } link.SetTraceID(pdata.NewTraceID(rawTrace)) + + // Convert span id. rawSpan, errSpan := hex.DecodeString(parts[1]) if errSpan != nil { return errSpan } link.SetSpanID(pdata.NewSpanID(rawSpan)) + link.SetTraceState(pdata.TraceState(parts[2])) var jsonStr string diff --git a/translator/trace/zipkin/zipkinv2_to_traces_test.go b/translator/trace/zipkin/zipkinv2_to_traces_test.go index a5fc8ab3c55..9362d967fdd 100644 --- a/translator/trace/zipkin/zipkinv2_to_traces_test.go +++ b/translator/trace/zipkin/zipkinv2_to_traces_test.go @@ -80,7 +80,7 @@ func generateSpanNoEndpoints() []*zipkinmodel.SpanModel { spans[0] = &zipkinmodel.SpanModel{ SpanContext: zipkinmodel.SpanContext{ TraceID: convertTraceID( - []byte{0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, 0x80}), + pdata.NewTraceID([]byte{0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, 0x80})), ID: convertSpanID([]byte{0xAF, 0xAE, 0xAD, 0xAC, 0xAB, 0xAA, 0xA9, 0xA8}), }, Name: "MinimalData", @@ -113,7 +113,7 @@ func generateTraceSingleSpanNoResourceOrInstrLibrary() pdata.Traces { ils.Spans().Resize(1) span := ils.Spans().At(0) span.SetTraceID( - []byte{0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, 0x80}) + pdata.NewTraceID([]byte{0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, 0x80})) span.SetSpanID([]byte{0xAF, 0xAE, 0xAD, 0xAC, 0xAB, 0xAA, 0xA9, 0xA8}) span.SetName("MinimalData") span.SetKind(pdata.SpanKindCLIENT) @@ -133,8 +133,8 @@ func generateTraceSingleSpanMinmalResource() pdata.Traces { return td } -func convertTraceID(t []byte) zipkinmodel.TraceID { - h, l, _ := tracetranslator.BytesToUInt64TraceID(t) +func convertTraceID(t pdata.TraceID) zipkinmodel.TraceID { + h, l, _ := tracetranslator.TraceIDToUInt64Pair(t) return zipkinmodel.TraceID{High: h, Low: l} }