Skip to content

Commit

Permalink
Trace STOMP connection and sending messages
Browse files Browse the repository at this point in the history
  • Loading branch information
hluk committed Feb 21, 2024
1 parent 3fc31c4 commit a17ed10
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions resultsdb/messaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import pkg_resources
import stomp
from opentelemetry import trace
from tenacity import retry, stop_after_attempt, wait_exponential

from resultsdb.models import db
Expand All @@ -42,6 +43,7 @@
from opentelemetry.trace.propagation.tracecontext import TraceContextTextMapPropagator

log = logging.getLogger(__name__)
tracer = trace.get_tracer(__name__)

SERIALIZE = Serializer().serialize

Expand Down Expand Up @@ -222,6 +224,7 @@ def __init__(self, **kwargs):
if self.use_ssl:
self.conn.set_ssl(**self.ssl_args)

@tracer.start_as_current_span("StompPlugin.publish")
def publish(self, msg):
# Add telemetry information. This includes an extra key
# traceparent.
Expand All @@ -239,9 +242,10 @@ def _publish_with_retry(self, **kwargs):

# Inactive connection is be closed/disconnected automatically
# after a short time.
self.conn.connect(wait=True)

self.conn.send(**kwargs)
with tracer.start_as_current_span("StompPlugin.publish.connect"):
self.conn.connect(wait=True)
with tracer.start_as_current_span("StompPlugin.publish.send"):
self.conn.send(**kwargs)
log.debug("Published message through stomp: %s", kwargs["body"])


Expand Down

0 comments on commit a17ed10

Please sign in to comment.