We have written the journey for monitoring the web app using playwright and Typescript. We are facing a difficulty to view the script's console.log written with the step, on the uptime monitor.
Do we need to use any other library or method apart of console.log to view the the script logs.
Thank you for your post and welcome to the community.
Unfortunately, log statements from journey script aren't captured and reported back, unless if the script throws or breaks due to an error.
What's your use case by the way? If you want to test the journey or test how page behaves against a journey script, you can run the test via @elastic/synthetics package via command line locally and can see the log statements in terminal. I am pasting an example below if it helps:
// sample-inline-journey.ts
step('Go to home page', async () => {
await page.goto('https://www.elastic.co');
const titleElement = await page.locator('h1.title').first().elementHandle();
const title = await titleElement.innerText();
console.log(`Title: ${title}`);
expect(title).toBeTruthy();
});
Running and logging the log statements locally isn't a problem. It's works fine.
We have a a set of scenarios that runs every 10 mins which are monitored and in these scenarios we perform a page load or a button click, (at least 5-6 times and we have written the some useful logs in this logic), if a certain content in iframe isn't loaded --> We do this because we fetch the iframe content from 3rd party and to avoid false negatives.
On local we cannot really simulate the scenario where the iframe content isn't loading. We ideally play around with locators to check if the iteration logic works fine, which does. But at the run-time we really wanted to capture/see what's happening.
As you said 'log statements from journey script aren't captured and reported back' there's nothing that could be done about it. Despite that, are there any plans to include the log statements from journey script ?
As you said 'log statements from journey script aren't captured and reported back' there's nothing that could be done about it. Despite that, are there any plans to include the log statements from journey script ?
If you must have to collect the output back using the current version, there could be two ways (or say workarounds):
Create a webpage accessible in synthetics environment running the test, which accepts the data as URL Query string and print the data in its body. Generate the url when you have the data ready and as a separate journey step, visit that url. You can then use the step screenshot to view that data.
Use the request object in journey to post the data to some endpoint (example).
There are currently no requests or roadmap to collect log statements or custom data points back from journeys. As already suggested, do create an enhancement request. Also, in case you use the above, do mention in the enhancement request if it were useful.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.