Repository: elastic/synthetics
Pull request #315 (2021-06-21 23:02:36)

chore: use duration.us for trace events
+ As a result of changes here - https://github.com/elastic/beats/pull/26248

apmmachine: 
## :grey_exclamation: Build Aborted
  
  > Either there was a build timeout or someone aborted the build.'}
  


<!-- BUILD BADGES-->
> _the below badges are clickable and redirect to their specific view in the CI or DOCS_
[![Pipeline View](https://img.shields.io/badge/pipeline-pipeline%20-green)](https://apm-ci.elastic.co/blue/organizations/jenkins/apm-agent-rum%2Felastic-synthetics%2FPR-315/detail/PR-315/1//pipeline) [![Test View](https://img.shields.io/badge/test-test-green)](https://apm-ci.elastic.co/blue/organizations/jenkins/apm-agent-rum%2Felastic-synthetics%2FPR-315/detail/PR-315/1//tests) [![Changes](https://img.shields.io/badge/changes-changes-green)](https://apm-ci.elastic.co/blue/organizations/jenkins/apm-agent-rum%2Felastic-synthetics%2FPR-315/detail/PR-315/1//changes) [![Artifacts](https://img.shields.io/badge/artifacts-artifacts-yellow)](https://apm-ci.elastic.co/blue/organizations/jenkins/apm-agent-rum%2Felastic-synthetics%2FPR-315/detail/PR-315/1//artifacts) 

<!-- BUILD SUMMARY-->
<details><summary>Expand to view the summary</summary>
<p>

#### Build stats


* Build Cause: `Pull request #315 opened`



* Start Time: 2021-06-21T23:02:49.735+0000


* Duration: 27 min 54 sec


* Commit: 638bdcde70c494c80a670cde7844ca76506f2349



#### Test stats :test_tube:

| Test         | Results                         |
| ------------ | :-----------------------------: |
| Failed       | 0  |
| Passed       | 109  |
| Skipped      | 0 |
| Total        | 109   |


#### Trends :test_tube:


![Image of Build Times](https://apm-ci.elastic.co/job/apm-agent-rum/job/elastic-synthetics/job/PR-315/buildTimeGraph/png)


![Image of Tests](https://apm-ci.elastic.co/job/apm-agent-rum/job/elastic-synthetics/job/PR-315/1/testReport/history/countGraph/png?start=0&amp;end=25)


</p>
</details>

<!-- TEST RESULTS IF ANY-->


<!-- STEPS ERRORS IF ANY -->











<!-- LOG OUTPUT-->
### Log output

<details><summary>Expand to view the last 100 lines of log output</summary>
<p>

```
[2021-06-21T23:11:59.181Z] Cleaning workspace
[2021-06-21T23:11:59.238Z]  > git --version # timeout=10
[2021-06-21T23:11:59.241Z]  > git --version # 'git version 2.17.1'
[2021-06-21T23:11:59.246Z] fatal: bad object bbed8ab717206e63fa6cc1cef7d35f4a13f717ab
[2021-06-21T23:11:59.184Z]  > git rev-parse --verify HEAD # timeout=10
[2021-06-21T23:11:59.189Z] Resetting working tree
[2021-06-21T23:11:59.189Z]  > git reset --hard # timeout=10
[2021-06-21T23:11:59.204Z]  > git clean -fdx # timeout=10
[2021-06-21T23:12:02.212Z] Running in /var/lib/jenkins/workspace/nt-rum_elastic-synthetics_PR-315/src/github.com/elastic/synthetics
[2021-06-21T23:12:16.861Z] + set +x
[2021-06-21T23:12:16.861Z] => Downloading nvm from git to '/var/lib/jenkins/workspace/nt-rum_elastic-synthetics_PR-315/.nvm'
[2021-06-21T23:12:16.861Z] => Initialized empty Git repository in /var/lib/jenkins/workspace/nt-rum_elastic-synthetics_PR-315/.nvm/.git/
[2021-06-21T23:12:17.435Z] From https://github.com/nvm-sh/nvm
[2021-06-21T23:12:17.435Z]  * [new tag]         v0.37.1    -> v0.37.1
[2021-06-21T23:12:17.435Z] => Compressing and cleaning up git repository
[2021-06-21T23:12:17.435Z] 
[2021-06-21T23:12:17.435Z] => Profile not found. Tried ~/.bashrc, ~/.bash_profile, ~/.zshrc, and ~/.profile.
[2021-06-21T23:12:17.435Z] => Create one of them and run this script again
[2021-06-21T23:12:17.435Z]    OR
[2021-06-21T23:12:17.435Z] => Append the following lines to the correct file yourself:
[2021-06-21T23:12:17.435Z] 
[2021-06-21T23:12:17.435Z] export NVM_DIR="$HOME/.nvm"
[2021-06-21T23:12:17.435Z] [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[2021-06-21T23:12:17.435Z] 
[2021-06-21T23:12:19.343Z] => Close and reopen your terminal to start using nvm or run the following to use it now:
[2021-06-21T23:12:19.343Z] 
[2021-06-21T23:12:19.343Z] export NVM_DIR="$HOME/.nvm"
[2021-06-21T23:12:19.343Z] [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[2021-06-21T23:12:19.343Z] Installing latest LTS version.
[2021-06-21T23:12:19.603Z] v14.17.1 is already installed.
[2021-06-21T23:12:19.862Z] Now using node v14.17.1 (npm v6.14.13)
[2021-06-21T23:12:19.971Z] Running in /var/lib/jenkins/workspace/nt-rum_elastic-synthetics_PR-315/src/github.com/elastic/synthetics
[2021-06-21T23:12:20.287Z] + chmod -R ugo+rw examples
[2021-06-21T23:12:20.312Z] Running in /var/lib/jenkins/workspace/nt-rum_elastic-synthetics_PR-315/src/github.com/elastic/synthetics/__tests__/e2e
[2021-06-21T23:12:20.628Z] + npm run test
[2021-06-21T23:12:20.628Z] 
[2021-06-21T23:12:20.628Z] > e2e-synthetics@ test /var/lib/jenkins/workspace/nt-rum_elastic-synthetics_PR-315/src/github.com/elastic/synthetics/__tests__/e2e
[2021-06-21T23:12:20.628Z] > npm i && npm run setup &&  bash scripts/test.sh
[2021-06-21T23:12:20.628Z] 
[2021-06-21T23:12:23.920Z] added 3 packages from 4 contributors and audited 178 packages in 2.643s
[2021-06-21T23:12:26.459Z] 
[2021-06-21T23:12:26.459Z] 66 packages are looking for funding
[2021-06-21T23:12:26.459Z]   run `npm fund` for details
[2021-06-21T23:12:26.459Z] 
[2021-06-21T23:12:26.459Z] found 1 moderate severity vulnerability
[2021-06-21T23:12:26.459Z]   run `npm audit fix` to fix them, or `npm audit` for details
[2021-06-21T23:12:26.459Z] 
[2021-06-21T23:12:26.459Z] > e2e-synthetics@ setup /var/lib/jenkins/workspace/nt-rum_elastic-synthetics_PR-315/src/github.com/elastic/synthetics/__tests__/e2e
[2021-06-21T23:12:26.459Z] > bash scripts/setup.sh
[2021-06-21T23:12:26.459Z] 
[2021-06-21T23:12:26.459Z] 
[2021-06-21T23:12:26.459Z] Temporary folder
[2021-06-21T23:12:26.459Z] Temporary files will be stored in: ./tmp
[2021-06-21T23:12:26.459Z] 
[2021-06-21T23:12:26.459Z] Starting elasticsearch , kibana and synthetics docker
[2021-06-21T23:12:26.459Z] 
[2021-06-21T23:12:26.459Z] 
[2021-06-21T23:12:26.459Z] Waiting for synthetics docker to start...
[2021-06-21T23:12:26.459Z] Error: No such object: synthetics
[2021-06-21T23:12:38.677Z] Error: No such object: synthetics
[2021-06-21T23:12:46.803Z] Error: No such object: synthetics
[2021-06-21T23:12:56.790Z] Error: No such object: synthetics
[2021-06-21T23:13:06.800Z] Error: No such object: synthetics
[2021-06-21T23:13:19.019Z] Error: No such object: synthetics
[2021-06-21T23:13:27.152Z] Error: No such object: synthetics
[2021-06-21T23:13:37.140Z] Error: No such object: synthetics
[2021-06-21T23:13:47.136Z] Error: No such object: synthetics
[2021-06-21T23:13:59.357Z] Error: No such object: synthetics
[2021-06-21T23:14:07.512Z] ✅ Setup completed successfully. Running e2e tests...
[2021-06-21T23:14:08.906Z] Waiting for Elastic Search  to start
[2021-06-21T23:14:47.765Z] Waiting for Synthetics to send data to ES for test monitor
[2021-06-21T23:29:24.420Z] Cancelling nested steps due to timeout
[2021-06-21T23:29:24.426Z] Sending interrupt signal to process
[2021-06-21T23:29:40.078Z] scripts/test.sh: line 26:  5207 Terminated              SYNTHETICS_JUNIT_FILE='junit.xml' npx @elastic/synthetics uptime.journey.ts --reporter junit
[2021-06-21T23:29:40.078Z] npm ERR! code ELIFECYCLE
[2021-06-21T23:29:40.078Z] npm ERR! errno 143
[2021-06-21T23:29:40.078Z] npm ERR! e2e-synthetics@ test: `npm i && npm run setup &&  bash scripts/test.sh`
[2021-06-21T23:29:40.078Z] npm ERR! Exit status 143
[2021-06-21T23:29:40.078Z] npm ERR! 
[2021-06-21T23:29:40.078Z] npm ERR! Failed at the e2e-synthetics@ test script.
[2021-06-21T23:29:40.078Z] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
[2021-06-21T23:29:40.078Z] 
[2021-06-21T23:29:40.078Z] npm ERR! A complete log of this run can be found in:
[2021-06-21T23:29:40.078Z] npm ERR!     /var/lib/jenkins/workspace/nt-rum_elastic-synthetics_PR-315/.npm/_logs/2021-06-21T23_29_29_882Z-debug.log
[2021-06-21T23:29:40.084Z] script returned exit code 143
[2021-06-21T23:29:41.351Z] Post stage
[2021-06-21T23:29:41.386Z] Archiving artifacts
[2021-06-21T23:29:41.551Z] Recording test results
[2021-06-21T23:29:41.678Z] None of the test reports contained any result
[2021-06-21T23:29:41.686Z] [Checks API] No suitable checks publisher found.
[2021-06-21T23:29:41.934Z] Stage "Release" skipped due to earlier failure(s)
[2021-06-21T23:29:41.970Z] Stage "Release" skipped due to earlier failure(s)
[2021-06-21T23:29:42.052Z] Stage "Release" skipped due to earlier failure(s)
[2021-06-21T23:29:42.724Z] Running on Jenkins in /var/lib/jenkins/workspace/nt-rum_elastic-synthetics_PR-315
[2021-06-21T23:29:42.805Z] [INFO] getVaultSecret: Getting secrets
[2021-06-21T23:29:42.853Z] Masking supported pattern matches of $VAULT_ADDR or $VAULT_ROLE_ID or $VAULT_SECRET_ID
[2021-06-21T23:29:44.004Z] + chmod 755 generate-build-data.sh
[2021-06-21T23:29:44.004Z] + ./generate-build-data.sh https://apm-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/apm-agent-rum/elastic-synthetics/PR-315/ https://apm-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/apm-agent-rum/elastic-synthetics/PR-315/runs/1 ABORTED 1614000
[2021-06-21T23:29:44.005Z] INFO: curl https://apm-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/apm-agent-rum/elastic-synthetics/PR-315/runs/1/steps/?limit=10000 -o steps-info.json
[2021-06-21T23:29:44.005Z] INFO: curl https://apm-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/apm-agent-rum/elastic-synthetics/PR-315/runs/1/tests/?status=FAILED -o tests-errors.json

```

</p>
</details>



<!--COMMENT_GENERATED_WITH_ID_comment.id-->

Patch:
diff --git a/src/common_types.ts b/src/common_types.ts
index 7641596..2417d76 100644
--- a/src/common_types.ts
+++ b/src/common_types.ts
@@ -41,7 +41,7 @@ export type TraceOutput = {
   name: string;
   type: string;
   start: MetricDuration;
-  end?: MetricDuration;
+  duration?: MetricDuration;
   score?: number;
 };
 
diff --git a/src/sdk/trace-metrics.ts b/src/sdk/trace-metrics.ts
index 373d128..4778622 100644
--- a/src/sdk/trace-metrics.ts
+++ b/src/sdk/trace-metrics.ts
@@ -72,8 +72,8 @@ export class UserTimings {
           start: {
             us: startTime,
           },
-          end: {
-            us: ts,
+          duration: {
+            us: ts - startTime,
           },
         });
       }


Test patch:
diff --git a/__tests__/sdk/trace-metrics.test.ts b/__tests__/sdk/trace-metrics.test.ts
index 2d3e601..4abdd23 100644
--- a/__tests__/sdk/trace-metrics.test.ts
+++ b/__tests__/sdk/trace-metrics.test.ts
@@ -41,8 +41,8 @@ describe('Trace metrics', () => {
     expect(metrics).toMatchInlineSnapshot(`
       Array [
         Object {
-          "end": Object {
-            "us": 3069485988748,
+          "duration": Object {
+            "us": 1212635,
           },
           "name": "Next.js-before-hydration",
           "start": Object {