small logging changes
This commit is contained in:
parent
d36d3d7449
commit
3dd37c0bf1
3 changed files with 12 additions and 6 deletions
|
@ -57,7 +57,7 @@ class PingAdapter(Adapter):
|
||||||
else:
|
else:
|
||||||
latency = 0
|
latency = 0
|
||||||
|
|
||||||
worker.log.info(f'{worker.name}: alive={alive} latency={latency}ms')
|
worker.log.info(f'alive={alive} latency={latency}ms')
|
||||||
return cls._construct(alive, latency)
|
return cls._construct(alive, latency)
|
||||||
|
|
||||||
|
|
||||||
|
@ -79,8 +79,7 @@ class HttpAdapter(Adapter):
|
||||||
|
|
||||||
latency = round((t_end - t_start) * 1000)
|
latency = round((t_end - t_start) * 1000)
|
||||||
|
|
||||||
worker.log.info(f'{worker.name}: status={resp.status} '
|
worker.log.info(f'status={resp.status} latency={latency}ms')
|
||||||
f'latency={latency}ms')
|
|
||||||
|
|
||||||
if resp.status == 200:
|
if resp.status == 200:
|
||||||
return cls._construct(True, latency)
|
return cls._construct(True, latency)
|
||||||
|
|
|
@ -107,5 +107,5 @@ async def streaming_ws(request, ws):
|
||||||
await ws.ping()
|
await ws.ping()
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
except websockets.exceptions.ConnectionClosed as wc:
|
except websockets.exceptions.ConnectionClosed as wc:
|
||||||
log.warning(f'connection {ws.client_id} closed: {wc!r}')
|
log.warning(f'conn {ws.client_id} closed: {wc.code} {wc.reason!r}')
|
||||||
request.app.manager.unsub_all(ws)
|
request.app.manager.unsub_all(ws)
|
||||||
|
|
|
@ -137,10 +137,12 @@ class ServiceManager:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
log.info(f'unsubscribed {websocket.client_id} from {unsub}')
|
log.info(f'unsubscribed {websocket.client_id} from {unsub}')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self._websockets.pop(websocket.client_id)
|
self._websockets.pop(websocket.client_id)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return unsub
|
return unsub
|
||||||
|
|
||||||
def _ws_send(self, websocket, data: Any):
|
def _ws_send(self, websocket, data: Any):
|
||||||
|
@ -166,8 +168,13 @@ class ServiceManager:
|
||||||
def _send(websocket):
|
def _send(websocket):
|
||||||
return self._raw_send(websocket, channel, data)
|
return self._raw_send(websocket, channel, data)
|
||||||
|
|
||||||
tasks = map(_send, websockets)
|
tasks = list(map(_send, websockets))
|
||||||
return list(tasks)
|
|
||||||
|
clients = len(tasks)
|
||||||
|
if clients:
|
||||||
|
log.info(f'Dispatching on {channel} to {clients} clients')
|
||||||
|
|
||||||
|
return tasks
|
||||||
|
|
||||||
def publish_incident(self, op: int, data: Any):
|
def publish_incident(self, op: int, data: Any):
|
||||||
ws_ids = self.subscribers['incidents']
|
ws_ids = self.subscribers['incidents']
|
||||||
|
|
Loading…
Reference in a new issue