Skip to content

logs from sitespeedio and insert custom headers #4462

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

Open
Domanicfaf opened this issue Mar 5, 2025 · 8 comments
Open

logs from sitespeedio and insert custom headers #4462

Domanicfaf opened this issue Mar 5, 2025 · 8 comments

Comments

@Domanicfaf
Copy link

Domanicfaf commented Mar 5, 2025

Debugging logs and custom header insertion

Command

sitespeed.io {url} --xvfb --browsertime.enableVideoRun false --browsertime.visualMetrics false --browsertime.chrome.windowRecorder false --chrome.windowRecorder false --video false --headless true --browsertime.chrome.args no-sandbox --chrome.enableChromeDriverLog true --chrome.enableVerboseChromeDriverLog true --chrome.collectPerfLog true --chrome.collectNetLog true --chrome.netLogCaptureMode Everything --chrome.collectConsoleLog true --logLevel trace --outputFolder $(pwd)/{result_dir} -n 1

Versions:

sitespeed.io 36.4.1
npm 10.8.2
node v20.18.3

Scenario

Debugging logs

I am currently using the following command, but I'm only receiving the following log files:

  1. chromeNetlog-1.json
  2. console-1.json.

However, I need the following logs as well:

  1. ChromeDriver logs
  2. Performance logs

Additionally, the console logs are not being populated as expected.

To summarize, I am looking for the logs that will help me debug in case an error occurs for any URL in Sitespeed as I am running this command via python code

Custom header

Also 1 more thing.
I tried to insert a custom header using
--browsertime.requestheader 'key: value' as the url does not allow access until that header is present, but the site was still not accessible as per screenshots. So are custom headers not allowed in headless mode of chrome?

Any suggestions on above 2 scenarios

@Domanicfaf Domanicfaf changed the title How to get all logs from sitespeedio logs from sitespeedio and insert custom headers Mar 5, 2025
@soulgalore
Copy link
Member

Hi @Domanicfaf for getting the logs, make sure each parameter that is going to browsertime, has the browsertime path of the key, that will also make more sense if you move the configuration to a config json file.

For me these works:
--browsertime.chrome.collectPerfLog true --browsertime.chrome.enableChromeDriverLog true

To verify if the request header works, you can use, that will echo out the request header you add:
sitespeed.io https://httpbin.org/headers --browsertime.requestheader 'key:value'

@Domanicfaf
Copy link
Author

Hey @soulgalore , that worked pretty good thanks. Now I am getting performance and chromedriver logs. Also the custom header check worked so thanks.

But the console logs as usual has only Warning logs even though I have trace in loglevel. Any help with that. I want all logs as much detailing as possible

@Domanicfaf
Copy link
Author

So right now I only get logs of"level":"WARNING"in console logs even though I have trace in loglevel which should basically give me detailed logs right?

@soulgalore
Copy link
Member

For Chrome console log, it is set to ALL https://github.com/sitespeedio/browsertime/blob/24f58672fde099d0bc019405feff10a46b1392df/lib/edge/webdriver/builder.js#L62 so I think it gives you whatever Chrome provides.

@soulgalore
Copy link
Member

For logLevel (that was just released in the latest release) you set the log level for the sitespeed.io/browsetime log, not Chromedriver/Geckordriver and other logs, they are separate.

@Domanicfaf
Copy link
Author

Thanks for the help.

@Domanicfaf
Copy link
Author

Domanicfaf commented Apr 1, 2025

Hey @soulgalore could you help me understand the mobile emulation part on sitespeed.

I have read the documentation for mobile emulation. Referred links are as follows

  1. https://www.sitespeed.io/documentation/sitespeed.io/mobile-phones/
  2. https://www.sitespeed.io/documentation/sitespeed.io/mobile-phones/#test-on-emulated-mobile
  3. https://www.sitespeed.io/documentation/sitespeed.io/cpu-benchmark/
  4. https://www.sitespeed.io/documentation/sitespeed.io/configuration/

So below are my questions regarding it

Android

When I run sitespeed.io --android https://www.sitespeed.io do I need to have Android real device as documentation asks to enable developer mode after installing apt-get install android-tools-adb .Reference link

Mobile

I was able to use --mobile for testing the website on default device that is Moto G4 but I was not able to understand how to pass width/height. Also can I select any other mobile device using this option?

--browsertime.chrome.mobileEmulation.deviceName

This allowed me to select another mobile device which is great but then whats the difference between --mobile and --browsertime.chrome.mobileEmulation.deviceName argument. Like which argument has what benefits? Is it CPU throttling

Also one followup question is why the --android argument asks for developer mode but the other arguments work without it.
Is it because --android option allows us to test it on real device?

@soulgalore
Copy link
Member

I created #4492 for you (instead of hijacking the old issue :))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants