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

#390: Issues with the new timer recorder plugin for Chrome #440

Merged
merged 7 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
7 changes: 5 additions & 2 deletions ant-scripts/timerrecorder_chrome.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,13 @@
<echo>Path to Chrome : ${timerrecorder.chrome.executable}</echo>

<!-- assemble crx -->
<!-- When undoing this, fix "- -" as well. XML sucks.
<exec executable="${timerrecorder.chrome.executable}" failonerror="true">
<arg value="--pack-extension=${basedir}/${target.dir}" />
<arg value="--pack-extension-key=${basedir}/${timerrecorder.chrome.dir}/xlt-timerrecorder-chrome.pem" />
<arg value="- -pack-extension=${basedir}/${target.dir}" />
<arg value="- -pack-extension-key=${basedir}/${timerrecorder.chrome.dir}/xlt-timerrecorder-chrome.pem" />
</exec>
-->
<zip destfile="${build.tools.dir}/${crx.fileName}" basedir="${basedir}/${target.dir}" />
</target>

<!-- Create CRX file. -->
Expand Down
18 changes: 15 additions & 3 deletions src/main/java/com/xceptance/xlt/api/webdriver/XltChromeDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,16 @@ public class XltChromeDriver extends ChromeDriver
*/
private static final boolean RECORD_INCOMPLETE_ENABLED;

/**
* The (hidden) XLT property to enable the use of the session storage in the Chrome timer recorder extension.
*/
private static final String PROPERTY_USE_SESSION_STORAGE = PROPERTY_DOMAIN + "useSessionStorage";

/**
* Whether the Chrome timer recorder extension should use the session storage. Defaults to false.
*/
private static final boolean USE_SESSION_STORAGE;

/**
* The base name of the extension file.
*/
Expand Down Expand Up @@ -177,6 +187,7 @@ public class XltChromeDriver extends ChromeDriver

HEADLESS_ENABLED = props.getProperty(PROPERTY_HEADLESS, false);
RECORD_INCOMPLETE_ENABLED = props.getProperty(PROPERTY_RECORD_INCOMPLETE, false);
USE_SESSION_STORAGE = props.getProperty(PROPERTY_USE_SESSION_STORAGE, false);
IGNORE_MISSING_DATA = props.getProperty(PROPERTY_IGNORE_MISSING_DATA, true);

// unpack the extension file to the temp directory
Expand Down Expand Up @@ -300,8 +311,9 @@ private void init()
*/
private void initConnect(final int retryCount)
{
final String url = "data:,xltParameters?xltPort=" + connectionHandler.getPort() + "&clientID=" + connectionHandler.getID() +
"&recordIncompleted=" + RECORD_INCOMPLETE_ENABLED;
final String url = String.format("data:,xltParameters?xltPort=%d&clientID=%s&recordIncompleted=%b&useSessionStorage=%b",
connectionHandler.getPort(), connectionHandler.getID(), RECORD_INCOMPLETE_ENABLED,
USE_SESSION_STORAGE);

long timeout = CONNECT_RETRY_BASE_TIMEOUT;

Expand Down Expand Up @@ -363,7 +375,7 @@ private static ChromeDriverService modifyService(ChromeDriverService service, fi

// read the environment settings
final Map<String, String> environment = ReflectionUtils.readField(ChromeDriverService.class, service,
FIELD_NAME_ENVIRONMENT);
FIELD_NAME_ENVIRONMENT);

// create the new environment settings including the DISPLAY variable
final ImmutableMap.Builder<String, String> mapBuilder = new ImmutableMap.Builder<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,17 +168,25 @@ public void onConnect(ClientPerformanceExtensionConnector connector, ClientPerfo
@Override
public void onMessage(ClientPerformanceExtensionConnection connection, JSONObject data, Responder responder)
{
final String action = data.optString("action");

LOG.debug("Message received: {}", action);

if (LOG.isTraceEnabled())
{
LOG.trace("Message received: " + data);
LOG.trace("Message data: " + data);
h-arlt marked this conversation as resolved.
Show resolved Hide resolved
}

try
{
if ("DUMP_PERFORMANCE_DATA".equals(data.optString("action")))
if ("DUMP_PERFORMANCE_DATA".equals(action))
{
dumpPerformanceData(data.optString("performanceData"));
}
else if ("KEEP_ALIVE_PING".equals(action))
{
// ignore for now
}
}
catch (Throwable t)
{
Expand Down Expand Up @@ -213,11 +221,25 @@ private void dumpPerformanceData(String rawData)
{
final List<ClientPerformanceData> performanceData = PerformanceDataTransformator.getTransformedPerformanceDataList(rawData);

if (LOG.isDebugEnabled())
{
int requestTimings = 0;
int pageLoadTimings = 0;

for (final ClientPerformanceData clientPerformanceData : performanceData)
{
requestTimings += clientPerformanceData.getRequestList().size();
pageLoadTimings += clientPerformanceData.getCustomDataList().size();
}

LOG.debug("Received client-performance metrics (requests: {}, page load timings: {})", requestTimings, pageLoadTimings);
}

ClientPerformanceMetrics.updatePerformanceData(session, performanceData);

if (LOG.isDebugEnabled())
if (LOG.isTraceEnabled())
{
LOG.debug("Dumped client-performance metrics: " + rawData);
LOG.trace("Dumped client-performance metrics: " + rawData);
}
}
catch (final Throwable t)
Expand All @@ -229,7 +251,7 @@ private void dumpPerformanceData(String rawData)
/**
* Fetch the remaining timing data from the client which were not sent.
*/
public String fetchPerformanceData() throws JSONException, TimeoutException, CommunicationException, InterruptedException
private String fetchPerformanceData() throws JSONException, TimeoutException, CommunicationException, InterruptedException
{
ClientPerformanceExtensionConnection conn = currentConnection;
if (conn == null || !conn.isOpen())
Expand Down
Loading