Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use incr for ws disconnect stats events #1223

Merged
merged 1 commit into from
Apr 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "querybook",
"version": "3.23.1",
"version": "3.23.2",
"description": "A Big Data Webapp",
"private": true,
"scripts": {
Expand Down
18 changes: 13 additions & 5 deletions querybook/server/datasources_socketio/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ def handler(*args, **kwargs):
if not current_user.is_authenticated:
LOG.error("Unauthorized websocket access")
disconnect()
# decrement ws connections counter on disconnect
stats_logger.decr(WS_CONNECTIONS)
# incr ws connections counter on disconnect
stats_logger.incr(
WS_CONNECTIONS, tags={"namespace": namespace, "event": "disconnect"}
)
else:
try:
if websocket_logging:
Expand All @@ -41,10 +43,16 @@ def handler(*args, **kwargs):

# increment ws connections counter on connect
if url == "connect":
stats_logger.incr(WS_CONNECTIONS, tags={"namespace": namespace})
# decrement ws connections counter on disconnect
stats_logger.incr(
WS_CONNECTIONS,
tags={"namespace": namespace, "event": "connect"},
)
# incr ws connections counter on disconnect
elif url == "disconnect":
stats_logger.decr(WS_CONNECTIONS, tags={"namespace": namespace})
stats_logger.incr(
WS_CONNECTIONS,
tags={"namespace": namespace, "event": "disconnect"},
)

handler.__raw__ = fn
return handler
Expand Down
2 changes: 0 additions & 2 deletions querybook/server/tasks/run_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ def run_query_task(
7406, "{}\n{}".format(e, traceback.format_exc())
)
finally:
stats_logger.decr(QUERY_EXECUTIONS, tags={"execution_type": execution_type})

# When the finally block is reached, it is expected
# that the executor should be in one of the end state
with DBSession() as session:
Expand Down