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

[uss_qualifier] Fix aggregate queries stats for #343 #345

Merged
merged 1 commit into from
Nov 16, 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
37 changes: 37 additions & 0 deletions monitoring/monitorlib/fetch/evaluation_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from datetime import datetime

from implicitdict import StringBasedDateTime

from monitoring.monitorlib.fetch import (
Query,
RequestDescription,
ResponseDescription,
evaluation,
)


def _fq(ts: int, elapsed: float):
"""returns a fake query with the specified epoch timestamp as 'initiated_at'"""
return Query(
request=RequestDescription(
method=None,
url=None,
initiated_at=StringBasedDateTime(datetime.fromtimestamp(ts)),
),
response=ResponseDescription(elapsed_s=elapsed, reported=None),
)


def test_get_init_subsequent_queries_durations():
dummy_queries = [_fq(10, 2), _fq(12, 1), _fq(13, 0.9), _fq(14, 0.8)]
query_dict = {"some-url": dummy_queries}
(init_d, subseq_d) = evaluation.get_init_subsequent_queries_durations(5, query_dict)

assert init_d == [2]
assert subseq_d == [1, 0.9, 0.8]

query_dict = {"some-url": dummy_queries, "another-url": dummy_queries}

(init_d, subseq_d) = evaluation.get_init_subsequent_queries_durations(5, query_dict)
assert init_d == [2, 2]
assert subseq_d == [1, 0.9, 0.8, 1, 0.9, 0.8]
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ def _init_queries(self, context: ExecutionContext):

for query in self._queries:
for base_url, participant in self._participants_by_base_url.items():
if query.request.url.startswith(base_url):
self._queries_by_participant[participant].append(query)
# TODO opportunity here to set the participant_id on the query if it's not already there
# maybe do so after most/all queries have been tagged at the call site where possible
if query.request.url.startswith(
base_url
) and not query.has_field_with_value("participant_id"):
query.participant_id = participant
break

# Only consider queries with the participant/server explicitly identified
Expand Down Expand Up @@ -372,3 +372,8 @@ def _dp_display_data_times_step(self):
f"{participant}/display_data",
f"percentiles on {len(relevant_queries)} relevant queries ({len(relevant_queries_by_url)} different URLs, {len(init_durations)} initial queries, {len(subsequent_durations)} subsequent queries): init 95th: {init_95th}; init 99th: {init_99th}; subsequent 95th: {subsequent_95th}; subsequent 99th: {subsequent_99th}",
)

self.record_note(
f"{participant}/display_data details",
f"Initial durations: {init_durations} subsequent durations: {subsequent_durations}",
)
Loading