Skip to content

Emit summaries when synthetics exits without emitting journey/end [#30729]#30825

Merged
lucasfcosta merged 1 commit intoelastic:mainfrom
lucasfcosta:emit-summaries-without-journey-end
Mar 17, 2022
Merged

Emit summaries when synthetics exits without emitting journey/end [#30729]#30825
lucasfcosta merged 1 commit intoelastic:mainfrom
lucasfcosta:emit-summaries-without-journey-end

Conversation

@lucasfcosta
Copy link
Copy Markdown
Contributor

@lucasfcosta lucasfcosta commented Mar 15, 2022

What does this PR do?

This PR fixes #30729 by always emitting heartbeat/summary documents when a command exits without journey/end.

These documents have the following message:

journey did not finish executing, X steps ran

Why is it important?

Such a change will cause the Uptime UI to be able to display correct results even if a journey execution exits successfully but doesn't manage to write a journey/end event to the desired descriptor. Such a situation could happen when the synthetics runner buffer was full and wasn't emptied on time before the command's exit, as described in elastic/synthetics#446 and fixed in elastic/synthetics#465

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (Does not apply)
  • I have made corresponding change to the default configuration files (Does not apply)
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Author's Checklist

I've done so myself, but would like reviewers to verify the following:

  • Running journeys on the latest version of the synthetics runner works fine for journeys which emit journey/end
  • Running journeys on the latest version of the synthetics runner works fine for journeys which exit with status code > 0 and do not emit journey/end
  • Running journeys on the latest version of the synthetics runner works fine for journeys which exit with status code == 0 and emit journey/end

How to test this PR locally

To test this PR locally you must have a version of the synthetics runner which does not emit journey/end events once its finished. Then, you'll use that version to run a browser monitor and verify that the documents in Kibana do contain summaries with the following error message:

journey did not finish executing, X steps ran

  1. Update your local version of the synthetics package by removing these lines which are responsible for emitting journey/end events: https://github.com/elastic/synthetics/blob/e594196f4b083917fb7e44d67e208e1a87ea29a5/src/reporters/json.ts#L474-L484 (just comment them).
  2. Copy the journey below and run it locally using pbpaste | elastic-synthetics --screenshots off --inline --rich-events | jq .type
    step("no journey end", async () => { await page.goto("https://bbc.co.uk") });
    You should ensure that no journey/end is emitted when running this journey. You must verify that because when running heartbeat you want to simulate what would happen when journeys exit without emitting journey/end.
  3. Checkout this branch and build heartbeat.
  4. Run the heartbeat executable you just compiled with the following monitor:
    heartbeat.monitors:
    - type: browser
      id: test-no-end-emitted
      name: test-no-end-emitted
      schedule: '@every 1m'
      source:
        inline:
          script: |-
            step("no journey end", async () => {
              await page.goto('https://www.bbc.co.uk');
            });
    You can use ELASTIC_SYNTHETICS_CAPABLE=true ./heartbeat -c /tmp/heartbeat.yml -e -d "*" for that.
  5. Go to Kibana and ensure that there is a summary for this monitor which mentions it didn't run to completion.

Related issues

Screenshots

Screenshot 2022-03-15 at 12 17 35

@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Mar 15, 2022
@lucasfcosta lucasfcosta added the Team:obs-ds-hosted-services Label for the Observability Hosted Services team label Mar 15, 2022
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/uptime (Team:Uptime)

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Mar 15, 2022
@lucasfcosta lucasfcosta force-pushed the emit-summaries-without-journey-end branch from eec5349 to bcea7d8 Compare March 15, 2022 12:19
@elasticmachine
Copy link
Copy Markdown
Contributor

elasticmachine commented Mar 15, 2022

💚 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: 2022-03-16T20:32:37.031+0000

  • Duration: 37 min 30 sec

Test stats 🧪

Test Results
Failed 0
Passed 131
Skipped 0
Total 131

💚 Flaky test report

Tests succeeded.

🤖 GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • /package : Generate the packages and run the E2E tests.

  • /beats-tester : Run the installation tests with beats-tester.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

Copy link
Copy Markdown
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.

LTGM

Did the manual tests that are specified in the action for reviewers.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: we can remove this, step/start is not emitted by synthetics.

@lucasfcosta lucasfcosta force-pushed the emit-summaries-without-journey-end branch from bcea7d8 to 9f0a99a Compare March 16, 2022 20:32
@lucasfcosta lucasfcosta merged commit 912f804 into elastic:main Mar 17, 2022
@lucasfcosta lucasfcosta deleted the emit-summaries-without-journey-end branch March 17, 2022 09:48
@vigneshshanmugam vigneshshanmugam added backport-v8.1.0 Automated backport with mergify backport-v8.2.0 Automated backport with mergify labels Mar 17, 2022
mergify bot pushed a commit that referenced this pull request Mar 17, 2022
lucasfcosta pushed a commit that referenced this pull request Mar 21, 2022
…d events [#30729] (#30825) (#30898)

(cherry picked from commit 912f804)

Co-authored-by: Lucas F. da Costa <lucas.costa@elastic.co>
@lucasfcosta lucasfcosta added backport-7.17 Automated backport to the 7.17 branch with mergify and removed v7.17.1 labels Mar 22, 2022
mergify bot pushed a commit that referenced this pull request Mar 22, 2022
lucasfcosta pushed a commit that referenced this pull request Mar 22, 2022
…d events [#30729] (#30825) (#30960)

(cherry picked from commit 912f804)

Co-authored-by: Lucas F. da Costa <lucas.costa@elastic.co>
kush-elastic pushed a commit to kush-elastic/beats that referenced this pull request May 2, 2022
mergify bot pushed a commit that referenced this pull request Jun 15, 2022
…d events [#30729] (#30825)

(cherry picked from commit 912f804)

# Conflicts:
#	x-pack/heartbeat/monitors/browser/synthexec/enrich_test.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport backport-7.17 Automated backport to the 7.17 branch with mergify backport-v8.1.0 Automated backport with mergify backport-v8.2.0 Automated backport with mergify enhancement Team:obs-ds-hosted-services Label for the Observability Hosted Services team v8.1.0 v8.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Heartbeat: report summary event when synthetics doesn't emit end event

3 participants