mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2026-06-19 21:45:50 +02:00
Trace sdk (#65)
* trace sdk initial commit. * fix imports and comments. * remove tracestate * split trace.go * add attribute over limit test. * add comments and restructure span.go and tracer.go * refactor MessageEvent * defer unlock * some more cleanup in span.go * rename *MessageEvent* to *Event* * cleanup comments in trace_test.go * fix typos. * return full string ID for traceID and spanID.
This commit is contained in:
@@ -53,14 +53,13 @@ func (sc SpanContext) HasSpanID() bool {
|
||||
}
|
||||
|
||||
func (sc SpanContext) SpanIDString() string {
|
||||
p := fmt.Sprintf("%.16x", sc.SpanID)
|
||||
return p[0:3] + ".." + p[13:16]
|
||||
return fmt.Sprintf("%.16x", sc.SpanID)
|
||||
}
|
||||
|
||||
func (sc SpanContext) TraceIDString() string {
|
||||
p1 := fmt.Sprintf("%.16x", sc.TraceID.High)
|
||||
p2 := fmt.Sprintf("%.16x", sc.TraceID.Low)
|
||||
return p1[0:3] + ".." + p2[13:16]
|
||||
return p1 + p2
|
||||
}
|
||||
|
||||
func (sc SpanContext) IsSampled() bool {
|
||||
|
||||
@@ -88,11 +88,11 @@ func TestSpanIDString(t *testing.T) {
|
||||
{
|
||||
name: "fourtytwo",
|
||||
sc: SpanContext{SpanID: uint64(42)},
|
||||
want: `000..02a`,
|
||||
want: `000000000000002a`,
|
||||
}, {
|
||||
name: "empty",
|
||||
sc: SpanContext{},
|
||||
want: `000..000`,
|
||||
want: `0000000000000000`,
|
||||
},
|
||||
} {
|
||||
t.Run(testcase.name, func(t *testing.T) {
|
||||
@@ -119,11 +119,11 @@ func TestTraceIDString(t *testing.T) {
|
||||
Low: uint64(42),
|
||||
},
|
||||
},
|
||||
want: `000..02a`,
|
||||
want: `000000000000002a000000000000002a`,
|
||||
}, {
|
||||
name: "empty",
|
||||
sc: SpanContext{TraceID: TraceID{}},
|
||||
want: `000..000`,
|
||||
want: `00000000000000000000000000000000`,
|
||||
},
|
||||
} {
|
||||
t.Run(testcase.name, func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user