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

feat: introduce step level tracing #369

Merged
merged 4 commits into from Sep 7, 2021

Conversation

vigneshshanmugam
Copy link
Member

@vigneshshanmugam vigneshshanmugam commented Aug 27, 2021

  • fix Introduce step level tracing for perf metrics #358
  • Updates the lighthouse processor with new changes that accounts for different modes - navigation, snapshot etc
  • Trace computation has been updated to handle the navigation changes inside steps
  • Plugin manager is cleaned up to add support for step level and journey level plugins with new API such as register, unregister etc.
  • Each Plugin follows the same interface to keep things simpler in the PluginManager.
    • new Plugin(driver)
    • plugin.start
    • plugin.stop
  • JSON reporter now writes Metrics and Traces for each step if there is a navigation event of interest.

@apmmachine
Copy link
Collaborator

apmmachine commented Aug 27, 2021

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2021-08-31T22:16:00.197+0000

  • Duration: 14 min 59 sec

  • Commit: e60d18e

Test stats 🧪

Test Results
Failed 0
Passed 127
Skipped 0
Total 127

Trends 🧪

Image of Build Times

Image of Tests

@@ -625,4 +625,35 @@ describe('runner', () => {
const blobs = screenshotDocs.map(data => data.blob);
expect(blobs[0]).not.toEqual(blobs[1]);
});

it('run - capture trace step level', async () => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andrewvc @dominiqueclarke This test provides the complete picture.

Copy link
Contributor

@andrewvc andrewvc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great aside from cleaning up the licensing a bit

src/core/runner.ts Show resolved Hide resolved
src/core/runner.ts Outdated Show resolved Hide resolved
src/core/runner.ts Outdated Show resolved Hide resolved
src/plugins/network.ts Show resolved Hide resolved
this.writeMetrics(journey, step, 'experience', metrics);
if (filmstrips) {
// Write each filmstrip separately so that we don't get documents that are too large
filmstrips.forEach((strip, index) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this affect timing? I thought we saved it for the end on purpose so as not to affect journey timing as much

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We left it to the end to make sure to run the tracer only once per journey, but we are already running trace for each step anyway so there is no harm in also capturing filmstrips.

break;
case 'browserconsole':
instance = new BrowserConsole(this.driver.page);
instance.start();
instance = new BrowserConsole(this.driver);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason you changed the constructor parameters aside from consistency? Just wondering.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really, only to be consistent across all plugins. Makes things easier.

@@ -41,7 +41,7 @@ const supportedMetrics = new Set<string>([
'JSHeapTotalSize',
]);

export interface Metrics {
export interface PageMetrics {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What exactly is meant by Page in this context? Is it metrics for the playwright Page class, and thus metrics for that particular browser tab on a per step level?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its per browser tab which alias to Page in playwright context.

}

onStep(step: Step) {
this.get(BrowserConsole) && (this.get(BrowserConsole)._currentStep = step);
this.get(NetworkManager) && (this.get(NetworkManager)._currentStep = step);
(this.get('browserconsole') as BrowserConsole)._currentStep = step;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could create a setStep function that takes the plugin type and the step for reusability.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, But we don't want to call this for each plugin instead abstract away from runner and handle it in single place in PluginManger which handles the logic of assigning to respective plugins.

Copy link
Contributor

@andrewvc andrewvc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM Pending @dominiqueclarke +1

Copy link
Contributor

@dominiqueclarke dominiqueclarke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@vigneshshanmugam vigneshshanmugam merged commit e67a91d into elastic:master Sep 7, 2021
@vigneshshanmugam vigneshshanmugam deleted the step-tracing branch September 7, 2021 17:35
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

Successfully merging this pull request may close these issues.

Introduce step level tracing for perf metrics
4 participants