-
Notifications
You must be signed in to change notification settings - Fork 0
/
span.go
45 lines (38 loc) · 786 Bytes
/
span.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package trace
import (
"context"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/trace"
)
func SpanName() string {
// fnName := GetCallerName(3)
// return getSpanNameFromCallerName(fnName)
return "implement me"
}
func StartSpan(
ctx context.Context,
spanName string,
opts ...trace.SpanStartOption,
) (
context.Context,
trace.Span,
) {
var (
tracerName = ""
tracer = trace.SpanFromContext(ctx).TracerProvider().Tracer(tracerName)
)
ctx, span := tracer.Start(ctx, spanName, opts...)
if span.IsRecording() {
return ctx, span
}
return otel.Tracer(tracerName).Start(ctx, spanName, opts...)
}
func StartNamedSpan(
ctx context.Context,
opts ...trace.SpanStartOption,
) (
context.Context,
trace.Span,
) {
return StartSpan(ctx, SpanName(), opts...)
}