diff --git a/lib/elastic_apm/spies/mongo.rb b/lib/elastic_apm/spies/mongo.rb index 8e04f81e8..d9ed837fd 100644 --- a/lib/elastic_apm/spies/mongo.rb +++ b/lib/elastic_apm/spies/mongo.rb @@ -96,9 +96,8 @@ def push_event(event) def pop_event(event) span = events.delete(event.operation_id) - return unless (curr = ElasticAPM.current_span) + ElasticAPM.end_span(span) - curr == span && ElasticAPM.end_span end def build_context(event)