Skip to content

Commit

Permalink
Adding end_result_backend_time to Query model (#2766)
Browse files Browse the repository at this point in the history
This will help us keep track on how long it takes to push the data
into the results backend.
  • Loading branch information
mistercrunch committed May 17, 2017
1 parent 960b26c commit 2395fbb
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""add_result_backend_time_logging
Revision ID: a65458420354
Revises: 2fcdcb35e487
Create Date: 2017-04-25 10:00:58.053120
"""
from alembic import op
import sqlalchemy as sa

# revision identifiers, used by Alembic.
revision = 'a65458420354'
down_revision = '2fcdcb35e487'


def upgrade():
op.add_column(
'query',
sa.Column(
'end_result_backend_time',
sa.Numeric(precision=20, scale=6),
nullable=True))


def downgrade():
op.drop_column('query', 'end_result_backend_time')
8 changes: 5 additions & 3 deletions superset/models/sql_lab.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,11 @@ class Query(Model):

# Using Numeric in place of DateTime for sub-second precision
# stored as seconds since epoch, allowing for milliseconds
start_time = Column(Numeric(precision=3))
start_running_time = Column(Numeric(precision=3))
end_time = Column(Numeric(precision=3))
start_time = Column(Numeric(precision=20, scale=6))
start_running_time = Column(Numeric(precision=20, scale=6))
end_time = Column(Numeric(precision=20, scale=6))
end_result_backend_time = Column(Numeric(precision=20, scale=6))

changed_on = Column(
DateTime,
default=datetime.utcnow,
Expand Down
1 change: 1 addition & 0 deletions superset/sql_lab.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ def handle_error(msg):
logging.info("Storing results in results backend, key: {}".format(key))
results_backend.set(key, utils.zlib_compress(payload))
query.results_key = key
query.end_result_backend_time = utils.now_as_float()

session.merge(query)
session.commit()
Expand Down

0 comments on commit 2395fbb

Please sign in to comment.