Repository: elastic/synthetics (ts)

Issue:
remove unused fields from network information
+ We need a allowlist of fields that can be set as part of the `journey/network_info` event rather than creating the JSON with all the available fields from CDP. This would also avoid the max buffer limit that gets triggered and causes issues like #446 

+ Reason being it leads of explosion of data due to the field Subject Alternative Name list. A single request from [recaptcha.net](http://recaptcha.net/) has a SAN list of 500KiB of data

+ We need this as an interim solution until we get this PR back #372 and move to newer versions of PW. 



Pull request description:
fix: keep only necessary fields for network info
+ fix #466 
+ We use only the relevant fields that are shown on the UI and drop all the other fields that increases the size of the network document. example- `san_list` from certificates. 
+ Benchmarks with before/after this PR

```
Website - https://www.elastic.co
Before - 1795494 bytes
After - 1207272 bytes


Website - https://www.cnn.com/
Before - 2492815 bytes
After - 1895130 bytes

Website - recaptcha which has huge SAN list
Before - 1101419 bytes
After - 440826 bytes
```

Yields a savings of 60kB approx. for every synthetics test run.

Patch:
diff --git a/src/common_types.ts b/src/common_types.ts
index f17eb99..227139e 100644
--- a/src/common_types.ts
+++ b/src/common_types.ts
@@ -100,18 +100,60 @@ export type Screenshot = {
   data: string;
 };
 
+export type SecurityDetails = {
+  issuer?: string;
+  protocol?: string;
+  subjectName?: string;
+  validFrom?: number;
+  validTo?: number;
+};
+
+export type Request = {
+  method: string;
+  url: string;
+  headers: Record<string, string>;
+  // Total size in bytes of the request (body and headers)
+  bytes?: number;
+  body?: {
+    // Size in bytes of the request body
+    bytes: number;
+  };
+  referrer?: string;
+};
+
+export type Response = {
+  url?: string;
+  protocol?: string;
+  status: number;
+  statusText?: string;
+  mimeType: string;
+  httpVersion?: string;
+  headers: Record<string, string>;
+  // Total size in bytes of the response (body and headers)
+  bytes?: number;
+  body?: {
+    // Size in bytes of the response body
+    bytes: number;
+  };
+  transferSize?: number;
+  redirectURL?: string;
+  securityDetails?: SecurityDetails;
+  remoteIPAddress?: string;
+  remotePort?: number;
+  fromServiceWorker?: boolean;
+  timing?: Protocol.Network.ResourceTiming;
+};
+
 export type NetworkInfo = {
   url: string;
   browser: BrowserInfo;
-  method: string;
   type: string;
-  request: Protocol.Network.Request;
-  response?: Protocol.Network.Response;
+  request: Request;
+  response?: Response;
   isNavigationRequest: boolean;
   requestSentTime: number;
   loadEndTime: number;
   responseReceivedTime: number;
-  status: number;
   resourceSize: number;
   transferSize: number;
   timings?: {
diff --git a/src/plugins/network.ts b/src/plugins/network.ts
index 84f9fa3..dbe06af 100644
--- a/src/plugins/network.ts
+++ b/src/plugins/network.ts
@@ -64,14 +64,14 @@ export class NetworkManager {
   }
 
   _onRequestWillBeSent(event: Protocol.Network.requestWillBeSentPayload) {
-    const { requestId, request, timestamp, type, loaderId } = event;
-    const { url, method } = request;
+    const { url, method, postData, headers } = event.request;
     /**
      * Data URI should not show up as network requests
      */
     if (url.startsWith('data:')) {
       return;
     }
+    const { requestId, timestamp, type, loaderId } = event;
     const isNavigationRequest = requestId == loaderId && type === 'Document';
     const record = this._findNetworkRecord(requestId);
     /**
@@ -81,6 +81,7 @@ export class NetworkManager {
      */
     if (record) {
       if (event.redirectResponse) {
+        record.response.redirectURL = url;
         const response = event.redirectResponse;
         const data = Object.assign(event, {
           type: event.type,
@@ -117,15 +118,23 @@ export class NetworkManager {
       step: this._currentStep,
       timestamp: getTimestamp(),
       url,
-      request,
       type,
-      method,
-      requestSentTime: timestamp,
+      request: {
+        url,
+        method,
+        headers,
+        bytes: postData?.length || 0,
+      },
+      response: {
+        status: -1,
+        mimeType: 'x-unknown',
+        headers: {},
+        timing: null,
+      },
       isNavigationRequest,
-      status: 0,
-      loadEndTime: -1,
+      requestSentTime: timestamp,
       responseReceivedTime: -1,
-      response: null,
+      loadEndTime: -1,
       resourceSize: 0,
       transferSize: 0,
       timings: null,
@@ -147,6 +156,7 @@ export class NetworkManager {
       ...record.request.headers,
       ...headers,
     };
+    record.request.referrer = record.request.headers?.Referer;
   }
 
   _onDataReceived(event: Protocol.Network.dataReceivedPayload) {
@@ -165,12 +175,31 @@ export class NetworkManager {
     if (!record) {
       return;
     }
-    Object.assign(record, {
+
+    record.responseReceivedTime = timestamp;
+    record.transferSize = response.encodedDataLength;
+    record.response = {
+      url: response.url,
       status: response.status,
-      response,
-      responseReceivedTime: timestamp,
-      transferSize: response.encodedDataLength,
-    });
+      protocol: response.protocol,
+      statusText: response.statusText,
+      headers: response.headers,
+      mimeType: response.mimeType,
+      remoteIPAddress: response.remoteIPAddress,
+      remotePort: response.remotePort,
+      fromServiceWorker: response.fromServiceWorker,
+      redirectURL: record.response.redirectURL,
+      timing: response.timing,
+    };
+    if (response.securityDetails) {
+      record.response.securityDetails = {
+        protocol: response.securityDetails.protocol,
+        subjectName: response.securityDetails.subjectName,
+        issuer: response.securityDetails.issuer,
+        validFrom: response.securityDetails.validFrom,
+        validTo: response.securityDetails.validTo,
+      };
+    }
   }
 
   _onLoadingFinished(event: Protocol.Network.loadingFinishedPayload) {
@@ -194,6 +223,9 @@ export class NetworkManager {
     }
     if (encodedDataLength >= 0) {
       record.transferSize = encodedDataLength;
+      record.response.body = {
+        bytes: encodedDataLength,
+      };
     }
     record.loadEndTime = endTime;
     record.timings = calculateTimings(record);
@@ -250,17 +282,6 @@ export function calculateTimings(record: NetworkInfo) {
     receive: -1,
     total: -1,
   };
-  const { requestSentTime, loadEndTime, responseReceivedTime } = record;
-
-  /**
-   * Handle when request failed and no responseReceived event was
-   * fired for that particular request
-   * Eg: connection refused by remote host
-   */
-  const response = record.response || {
-    timing: null,
-    fromServiceWorker: false,
-  };
 
   const toMilliseconds = (time: number) => (time === -1 ? -1 : time * 1000);
   const calculateDiffInMs = (
@@ -293,6 +314,8 @@ export function calculateTimings(record: NetworkInfo) {
       calculateDiffInMs(name, startTime + start / 1000, startTime + end / 1000);
     }
   };
+  const { requestSentTime, loadEndTime, responseReceivedTime, response } =
+    record;
   const timing = response.timing;
   const actResRcvdTime = getResponseReceivedTime(timing, responseReceivedTime);
   const issueTime = requestSentTime;
diff --git a/src/reporters/json.ts b/src/reporters/json.ts
index c2a7d40..bcc9036 100644
--- a/src/reporters/json.ts
+++ b/src/reporters/json.ts
@@ -40,6 +40,7 @@ import { Journey, Step } from '../dsl';
 import snakeCaseKeys from 'snakecase-keys';
 import {
   NetworkInfo,
+  SecurityDetails,
   NetworkConditions,
   TraceOutput,
   StatusValue,
@@ -47,7 +48,6 @@ import {
   Params,
   Screenshot,
 } from '../common_types';
-import { Protocol } from 'playwright-chromium/types/protocol';
 import { PageMetrics } from '../plugins';
 
 /* eslint-disable @typescript-eslint/no-var-requires */
@@ -72,7 +72,7 @@ type Payload = {
   start?: number;
   end?: number;
   url?: string;
-  status?: StatusValue | number;
+  status?: StatusValue;
   pagemetrics?: PageMetrics;
   params?: Params;
   type?: OutputType;
@@ -94,7 +94,7 @@ type OutputFields = {
   };
   error?: Error;
   root_fields?: Record<string, unknown>;
-  payload?: Payload | NetworkInfo;
+  payload?: Payload;
   blob?: string;
   blob_mime?: string;
 };
@@ -143,41 +143,12 @@ function formatVersion(protocol: string | undefined) {
   }
 }
 
-function formatRequest(request: Protocol.Network.Request) {
-  const postData = request.postData ? request.postData : '';
-  return {
-    ...request,
-    body: {
-      bytes: postData.length,
-      content: postData,
-    },
-    referrer: request.headers?.Referer,
-  };
-}
-
-function formatResponse(response: Protocol.Network.Response) {
-  if (!response) {
-    return;
-  }
-  return {
-    ...response,
-    body: {
-      bytes: response.encodedDataLength,
-    },
-    status_code: response.status,
-  };
-}
-
-function formatTLS(tls: Protocol.Network.SecurityDetails) {
+function formatTLS(tls: SecurityDetails) {
   if (!tls) {
     return;
   }
-  const cipher = `${tls.keyExchange ? tls.keyExchange + '_' : ''}${
-    tls.cipher
-  }_${tls.keyExchangeGroup}`;
   const [name, version] = tls.protocol.toLowerCase().split(' ');
   return {
-    cipher,
     server: {
       x509: {
         issuer: {
@@ -191,7 +162,7 @@ function formatTLS(tls: Protocol.Network.SecurityDetails) {
       },
     },
     version_protocol: name,
-    version: version,
+    version,
   };
 }
 
@@ -207,16 +178,14 @@ export function formatNetworkFields(network: NetworkInfo) {
     },
     http: {
       version: formatVersion(response?.protocol),
-      request: formatRequest(request),
-      response: formatResponse(response),
+      request,
+      response,
     },
     tls: formatTLS(response?.securityDetails),
   };
 
   const pickItems: Array<keyof NetworkInfo> = [
     'browser',
-    'status',
-    'method',
     'type',
     'isNavigationRequest',
     'requestSentTime',


Test patch:
diff --git a/__tests__/fixtures/networkinfo.ts b/__tests__/fixtures/networkinfo.ts
index 778317b..6411d81 100644
--- a/__tests__/fixtures/networkinfo.ts
+++ b/__tests__/fixtures/networkinfo.ts
@@ -25,184 +25,126 @@
 
 import { NetworkInfo } from '../../src/common_types';
 
-export const NETWORK_INFO: Array<Partial<NetworkInfo>> = [
+export const NETWORK_INFO: Array<NetworkInfo> = [
   {
-    browser: { name: 'HeadlessChrome', version: '90.0.4392.0' },
-    step: {
-      name: 'go to app',
-      index: 1,
-    },
-    timestamp: 1612482095137858,
-    url: 'https://vigneshh.in/',
+    browser: { name: 'HeadlessChrome', version: '94.0.4595.0' },
+    step: null,
+    timestamp: 1646782451347652.5,
+    url: 'http://localhost:56899/index',
+    type: 'Document',
     request: {
-      url: 'https://vigneshh.in/',
+      url: 'http://localhost:56899/index',
       method: 'GET',
       headers: {
         'Upgrade-Insecure-Requests': '1',
         'User-Agent':
-          'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/90.0.4392.0 Safari/537.36',
-        ':method': 'GET',
-        ':path': '/',
-        'user-agent':
-          'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/90.0.4392.0 Safari/537.36',
-        'accept-encoding': 'gzip, deflate, br',
+          'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/94.0.4595.0 Safari/537.36 Elastic/Synthetics',
+        Host: 'localhost:56899',
+        Connection: 'keep-alive',
       },
-      mixedContentType: 'none',
-      initialPriority: 'VeryHigh',
-      referrerPolicy: 'strict-origin-when-cross-origin',
+      bytes: 0,
+      referrer: undefined,
     },
-    type: 'Document',
-    method: 'GET',
-    requestSentTime: 2355505.10179,
-    isNavigationRequest: true,
-    status: 200,
-    loadEndTime: 2355505.448326,
-    responseReceivedTime: 2355505.4514,
     response: {
-      url: 'https://vigneshh.in/',
-      headers: {},
+      url: 'http://localhost:56899/index',
       status: 200,
-      statusText: '',
+      protocol: 'http/1.1',
+      statusText: 'OK',
+      headers: {
+        'content-type': 'text/html',
+        Date: 'Tue, 08 Mar 2022 23:34:11 GMT',
+        Connection: 'keep-alive',
+        'Keep-Alive': 'timeout=5',
+        'Content-Length': '46',
+      },
       mimeType: 'text/html',
-      connectionReused: false,
-      connectionId: 12,
-      remoteIPAddress: '[2606:4700:3035::ac43:83e0]',
-      remotePort: 443,
-      fromDiskCache: false,
+      remoteIPAddress: '[::1]',
+      remotePort: 56899,
       fromServiceWorker: false,
-      fromPrefetchCache: false,
-      encodedDataLength: 3329,
-      responseTime: 1612482095476.922,
-      protocol: 'h2',
-      securityState: 'secure',
-      securityDetails: {
-        protocol: 'TLS 1.3',
-        keyExchange: '',
-        keyExchangeGroup: 'X25519',
-        cipher: 'AES_128_GCM',
-        certificateId: 0,
-        subjectName: 'sni.cloudflaressl.com',
-        sanList: [],
-        issuer: 'Cloudflare Inc ECC CA-3',
-        validFrom: 1595980800,
-        validTo: 1627560000,
-        signedCertificateTimestampList: [],
-        certificateTransparencyCompliance: 'unknown',
+      redirectURL: undefined,
+      timing: {
+        requestTime: 300869.367875,
+        proxyStart: -1,
+        proxyEnd: -1,
+        dnsStart: 0.25,
+        dnsEnd: 0.25,
+        connectStart: 0.25,
+        connectEnd: 0.5,
+        sslStart: -1,
+        sslEnd: -1,
+        workerStart: -1,
+        workerReady: -1,
+        workerFetchStart: -1,
+        workerRespondWithSettled: -1,
+        sendStart: 0.5,
+        sendEnd: 0.5,
+        pushStart: 0,
+        pushEnd: 0,
+        receiveHeadersEnd: 5.125,
       },
+      body: { bytes: 194 },
     },
-    transferSize: 3392,
-    resourceSize: 7634,
+    isNavigationRequest: true,
+    requestSentTime: 300869.36725,
+    responseReceivedTime: 300869.3735,
+    loadEndTime: 300869.373125,
+    resourceSize: 46,
+    transferSize: 194,
     timings: {
-      blocked: 2.080999780446291,
-      queueing: 2.145999576896429,
+      blocked: 0.24999998277053237,
+      queueing: 0.6249999860301614,
       proxy: -1,
-      dns: 45.81400007009506,
-      ssl: 61.003000009804964,
-      connect: 78.5130001604557,
-      send: 0.5449997261166573,
-      wait: 212.02100021764636,
-      receive: 3.9220000617206097,
-      total: 346.5359997935593,
+      dns: 0,
+      ssl: -1,
+      connect: 0.2500000409781933,
+      send: 0,
+      wait: 4.625000001396984,
+      receive: 0.12499996228143573,
+      total: 5.874999973457307,
     },
   },
   {
-    browser: { name: 'HeadlessChrome', version: '90.0.4392.0' },
-    step: {
-      name: 'go to app',
-      index: 1,
-    },
-    timestamp: 1612482095517516,
-    url: 'https://vigneshh.in/static/main.js',
+    browser: { name: 'HeadlessChrome', version: '94.0.4595.0' },
+    step: null,
+    timestamp: 1646782451408470,
+    url: 'http://localhost:56899/delay100',
+    type: 'Script',
     request: {
-      url: 'https://vigneshh.in/static/main.js',
+      url: 'http://localhost:56899/delay100',
       method: 'GET',
       headers: {
-        Referer: 'https://vigneshh.in/',
+        Referer: 'http://localhost:56899/index',
         'User-Agent':
-          'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/90.0.4392.0 Safari/537.36',
+          'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/94.0.4595.0 Safari/537.36 Elastic/Synthetics',
+        Host: 'localhost:56899',
+        Connection: 'keep-alive',
       },
-      mixedContentType: 'none',
-      initialPriority: 'Low',
-      referrerPolicy: 'strict-origin-when-cross-origin',
+      bytes: 0,
+      referrer: undefined,
     },
-    type: 'Script',
-    method: 'GET',
-    requestSentTime: 2355505.472502,
-    isNavigationRequest: false,
-    status: 200,
-    loadEndTime: 2355505.589043,
-    responseReceivedTime: 2355505.603987,
     response: {
-      url: 'https://vigneshh.in/static/main.js',
-      status: 200,
-      statusText: '',
+      status: -1,
+      mimeType: 'x-unknown',
       headers: {},
-      mimeType: 'application/javascript',
-      connectionReused: true,
-      connectionId: 12,
-      remoteIPAddress: '[2606:4700:3035::ac43:83e0]',
-      remotePort: 443,
-      fromDiskCache: false,
-      fromServiceWorker: false,
-      fromPrefetchCache: false,
-      encodedDataLength: 425,
-      responseTime: 1612482095622.864,
-      protocol: 'h2',
-      securityState: 'secure',
-      securityDetails: {
-        protocol: 'TLS 1.3',
-        keyExchange: '',
-        keyExchangeGroup: 'X25519',
-        cipher: 'AES_128_GCM',
-        certificateId: 0,
-        subjectName: 'sni.cloudflaressl.com',
-        sanList: [],
-        issuer: 'Cloudflare Inc ECC CA-3',
-        validFrom: 1595980800,
-        validTo: 1627560000,
-        signedCertificateTimestampList: [],
-        certificateTransparencyCompliance: 'unknown',
-      },
+      timing: null,
     },
+    isNavigationRequest: false,
+    requestSentTime: 300869.377,
+    responseReceivedTime: -1,
+    loadEndTime: 300869.45675,
+    resourceSize: 0,
+    transferSize: 0,
     timings: {
-      blocked: 1.058999914675951,
-      queueing: 46.335999853909016,
+      blocked: 79.75000003352761,
+      queueing: -1,
       proxy: -1,
       dns: -1,
       ssl: -1,
       connect: -1,
-      send: 0.2100002020597458,
-      wait: 68.73499974608421,
-      receive: 0.2009999006986618,
-      total: 116.54099961742759,
+      send: -1,
+      wait: -1,
+      receive: -1,
+      total: 79.75000003352761,
     },
   },
-  {
-    browser: { name: 'HeadlessChrome', version: '90.0.4392.0' },
-    timestamp: 1612482095713278,
-    url: 'https://www.google-analytics.com/',
-    request: {
-      url: 'https://www.google-analytics.com/',
-      method: 'POST',
-      headers: {
-        Referer: 'https://vigneshh.in/',
-        'User-Agent':
-          'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/90.0.4392.0 Safari/537.36',
-        'Content-Type': 'text/plain',
-      },
-      hasPostData: true,
-      mixedContentType: 'none',
-      initialPriority: 'High',
-      referrerPolicy: 'strict-origin-when-cross-origin',
-    },
-    type: 'XHR',
-    method: 'POST',
-    requestSentTime: 2355505.677688,
-    isNavigationRequest: false,
-    status: 0,
-    loadEndTime: -1,
-    responseReceivedTime: -1,
-    response: null,
-    timings: null,
-  },
 ];
diff --git a/__tests__/plugins/network.test.ts b/__tests__/plugins/network.test.ts
index 643ddf9..9d6fcff 100644
--- a/__tests__/plugins/network.test.ts
+++ b/__tests__/plugins/network.test.ts
@@ -55,9 +55,7 @@ describe('network', () => {
       request: expect.any(Object),
       response: expect.any(Object),
       type: 'Document',
-      method: 'GET',
       requestSentTime: expect.any(Number),
-      status: 200,
       loadEndTime: expect.any(Number),
       responseReceivedTime: expect.any(Number),
       timings: expect.any(Object),
@@ -90,9 +88,9 @@ describe('network', () => {
     await driver.page.goto(server.PREFIX + '/route1');
     const netinfo = await network.stop();
     expect(netinfo.length).toEqual(3);
-    expect(netinfo[0].status).toBe(302);
-    expect(netinfo[1].status).toBe(302);
-    expect(netinfo[2].status).toBe(200);
+    expect(netinfo[0].response.status).toBe(302);
+    expect(netinfo[1].response.status).toBe(302);
+    expect(netinfo[2].response.status).toBe(200);
     await Gatherer.stop();
   });
 
@@ -136,8 +134,12 @@ describe('network', () => {
     expect(netinfo.length).toBe(2);
     expect(netinfo[1]).toMatchObject({
       url: `${server.PREFIX}/delay100`,
-      status: 0,
-      response: null,
+      response: {
+        headers: {},
+        mimeType: 'x-unknown',
+        status: -1,
+        timing: null,
+      },
       timings: expect.any(Object),
     });
     expect(netinfo[1].timings.total).toBeGreaterThan(delayTime);
@@ -172,7 +174,6 @@ describe('network', () => {
     expect(netinfo.length).toBe(2);
     expect(netinfo[1]).toMatchObject({
       url: `${server.PREFIX}/chunked`,
-      status: 200,
       response: expect.any(Object),
       timings: expect.any(Object),
     });
diff --git a/__tests__/reporters/__snapshots__/json.test.ts.snap b/__tests__/reporters/__snapshots__/json.test.ts.snap
index db06edd..ddae101 100644
--- a/__tests__/reporters/__snapshots__/json.test.ts.snap
+++ b/__tests__/reporters/__snapshots__/json.test.ts.snap
@@ -10,111 +10,91 @@ Object {
   "ecs": Object {
     "http": Object {
       "request": Object {
-        "body": Object {
-          "bytes": 0,
-          "content": "",
-        },
+        "bytes": 0,
         "headers": Object {
-          "accept_encoding": "gzip, deflate, br",
-          "method": "GET",
-          "path": "/",
+          "connection": "keep-alive",
+          "host": "localhost:56899",
           "upgrade_insecure_requests": "1",
-          "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/90.0.4392.0 Safari/537.36",
+          "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/94.0.4595.0 Safari/537.36 Elastic/Synthetics",
         },
-        "initial_priority": "VeryHigh",
         "method": "GET",
-        "mixed_content_type": "none",
         "referrer": undefined,
-        "referrer_policy": "strict-origin-when-cross-origin",
-        "url": "https://vigneshh.in/",
+        "url": "http://localhost:56899/index",
       },
       "response": Object {
         "body": Object {
-          "bytes": 3329,
+          "bytes": 194,
         },
-        "connection_id": 12,
-        "connection_reused": false,
-        "encoded_data_length": 3329,
-        "from_disk_cache": false,
-        "from_prefetch_cache": false,
         "from_service_worker": false,
-        "headers": Object {},
-        "mime_type": "text/html",
-        "protocol": "h2",
-        "remote_i_p_address": "[2606:4700:3035::ac43:83e0]",
-        "remote_port": 443,
-        "response_time": 1612482095476.922,
-        "security_details": Object {
-          "certificate_id": 0,
-          "certificate_transparency_compliance": "unknown",
-          "cipher": "AES_128_GCM",
-          "issuer": "Cloudflare Inc ECC CA-3",
-          "key_exchange": "",
-          "key_exchange_group": "X25519",
-          "protocol": "TLS 1.3",
-          "san_list": Array [],
-          "signed_certificate_timestamp_list": Array [],
-          "subject_name": "sni.cloudflaressl.com",
-          "valid_from": 1595980800,
-          "valid_to": 1627560000,
+        "headers": Object {
+          "connection": "keep-alive",
+          "content_length": "46",
+          "content_type": "text/html",
+          "date": "Tue, 08 Mar 2022 23:34:11 GMT",
+          "keep_alive": "timeout=5",
         },
-        "security_state": "secure",
+        "mime_type": "text/html",
+        "protocol": "http/1.1",
+        "redirect_u_r_l": undefined,
+        "remote_i_p_address": "[::1]",
+        "remote_port": 56899,
         "status": 200,
-        "status_code": 200,
-        "status_text": "",
-        "url": "https://vigneshh.in/",
-      },
-      "version": 2,
-    },
-    "tls": Object {
-      "cipher": "AES_128_GCM_X25519",
-      "server": Object {
-        "x509": Object {
-          "issuer": Object {
-            "common_name": "Cloudflare Inc ECC CA-3",
-          },
-          "not_after": "2021-07-29T12:00:00.000Z",
-          "not_before": "2020-07-29T00:00:00.000Z",
-          "subject": Object {
-            "common_name": "sni.cloudflaressl.com",
-          },
+        "status_text": "OK",
+        "timing": Object {
+          "connect_end": 0.5,
+          "connect_start": 0.25,
+          "dns_end": 0.25,
+          "dns_start": 0.25,
+          "proxy_end": -1,
+          "proxy_start": -1,
+          "push_end": 0,
+          "push_start": 0,
+          "receive_headers_end": 5.125,
+          "request_time": 300869.367875,
+          "send_end": 0.5,
+          "send_start": 0.5,
+          "ssl_end": -1,
+          "ssl_start": -1,
+          "worker_fetch_start": -1,
+          "worker_ready": -1,
+          "worker_respond_with_settled": -1,
+          "worker_start": -1,
         },
+        "url": "http://localhost:56899/index",
       },
-      "version": "1.3",
-      "version_protocol": "tls",
+      "version": 1.1,
     },
-    "url": "https://vigneshh.in/",
+    "tls": undefined,
+    "url": "http://localhost:56899/index",
     "user_agent": Object {
       "name": "HeadlessChrome",
-      "original": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/90.0.4392.0 Safari/537.36",
-      "version": "90.0.4392.0",
+      "original": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/94.0.4595.0 Safari/537.36 Elastic/Synthetics",
+      "version": "94.0.4595.0",
     },
   },
   "payload": Object {
     "browser": Object {
       "name": "HeadlessChrome",
-      "version": "90.0.4392.0",
+      "version": "94.0.4595.0",
     },
     "is_navigation_request": true,
-    "load_end_time": 2355505.448326,
-    "method": "GET",
-    "request_sent_time": 2355505.10179,
-    "resource_size": 7634,
-    "response_received_time": 2355505.4514,
-    "status": 200,
+    "load_end_time": 300869.373125,
+    "request_sent_time": 300869.36725,
+    "resource_size": 46,
+    "response_received_time": 300869.3735,
     "timings": Object {
-      "blocked": 2.080999780446291,
-      "connect": 78.5130001604557,
-      "dns": 45.81400007009506,
+      "blocked": 0.24999998277053237,
+      "connect": 0.2500000409781933,
+      "dns": 0,
       "proxy": -1,
-      "queueing": 2.145999576896429,
-      "receive": 3.9220000617206097,
-      "send": 0.5449997261166573,
-      "ssl": 61.003000009804964,
-      "total": 346.5359997935593,
-      "wait": 212.02100021764636,
+      "queueing": 0.6249999860301614,
+      "receive": 0.12499996228143573,
+      "send": 0,
+      "ssl": -1,
+      "total": 5.874999973457307,
+      "wait": 4.625000001396984,
     },
-    "transfer_size": 3392,
+    "transfer_size": 194,
     "type": "Document",
   },
 }
@@ -125,157 +105,58 @@ Object {
   "ecs": Object {
     "http": Object {
       "request": Object {
-        "body": Object {
-          "bytes": 0,
-          "content": "",
-        },
+        "bytes": 0,
         "headers": Object {
-          "referer": "https://vigneshh.in/",
-          "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/90.0.4392.0 Safari/537.36",
+          "connection": "keep-alive",
+          "host": "localhost:56899",
+          "referer": "http://localhost:56899/index",
+          "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/94.0.4595.0 Safari/537.36 Elastic/Synthetics",
         },
-        "initial_priority": "Low",
         "method": "GET",
-        "mixed_content_type": "none",
-        "referrer": "https://vigneshh.in/",
-        "referrer_policy": "strict-origin-when-cross-origin",
-        "url": "https://vigneshh.in/static/main.js",
+        "referrer": undefined,
+        "url": "http://localhost:56899/delay100",
       },
       "response": Object {
-        "body": Object {
-          "bytes": 425,
-        },
-        "connection_id": 12,
-        "connection_reused": true,
-        "encoded_data_length": 425,
-        "from_disk_cache": false,
-        "from_prefetch_cache": false,
-        "from_service_worker": false,
         "headers": Object {},
-        "mime_type": "application/javascript",
-        "protocol": "h2",
-        "remote_i_p_address": "[2606:4700:3035::ac43:83e0]",
-        "remote_port": 443,
-        "response_time": 1612482095622.864,
-        "security_details": Object {
-          "certificate_id": 0,
-          "certificate_transparency_compliance": "unknown",
-          "cipher": "AES_128_GCM",
-          "issuer": "Cloudflare Inc ECC CA-3",
-          "key_exchange": "",
-          "key_exchange_group": "X25519",
-          "protocol": "TLS 1.3",
-          "san_list": Array [],
-          "signed_certificate_timestamp_list": Array [],
-          "subject_name": "sni.cloudflaressl.com",
-          "valid_from": 1595980800,
-          "valid_to": 1627560000,
-        },
-        "security_state": "secure",
-        "status": 200,
-        "status_code": 200,
-        "status_text": "",
-        "url": "https://vigneshh.in/static/main.js",
-      },
-      "version": 2,
-    },
-    "tls": Object {
-      "cipher": "AES_128_GCM_X25519",
-      "server": Object {
-        "x509": Object {
-          "issuer": Object {
-            "common_name": "Cloudflare Inc ECC CA-3",
-          },
-          "not_after": "2021-07-29T12:00:00.000Z",
-          "not_before": "2020-07-29T00:00:00.000Z",
-          "subject": Object {
-            "common_name": "sni.cloudflaressl.com",
-          },
-        },
+        "mime_type": "x-unknown",
+        "status": -1,
+        "timing": null,
       },
-      "version": "1.3",
-      "version_protocol": "tls",
+      "version": undefined,
     },
-    "url": "https://vigneshh.in/static/main.js",
+    "tls": undefined,
+    "url": "http://localhost:56899/delay100",
     "user_agent": Object {
       "name": "HeadlessChrome",
-      "original": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/90.0.4392.0 Safari/537.36",
-      "version": "90.0.4392.0",
+      "original": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/94.0.4595.0 Safari/537.36 Elastic/Synthetics",
+      "version": "94.0.4595.0",
     },
   },
   "payload": Object {
     "browser": Object {
       "name": "HeadlessChrome",
-      "version": "90.0.4392.0",
+      "version": "94.0.4595.0",
     },
-    "load_end_time": 2355505.589043,
-    "method": "GET",
-    "request_sent_time": 2355505.472502,
-    "response_received_time": 2355505.603987,
-    "status": 200,
+    "load_end_time": 300869.45675,
+    "request_sent_time": 300869.377,
+    "response_received_time": -1,
     "timings": Object {
-      "blocked": 1.058999914675951,
+      "blocked": 79.75000003352761,
       "connect": -1,
       "dns": -1,
       "proxy": -1,
-      "queueing": 46.335999853909016,
-      "receive": 0.2009999006986618,
-      "send": 0.2100002020597458,
+      "queueing": -1,
+      "receive": -1,
+      "send": -1,
       "ssl": -1,
-      "total": 116.54099961742759,
-      "wait": 68.73499974608421,
+      "total": 79.75000003352761,
+      "wait": -1,
     },
     "type": "Script",
   },
 }
 `;
 
-exports[`json reporter formats network fields in ECS format 3`] = `
-Object {
-  "ecs": Object {
-    "http": Object {
-      "request": Object {
-        "body": Object {
-          "bytes": 0,
-          "content": "",
-        },
-        "has_post_data": true,
-        "headers": Object {
-          "content_type": "text/plain",
-          "referer": "https://vigneshh.in/",
-          "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/90.0.4392.0 Safari/537.36",
-        },
-        "initial_priority": "High",
-        "method": "POST",
-        "mixed_content_type": "none",
-        "referrer": "https://vigneshh.in/",
-        "referrer_policy": "strict-origin-when-cross-origin",
-        "url": "https://www.google-analytics.com/",
-      },
-      "response": undefined,
-      "version": undefined,
-    },
-    "tls": undefined,
-    "url": "https://www.google-analytics.com/",
-    "user_agent": Object {
-      "name": "HeadlessChrome",
-      "original": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/90.0.4392.0 Safari/537.36",
-      "version": "90.0.4392.0",
-    },
-  },
-  "payload": Object {
-    "browser": Object {
-      "name": "HeadlessChrome",
-      "version": "90.0.4392.0",
-    },
-    "load_end_time": -1,
-    "method": "POST",
-    "request_sent_time": 2355505.677688,
-    "response_received_time": -1,
-    "type": "XHR",
-  },
-}
-`;
-
 exports[`json reporter screenshots write block & reference docs 1`] = `
 "{\\"type\\":\\"screenshot/block\\",\\"_id\\":\\"e89af7cc2cae152df54ccf091793db64b3dfe995\\",\\"@timestamp\\":1600300800000000,\\"root_fields\\":{\\"os\\":{\\"platform\\":\\"darwin\\"},\\"package\\":{\\"name\\":\\"@elastic/synthetics\\",\\"version\\":\\"0.0.1\\"}},\\"blob\\":\\"/9j/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCABaAKADASIAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAj/xAAUEAEAAAAAAAAAAAAAAAAAAAAA/8QAFAEBAAAAAAAAAAAAAAAAAAAAAP/EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAMAwEAAhEDEQA/AKcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB//9k=\\",\\"blob_mime\\":\\"image/jpeg\\",\\"package_version\\":\\"0.0.1\\"}
 {\\"type\\":\\"screenshot/block\\",\\"_id\\":\\"e89af7cc2cae152df54ccf091793db64b3dfe995\\",\\"@timestamp\\":1600300800000000,\\"root_fields\\":{\\"os\\":{\\"platform\\":\\"darwin\\"},\\"package\\":{\\"name\\":\\"@elastic/synthetics\\",\\"version\\":\\"0.0.1\\"}},\\"blob\\":\\"/9j/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCABaAKADASIAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAj/xAAUEAEAAAAAAAAAAAAAAAAAAAAA/8QAFAEBAAAAAAAAAAAAAAAAAAAAAP/EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAMAwEAAhEDEQA/AKcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB//9k=\\",\\"blob_mime\\":\\"image/jpeg\\",\\"package_version\\":\\"0.0.1\\"}
@@ -355,7 +236,7 @@ exports[`json reporter writes each step as NDJSON to the FD 1`] = `
 {\\"type\\":\\"step/metrics\\",\\"@timestamp\\":1600300800000000,\\"journey\\":{\\"name\\":\\"j1\\",\\"id\\":\\"j1\\"},\\"step\\":{\\"name\\":\\"s1\\",\\"index\\":1},\\"root_fields\\":{\\"browser\\":{\\"experience\\":{\\"lcp\\":{\\"us\\":200},\\"fcp\\":{\\"us\\":100},\\"dcl\\":{\\"us\\":300},\\"load\\":{\\"us\\":400},\\"cls\\":0.123}},\\"os\\":{\\"platform\\":\\"darwin\\"},\\"package\\":{\\"name\\":\\"@elastic/synthetics\\",\\"version\\":\\"0.0.1\\"}},\\"package_version\\":\\"0.0.1\\"}
 {\\"type\\":\\"step/filmstrips\\",\\"@timestamp\\":1600300800000000,\\"journey\\":{\\"name\\":\\"j1\\",\\"id\\":\\"j1\\"},\\"step\\":{\\"name\\":\\"s1\\",\\"index\\":1},\\"root_fields\\":{\\"browser\\":{\\"relative_trace\\":{\\"start\\":{\\"us\\":392583998697}}},\\"os\\":{\\"platform\\":\\"darwin\\"},\\"package\\":{\\"name\\":\\"@elastic/synthetics\\",\\"version\\":\\"0.0.1\\"}},\\"payload\\":{\\"index\\":0},\\"blob\\":\\"dummy\\",\\"blob_mime\\":\\"image/jpeg\\",\\"package_version\\":\\"0.0.1\\"}
 {\\"type\\":\\"step/end\\",\\"@timestamp\\":1600300800000000,\\"journey\\":{\\"name\\":\\"j1\\",\\"id\\":\\"j1\\"},\\"step\\":{\\"name\\":\\"s1\\",\\"index\\":1,\\"status\\":\\"succeeded\\",\\"duration\\":{\\"us\\":10000000}},\\"root_fields\\":{\\"os\\":{\\"platform\\":\\"darwin\\"},\\"package\\":{\\"name\\":\\"@elastic/synthetics\\",\\"version\\":\\"0.0.1\\"}},\\"payload\\":{\\"source\\":\\"() => { }\\",\\"url\\":\\"dummy\\",\\"status\\":\\"succeeded\\"},\\"url\\":\\"dummy\\",\\"package_version\\":\\"0.0.1\\"}
-{\\"type\\":\\"journey/network_info\\",\\"@timestamp\\":1600300800000000,\\"journey\\":{\\"name\\":\\"j1\\",\\"id\\":\\"j1\\"},\\"root_fields\\":{\\"user_agent\\":{},\\"http\\":{\\"request\\":{\\"body\\":{\\"bytes\\":0,\\"content\\":\\"\\"}}},\\"os\\":{\\"platform\\":\\"darwin\\"},\\"package\\":{\\"name\\":\\"@elastic/synthetics\\",\\"version\\":\\"0.0.1\\"}},\\"payload\\":{\\"browser\\":{},\\"is_navigation_request\\":true},\\"package_version\\":\\"0.0.1\\"}
+{\\"type\\":\\"journey/network_info\\",\\"@timestamp\\":1600300800000000,\\"journey\\":{\\"name\\":\\"j1\\",\\"id\\":\\"j1\\"},\\"root_fields\\":{\\"user_agent\\":{},\\"http\\":{\\"request\\":{}},\\"os\\":{\\"platform\\":\\"darwin\\"},\\"package\\":{\\"name\\":\\"@elastic/synthetics\\",\\"version\\":\\"0.0.1\\"}},\\"payload\\":{\\"browser\\":{},\\"is_navigation_request\\":true},\\"package_version\\":\\"0.0.1\\"}
 {\\"type\\":\\"journey/browserconsole\\",\\"@timestamp\\":1600300800000000,\\"journey\\":{\\"name\\":\\"j1\\",\\"id\\":\\"j1\\"},\\"step\\":{\\"name\\":\\"step-name\\",\\"index\\":0},\\"root_fields\\":{\\"os\\":{\\"platform\\":\\"darwin\\"},\\"package\\":{\\"name\\":\\"@elastic/synthetics\\",\\"version\\":\\"0.0.1\\"}},\\"payload\\":{\\"text\\":\\"Boom\\",\\"type\\":\\"error\\"},\\"error\\":{\\"name\\":\\"Error\\",\\"message\\":\\"boom\\",\\"stack\\":\\"\\"},\\"package_version\\":\\"0.0.1\\"}
 {\\"type\\":\\"journey/end\\",\\"@timestamp\\":1600300800000000,\\"journey\\":{\\"name\\":\\"j1\\",\\"id\\":\\"j1\\",\\"status\\":\\"succeeded\\"},\\"root_fields\\":{\\"os\\":{\\"platform\\":\\"darwin\\"},\\"package\\":{\\"name\\":\\"@elastic/synthetics\\",\\"version\\":\\"0.0.1\\"}},\\"payload\\":{\\"start\\":0,\\"end\\":11,\\"status\\":\\"succeeded\\"},\\"package_version\\":\\"0.0.1\\"}
 "