diff --git a/coolamqp/attaches/declarer.py b/coolamqp/attaches/declarer.py index 1e0cbdba14cd70b13883568c2d5a2b671097c8bc..ebc579d44583f6cd5fe8d8422ec7e3c8bbd75ed6 100644 --- a/coolamqp/attaches/declarer.py +++ b/coolamqp/attaches/declarer.py @@ -45,14 +45,23 @@ class Operation(object): def span_exception(self, exception): if self.parent_span is not None: - if self.processing_span is not None: + if self.enqueued_span is None: from opentracing import tags, logs - self.processing_span.set_tag(tags.ERROR, True) - self.processing_span.log_kv({logs.EVENT: tags.ERROR, + self.enqueued_span.set_tag(tags.ERROR, True) + self.enqueued_span.log_kv({logs.EVENT: tags.ERROR, logs.ERROR_KIND: exception, logs.ERROR_OBJECT: exception}) - self.processing_span.finish() - self.processing_span = None + self.enqueued_span.finish() + self.enqueued_span = None + + if self.processing_span is not None: + from opentracing import tags, logs + self.processing_span.set_tag(tags.ERROR, True) + self.processing_span.log_kv({logs.EVENT: tags.ERROR, + logs.ERROR_KIND: exception, + logs.ERROR_OBJECT: exception}) + self.processing_span.finish() + self.processing_span = None if self.enqueued_span is not None: self.enqueued_span.finish() self.enqueued_span = None @@ -73,10 +82,12 @@ class Operation(object): self.processing_span = self.declarer.cluster.tracer.start_span('Declaring', child_of=self.parent_span, references=follows_from(self.enqueued_span)) + self.enqueued_span = None def span_finished(self): - if self.parent_span is None: + if self.processing_span is None: self.processing_span.finish() + self.processing_span = None def span_begin(self): if self.enqueued_span is not None: diff --git a/coolamqp/attaches/publisher.py b/coolamqp/attaches/publisher.py index 77cc6b90b56f74f0107964046abcac294594c6e1..09dd41ccff0b2d037ed722302bc9d13c7803e134 100644 --- a/coolamqp/attaches/publisher.py +++ b/coolamqp/attaches/publisher.py @@ -212,8 +212,8 @@ class Publisher(Channeler, Synchronized): if not fut.set_running_or_notify_cancel(): if span_enqueued is not None: - import opentracing - span_enqueued.log_kv({opentracing.logs.EVENT: 'Cancelled'}) + from opentracing import logs + span_enqueued.log_kv({logs.EVENT: 'Cancelled'}) span_enqueued.finish() parent_span.finish() continue # cancelled diff --git a/coolamqp/attaches/utils.py b/coolamqp/attaches/utils.py index 5fe56866f9f9b15c5d20892fdeb03b3ba9b2eed0..e9a693cf69ee00e7fdf1e775eaf66612f5792d59 100644 --- a/coolamqp/attaches/utils.py +++ b/coolamqp/attaches/utils.py @@ -135,8 +135,7 @@ class AtomicTagger(object): i = len(self.tags) - 1 # start index while i > 0: # this will terminate at i=0 - if self.tags[i][ - 0] > tag: # this means we should insert it here... + if self.tags[i][0] > tag: # this means we should insert it here... break i -= 1 # previousl index