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

[Heartbeat] Dedupe screenshots / Extra Args #25808

Merged
merged 22 commits into from
Jun 8, 2021
Merged

Conversation

andrewvc
Copy link
Contributor

@andrewvc andrewvc commented May 20, 2021

Counterpart of elastic/synthetics#282
Fixes: #26188

Adds support for screenshot blocks as mentioned in the synthetics PR, and also switches over to using the new flags / capabilities system. This is done by using --rich-events by default as a synthetics flag, and also exposing a new synthetics_args option for synthetics, allowing users to use configs like:

- type: browser
  enabled: true
  id: my-monitor
  name: My Monitor
  synthetics_args: ["--capability", "trace", "metrics", "filmstrips", "ssblocks"]
  source:
    inline:
      script:
        step("load homepage", async () => {
            await page.goto('https://www.elastic.co');
        });
        step("hover over products menu", async () => {
            await page.hover('css=[data-nav-item=products]');
        });
        step("failme", async () => {
            await page.hhover('css=[data-nav-item=products]');
        });
  schedule: "@every 1m"

This PR also moves some of the logic from browser.go to suite.go, which was also renamed to be cleaner and more in keeping with idiomatic go. This also made adding a small test possible. We still need a better story around E2E testing, but for now this will suffice.

Finally, this adds mappings for screenshot_ref objects as well as blocks, and routes them to the correct dataset. It also improves tests for enrichment of events to help test this.

@andrewvc andrewvc added the Team:obs-ds-hosted-services Label for the Observability Hosted Services team label May 20, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/uptime (Team:Uptime)

@botelastic botelastic bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels May 20, 2021
@elasticmachine
Copy link
Collaborator

elasticmachine commented May 20, 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

Expand to view the summary

Build stats

  • Build Cause: Pull request #25808 updated

  • Start Time: 2021-06-08T02:22:32.702+0000

  • Duration: 78 min 2 sec

  • Commit: 452c53a

Test stats 🧪

Test Results
Failed 0
Passed 3359
Skipped 82
Total 3441

Trends 🧪

Image of Build Times

Image of Tests

💚 Flaky test report

Tests succeeded.

Expand to view the summary

Test stats 🧪

Test Results
Failed 0
Passed 3359
Skipped 82
Total 3441

Copy link
Member

@vigneshshanmugam vigneshshanmugam left a comment

Choose a reason for hiding this comment

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

LGTM, tested and it works as expected.

We might need to change one more thing to get it merged. adding step/block to the screenshot datastream index.

@andrewvc andrewvc requested a review from a team as a code owner May 27, 2021 02:43
@andrewvc andrewvc changed the title POC for dedupe of screenshots Dedupe screenshots May 27, 2021
@andrewvc
Copy link
Contributor Author

PR now adds mapping and properly routes to correct dataset. Still needs tests

@mergify
Copy link
Contributor

mergify bot commented Jun 1, 2021

This pull request is now in conflicts. Could you fix it? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b dedupe upstream/dedupe
git merge upstream/master
git push upstream dedupe

@andrewvc andrewvc changed the title Dedupe screenshots [Heartbeat] Dedupe screenshots Jun 4, 2021
- name: blocks
type: group
fields:
- name: hash
Copy link
Member

Choose a reason for hiding this comment

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

Need to add top and left here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch!

Copy link
Member

Choose a reason for hiding this comment

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

I don't see the top & left yet in the new changes.

fields:
- name: width
type: integer
description: Width of the full screenshot in pixels.
Copy link
Member

Choose a reason for hiding this comment

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

Shall we remove the use of full here? Full seems like full page screenshot but we are capture only the viewport width and height.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmmm, I intended it to mean not of an individual block. I'll clarify that.

@@ -108,23 +109,31 @@ func runCmd(
return nil, err
}

// Default capabilities
capabilities = append(capabilities, "trace", "metrics", "filmstrips", "ssblocks")
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure if its the right way to do it.

I was thinking we should make it configurable by introducing Capability flag in the config.go in addition to params and then using it here for experimentation.

moving forward once the feature is built in to the UI, we can add it to --rich-events in synthetics.

WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I see what you mean. That makes sense, will make those changes!

@mergify
Copy link
Contributor

mergify bot commented Jun 7, 2021

This pull request is now in conflicts. Could you fix it? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b dedupe upstream/dedupe
git merge upstream/master
git push upstream dedupe

@andrewvc andrewvc changed the title [Heartbeat] Dedupe screenshots [Heartbeat] Dedupe screenshots / Extra Args Jun 7, 2021
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

package browser
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This file isn't new, it's just moved. Enough of it changed due to renaming the ss var to s that git thinks it's all new.

@andrewvc andrewvc self-assigned this Jun 7, 2021
Copy link
Member

@vigneshshanmugam vigneshshanmugam left a comment

Choose a reason for hiding this comment

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

LGTM after the top and left changes.

CHANGELOG.next.asciidoc Outdated Show resolved Hide resolved
- name: blocks
type: group
fields:
- name: hash
Copy link
Member

Choose a reason for hiding this comment

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

I don't see the top & left yet in the new changes.

},
{
"kitchen sink",
&Config{SyntheticsArgs: []string{"--capability", "trace"}, Sandbox: true},
Copy link
Member

Choose a reason for hiding this comment

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

I am curios to see a test with capability > 2 and other flags as part of synthetic args. Reason being variadic args are prone to errors.

andrewvc and others added 2 commits June 7, 2021 17:49
Co-authored-by: Vignesh Shanmugam <vignesh.shanmugam22@gmail.com>
@andrewvc
Copy link
Contributor Author

andrewvc commented Jun 7, 2021

@vigneshshanmugam I believe I've addressed your concerns. I left out top and left on the mapping intentionally. We'll probably never query them, so it makes sense to save a field. I've added some notes to the fields yml indicating why this is.

@vigneshshanmugam
Copy link
Member

@andrewvc Spot on, Sounds good to me ++.

@andrewvc andrewvc merged commit db6738e into elastic:master Jun 8, 2021
@andrewvc
Copy link
Contributor Author

andrewvc commented Jun 8, 2021

@Mergifyio backport 7.x

mergify bot pushed a commit that referenced this pull request Jun 8, 2021
(cherry picked from commit db6738e)

# Conflicts:
#	heartbeat/_meta/fields.common.yml
#	heartbeat/docs/fields.asciidoc
#	heartbeat/include/fields.go
#	x-pack/heartbeat/include/fields.go
@mergify
Copy link
Contributor

mergify bot commented Jun 8, 2021

Command backport 7.x: success

Backports have been created

@mergify
Copy link
Contributor

mergify bot commented Jun 8, 2021

Command backport 7.14: failure

No backport have been created

  • Backport to branch 7.14 failed: Branch not found

andrewvc added a commit that referenced this pull request Jun 8, 2021
* [Heartbeat] Dedupe screenshots / Extra Args (#25808)

(cherry picked from commit db6738e)

# Conflicts:
#	heartbeat/_meta/fields.common.yml
#	heartbeat/docs/fields.asciidoc
#	heartbeat/include/fields.go
#	x-pack/heartbeat/include/fields.go

* Fix merge

* Update fields docs

Co-authored-by: Andrew Cholakian <andrew@andrewvc.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Heartbeat Team:obs-ds-hosted-services Label for the Observability Hosted Services team v7.14.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Heartbeat] Support de-duped screenshots
3 participants