You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-11-25 22:41:46 +02:00
Refactor current span check (#419)
- Simplify conditionals. - Remove unnecessary nil check. Go type assertions return a bool value indicating whether the assertion succeeded. When the assertion is performed on a nil value, the bool becomes false without a panic, therefore the nil check is unnecessary.
This commit is contained in:
committed by
Liz Fong-Jones
parent
4a8667986b
commit
d4557c3dfa
@@ -47,13 +47,9 @@ func (tr *tracer) Start(ctx context.Context, name string, o ...apitrace.StartOpt
|
|||||||
// Future relationship types may have different behavior,
|
// Future relationship types may have different behavior,
|
||||||
// e.g., adding a `Link` instead of setting the `parent`
|
// e.g., adding a `Link` instead of setting the `parent`
|
||||||
}
|
}
|
||||||
} else {
|
} else if p, ok := apitrace.SpanFromContext(ctx).(*span); ok {
|
||||||
if p := apitrace.SpanFromContext(ctx); p != nil {
|
p.addChild()
|
||||||
if sdkSpan, ok := p.(*span); ok {
|
parent = p.spanContext
|
||||||
sdkSpan.addChild()
|
|
||||||
parent = sdkSpan.spanContext
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
spanName := tr.spanNameWithPrefix(name)
|
spanName := tr.spanNameWithPrefix(name)
|
||||||
|
|||||||
Reference in New Issue
Block a user