Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Stylish imports
Browse files Browse the repository at this point in the history
  • Loading branch information
JorikSchellekens committed Aug 16, 2019
1 parent 303a58f commit 63179ef
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
4 changes: 2 additions & 2 deletions synapse/federation/federation_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
from twisted.internet.abstract import isIPAddress
from twisted.python import failure

import synapse.logging.opentracing as opentracing
from synapse.api.constants import EventTypes, Membership
from synapse.api.errors import (
AuthError,
Expand All @@ -44,6 +43,7 @@
from synapse.federation.units import Edu, Transaction
from synapse.http.endpoint import parse_server_name
from synapse.logging.context import nested_logging_context
from synapse.logging.opentracing import start_active_span_from_edu
from synapse.logging.utils import log_function
from synapse.replication.http.federation import (
ReplicationFederationSendEduRestServlet,
Expand Down Expand Up @@ -809,7 +809,7 @@ def on_edu(self, edu_type, origin, content):
if not handler:
logger.warn("No handler registered for EDU type %s", edu_type)

with opentracing.start_active_span_from_edu(content, "handle_edu"):
with start_active_span_from_edu(content, "handle_edu"):
try:
yield handler(origin, content)
except SynapseError as e:
Expand Down
8 changes: 3 additions & 5 deletions synapse/federation/sender/per_destination_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

from twisted.internet import defer

import synapse.logging.opentracing as opentracing
from synapse.api.errors import (
FederationDeniedError,
HttpResponseException,
Expand All @@ -30,6 +29,7 @@
from synapse.events import EventBase
from synapse.federation.units import Edu
from synapse.handlers.presence import format_user_presence_state
from synapse.logging.opentracing import extract_text_map, start_active_span_follows_from
from synapse.metrics import sent_transactions_counter
from synapse.metrics.background_process_metrics import run_as_background_process
from synapse.storage import UserPresenceState
Expand Down Expand Up @@ -211,17 +211,15 @@ def _transaction_transmission_loop(self):
# are never received on the remote the span effectively has no causality.

span_contexts = [
opentracing.extract_text_map(
extract_text_map(
json.loads(
edu.get_dict().get("content", {}).get("context", "{}")
)
)
for edu in pending_edus
]

with opentracing.start_active_span_follows_from(
"send_transaction", span_contexts
):
with start_active_span_follows_from("send_transaction", span_contexts):
# BEGIN CRITICAL SECTION
#
# In order to avoid a race condition, we need to make sure that
Expand Down
15 changes: 10 additions & 5 deletions synapse/handlers/devicemessage.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@

from twisted.internet import defer

import synapse.logging.opentracing as opentracing
from synapse.api.errors import SynapseError
from synapse.logging.opentracing import (
get_active_span_text_map,
set_tag,
start_active_span,
whitelisted_homeserver,
)
from synapse.types import UserID, get_domain_from_id
from synapse.util.stringutils import random_string

Expand Down Expand Up @@ -103,19 +108,19 @@ def send_device_message(self, sender_user_id, message_type, messages):

message_id = random_string(16)

context = opentracing.get_active_span_text_map()
context = get_active_span_text_map()

remote_edu_contents = {}
for destination, messages in remote_messages.items():
with opentracing.start_active_span("to_device_for_user"):
opentracing.set_tag("destination", destination)
with start_active_span("to_device_for_user"):
set_tag("destination", destination)
remote_edu_contents[destination] = {
"messages": messages,
"sender": sender_user_id,
"type": message_type,
"message_id": message_id,
"org.matrix.context": json.dumps(context)
if opentracing.whitelisted_homeserver(destination)
if whitelisted_homeserver(destination)
else None,
}

Expand Down

0 comments on commit 63179ef

Please sign in to comment.