Merge pull request #1985 from lbryio/fix-ttfb-analytics
fix the time to the head blob including the time to the sd blob in analytics
This commit is contained in:
commit
2df7284c29
2 changed files with 20 additions and 1 deletions
|
@ -455,7 +455,7 @@ class StreamManager:
|
|||
), timeout
|
||||
)
|
||||
time_to_descriptor = await descriptor_time_fut
|
||||
time_to_first_bytes = self.loop.time() - start_download_time
|
||||
time_to_first_bytes = self.loop.time() - start_download_time - time_to_descriptor
|
||||
self.wait_for_stream_finished(stream)
|
||||
if fee_address and fee_amount and not to_replace:
|
||||
stream.tx = await self.wallet.send_amount_to_address(
|
||||
|
|
|
@ -113,6 +113,25 @@ class TestStreamManager(BlobExchangeTestBase):
|
|||
binascii.hexlify(generate_id()).decode()))
|
||||
self.exchange_rate_manager = get_dummy_exchange_rate_manager(time)
|
||||
|
||||
async def test_time_to_first_bytes(self):
|
||||
await self.setup_stream_manager()
|
||||
checked_post = False
|
||||
|
||||
async def check_post(event):
|
||||
self.assertEqual(event['event'], 'Time To First Bytes')
|
||||
total_duration = event['properties']['total_duration']
|
||||
resolve_duration = event['properties']['resolve_duration']
|
||||
head_blob_duration = event['properties']['head_blob_duration']
|
||||
sd_blob_duration = event['properties']['sd_blob_duration']
|
||||
self.assertTrue(total_duration >= resolve_duration + head_blob_duration + sd_blob_duration)
|
||||
nonlocal checked_post
|
||||
checked_post = True
|
||||
|
||||
self.stream_manager.analytics_manager._post = check_post
|
||||
await self.stream_manager.download_stream_from_uri(self.uri, self.exchange_rate_manager)
|
||||
await asyncio.sleep(0, loop=self.loop)
|
||||
self.assertTrue(checked_post)
|
||||
|
||||
async def test_download_stop_resume_delete(self):
|
||||
await self.setup_stream_manager()
|
||||
received = []
|
||||
|
|
Loading…
Reference in a new issue