1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-11-29 23:07:45 +02:00

TraceID and SpanID implementations for Stringer Interface (#642)

* TraceID and SpanID implementations for Stringer Interface

* Hex encode while stringifying

* Modify format specifiers wherever SpanID is used

* comment changes

* Remove TraceIdString() and SpanIdString()

* Comments Fixes
This commit is contained in:
Shouri Piratla
2020-04-17 04:12:48 +05:30
committed by GitHub
parent ebc245b388
commit 669d4b3a6c
6 changed files with 75 additions and 79 deletions

View File

@@ -139,7 +139,7 @@ func BenchmarkTraceID_DotString(b *testing.B) {
want := "0000000000000001000000000000002a"
for i := 0; i < b.N; i++ {
if got := sc.TraceIDString(); got != want {
if got := sc.TraceID.String(); got != want {
b.Fatalf("got = %q want = %q", got, want)
}
}
@@ -149,7 +149,7 @@ func BenchmarkSpanID_DotString(b *testing.B) {
sc := core.SpanContext{SpanID: core.SpanID{1}}
want := "0100000000000000"
for i := 0; i < b.N; i++ {
if got := sc.SpanIDString(); got != want {
if got := sc.SpanID.String(); got != want {
b.Fatalf("got = %q want = %q", got, want)
}
}

View File

@@ -620,10 +620,10 @@ func checkChild(p core.SpanContext, apiSpan apitrace.Span) error {
if s == nil {
return fmt.Errorf("got nil child span, want non-nil")
}
if got, want := s.spanContext.TraceIDString(), p.TraceIDString(); got != want {
if got, want := s.spanContext.TraceID.String(), p.TraceID.String(); got != want {
return fmt.Errorf("got child trace ID %s, want %s", got, want)
}
if childID, parentID := s.spanContext.SpanIDString(), p.SpanIDString(); childID == parentID {
if childID, parentID := s.spanContext.SpanID.String(), p.SpanID.String(); childID == parentID {
return fmt.Errorf("got child span ID %s, parent span ID %s; want unequal IDs", childID, parentID)
}
if got, want := s.spanContext.TraceFlags, p.TraceFlags; got != want {