Skip to content

Commit 4cd48d1

Browse files
committed
chore: rewrite requireParent condition to avoid unnecessary work
1 parent 88a9788 commit 4cd48d1

File tree

1 file changed

+1
-2
lines changed
  • packages/opentelemetry-plugin-http/src

1 file changed

+1
-2
lines changed

packages/opentelemetry-plugin-http/src/http.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -432,13 +432,12 @@ export class HttpPlugin extends BasePlugin<Http> {
432432
* If a parent is required but not present, we use a `NoRecordingSpan` to still
433433
* propagate context without recording it.
434434
*/
435-
const hasParent = this._tracer.getCurrentSpan() !== undefined;
436435
const requireParent =
437436
options.kind === SpanKind.CLIENT
438437
? this._config.requireParentforOutgoingSpans
439438
: this._config.requireParentforIncomingSpans;
440439
let span: Span;
441-
if (hasParent === false && requireParent === true) {
440+
if (requireParent === true && this._tracer.getCurrentSpan() === undefined) {
442441
const spanContext =
443442
getExtractedSpanContext(context.active()) ?? plugin._emptySpanContext;
444443
// TODO: Refactor this when a solution is found in

0 commit comments

Comments
 (0)