From fdbbda9497d3864cbbd1d4b2c7031c2e8cd66994 Mon Sep 17 00:00:00 2001 From: Tobias Stadler Date: Mon, 28 Feb 2022 16:57:54 +0100 Subject: [PATCH] Review by @jackshirazi --- .../java/co/elastic/apm/agent/impl/transaction/Span.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/Span.java b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/Span.java index 55863b67735..2302adba063 100644 --- a/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/Span.java +++ b/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/transaction/Span.java @@ -323,13 +323,13 @@ protected void afterEnd() { return; } if (!buffered.tryToCompress(this)) { - if (!parent.bufferedSpan.compareAndSet(buffered, this)) { + if (parent.bufferedSpan.compareAndSet(buffered, this)) { + this.tracer.endSpan(buffered); + } else { // the failed update would ideally lead to a compression attempt with the new buffer, // but we're dropping the compression attempt to keep things simple this.tracer.endSpan(buffered); this.tracer.endSpan(this); - } else { - this.tracer.endSpan(buffered); } } else if (isSampled()) { Transaction transaction = getTransaction();