Skip to content

Commit 483bc39

Browse files
committed
tracing: outline span creation in StartSpan so string concat can be inlined and folded at compiletime
Fixes #67
1 parent 26cbf73 commit 483bc39

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

bitswap/client/internal/tracing.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,10 @@ import (
88
)
99

1010
func StartSpan(ctx context.Context, name string, opts ...trace.SpanStartOption) (context.Context, trace.Span) {
11-
return otel.Tracer("go-bitswap").Start(ctx, "Bitswap."+name, opts...)
11+
return startSpan(ctx, "Bitswap.Client."+name, opts...)
12+
}
13+
14+
// outline logic so the string concatenation can be inlined and executed at compile time
15+
func startSpan(ctx context.Context, name string, opts ...trace.SpanStartOption) (context.Context, trace.Span) {
16+
return otel.Tracer("go-bitswap").Start(ctx, name, opts...)
1217
}

bitswap/internal/tracing.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,10 @@ import (
88
)
99

1010
func StartSpan(ctx context.Context, name string, opts ...trace.SpanStartOption) (context.Context, trace.Span) {
11-
return otel.Tracer("go-bitswap").Start(ctx, "Bitswap."+name, opts...)
11+
return startSpan(ctx, "Bitswap."+name, opts...)
12+
}
13+
14+
// outline logic so the string concatenation can be inlined and executed at compile time
15+
func startSpan(ctx context.Context, name string, opts ...trace.SpanStartOption) (context.Context, trace.Span) {
16+
return otel.Tracer("go-bitswap").Start(ctx, name, opts...)
1217
}

blockservice/internal/tracing.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,10 @@ import (
88
)
99

1010
func StartSpan(ctx context.Context, name string, opts ...trace.SpanStartOption) (context.Context, trace.Span) {
11-
return otel.Tracer("go-blockservice").Start(ctx, "Blockservice."+name, opts...)
11+
return startSpan(ctx, "Blockservice."+name, opts...)
12+
}
13+
14+
// outline logic so the string concatenation can be inlined and executed at compile time
15+
func startSpan(ctx context.Context, name string, opts ...trace.SpanStartOption) (context.Context, trace.Span) {
16+
return otel.Tracer("go-blockservice").Start(ctx, name, opts...)
1217
}

0 commit comments

Comments
 (0)