summary refs log tree commit diff
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2018-11-27 11:22:49 +0000
committerBrendan Abolivier <babolivier@matrix.org>2019-02-13 15:16:03 +0000
commitfe6e221cfac9215625d3b2b5c7e4092bcf35c8c5 (patch)
treea076b24ffb856d1fc2e6625451cf75604c2867f4
parentStrip signatures and hashes on outgoing events (diff)
downloadsynapse-fe6e221cfac9215625d3b2b5c7e4092bcf35c8c5.tar.xz
Opentracing. Reduce event ID size
-rw-r--r--synapse/events/builder.py2
-rw-r--r--synapse/federation/transaction_queue.py6
-rw-r--r--synapse/federation/transport/server.py8
-rw-r--r--synapse/federation/units.py2
-rw-r--r--synapse/http/matrixfederationclient.py11
5 files changed, 20 insertions, 9 deletions
diff --git a/synapse/events/builder.py b/synapse/events/builder.py
index e662eaef10..03ea2ef14f 100644
--- a/synapse/events/builder.py
+++ b/synapse/events/builder.py
@@ -52,7 +52,7 @@ class EventBuilderFactory(object):
         i = str(self.event_id_count)
         self.event_id_count += 1
 
-        local_part = str(int(self.clock.time())) + i + random_string(5)
+        local_part = random_string(3) + str(i)
 
         e_id = EventID(local_part, self.hostname)
 
diff --git a/synapse/federation/transaction_queue.py b/synapse/federation/transaction_queue.py
index 80536856a6..fe02ace8a7 100644
--- a/synapse/federation/transaction_queue.py
+++ b/synapse/federation/transaction_queue.py
@@ -625,6 +625,10 @@ class TransactionQueue(object):
         txn_id = str(self._next_txn_id)
 
         span.set_tag("txn-id", txn_id)
+        span.log_kv({
+            "pdus": len(pdus),
+            "edus": len(edus),
+        })
 
         logger.debug(
             "TX [%s] {%s} Attempting new transaction"
@@ -695,8 +699,6 @@ class TransactionQueue(object):
             destination, txn_id, code
         )
 
-        span.set_tag("http.status_code", code)
-
         yield self.transaction_actions.delivered(
             transaction, code, response
         )
diff --git a/synapse/federation/transport/server.py b/synapse/federation/transport/server.py
index 6af0832511..b5f9d9ebb8 100644
--- a/synapse/federation/transport/server.py
+++ b/synapse/federation/transport/server.py
@@ -18,6 +18,7 @@ import functools
 import logging
 import re
 import opentracing
+from opentracing.ext import tags
 
 import six
 
@@ -267,8 +268,9 @@ class BaseFederationServlet(object):
                 parent_ctx = None
 
             tags_dict = {
-                "http.method": request.method.decode('ascii'),
-                "http.url": request.uri.decode('ascii'),
+                tags.HTTP_METHOD: request.method.decode('ascii'),
+                tags.HTTP_URL: request.uri.decode('ascii'),
+                tags.SPAN_KIND: tags.SPAN_KIND_RPC_SERVER,
             }
 
             span = self.tracer.start_span(
@@ -306,7 +308,7 @@ class BaseFederationServlet(object):
                         origin, content, request.args, *args, **kwargs
                     )
 
-                span.set_tag("http.status_code", response[0])
+                span.set_tag(tags.HTTP_STATUS_CODE, response[0])
 
             defer.returnValue(response)
 
diff --git a/synapse/federation/units.py b/synapse/federation/units.py
index d278475d9a..bfd07e6615 100644
--- a/synapse/federation/units.py
+++ b/synapse/federation/units.py
@@ -132,6 +132,8 @@ def _mangle_pdu(pdu_json):
     pdu_json["auth_events"] = list(_strip_hashes(pdu_json["auth_events"]))
     pdu_json["prev_events"] = list(_strip_hashes(pdu_json["prev_events"]))
 
+    logger.info("Mangled PDU: %s", pdu_json)
+
     return pdu_json
 
 
diff --git a/synapse/http/matrixfederationclient.py b/synapse/http/matrixfederationclient.py
index 0bbd928b92..3d45747db4 100644
--- a/synapse/http/matrixfederationclient.py
+++ b/synapse/http/matrixfederationclient.py
@@ -20,6 +20,7 @@ import sys
 from io import BytesIO
 
 import opentracing
+from opentracing.ext import tags
 
 from six import PY3, string_types, iteritems
 from six.moves import urllib
@@ -351,8 +352,12 @@ class MatrixFederationHttpClient(object):
                             reactor=self.hs.get_reactor(),
                         )
 
-                        child_span.set_tag("http.method", request.method)
-                        child_span.set_tag("http.url", url_str)
+                        child_span.set_tag(tags.HTTP_METHOD, request.method)
+                        child_span.set_tag(tags.HTTP_URL, url_str)
+                        child_span.set_tag(
+                            tags.SPAN_KIND,
+                            tags.SPAN_KIND_RPC_CLIENT,
+                        )
 
                         try:
                             with Measure(self.clock, "outbound_request"):
@@ -363,7 +368,7 @@ class MatrixFederationHttpClient(object):
                             child_span.set_tag("error", str(e))
                             raise
 
-                        child_span.set_tag("http.status_code", response.code)
+                        child_span.set_tag(tags.HTTP_STATUS_CODE, response.code)
 
                     break
                 except Exception as e: