Skip to content

Commit

Permalink
Rever breaking change to [Trace|Span]ID.HexString() (#5995)
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan <[email protected]>

Signed-off-by: Bogdan <[email protected]>
  • Loading branch information
bogdandrutu authored Aug 29, 2022
1 parent 5039081 commit 9ba35cd
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions pdata/pcommon/spanid.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ func (ms SpanID) Bytes() [8]byte {

// HexString returns hex representation of the SpanID.
func (ms SpanID) HexString() string {
if ms.IsEmpty() {
return ""
}
return hex.EncodeToString(ms.orig[:])
}

Expand Down
2 changes: 1 addition & 1 deletion pdata/pcommon/spanid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestNewSpanID(t *testing.T) {

func TestSpanIDHexString(t *testing.T) {
sid := NewSpanID([8]byte{})
assert.Equal(t, "0000000000000000", sid.HexString())
assert.Equal(t, "", sid.HexString())

sid = NewSpanID([8]byte{0x12, 0x23, 0xAD, 0x12, 0x23, 0xAD, 0x12, 0x23})
assert.Equal(t, "1223ad1223ad1223", sid.HexString())
Expand Down
3 changes: 3 additions & 0 deletions pdata/pcommon/traceid.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ func (ms TraceID) Bytes() [16]byte {

// HexString returns hex representation of the TraceID.
func (ms TraceID) HexString() string {
if ms.IsEmpty() {
return ""
}
return hex.EncodeToString(ms.orig[:])
}

Expand Down
2 changes: 1 addition & 1 deletion pdata/pcommon/traceid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func TestNewTraceID(t *testing.T) {

func TestTraceIDHexString(t *testing.T) {
tid := NewTraceID([16]byte{})
assert.Equal(t, "00000000000000000000000000000000", tid.HexString())
assert.Equal(t, "", tid.HexString())

tid = NewTraceID([16]byte{0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78, 0x12, 0x34, 0x56, 0x78})
assert.Equal(t, "12345678123456781234567812345678", tid.HexString())
Expand Down

0 comments on commit 9ba35cd

Please sign in to comment.