[kbn-journeys] add synthtrace support (#178599)

## Summary

Moving synthtrace clients init inside kbn-journeys:

esArchiver does not always solve the issue with data generation. We
already have afew journeys using Synthtrace instead and expect more to
come.

In order to simplify the process of creating new journeys, this PR moves
Synthtrace client initialisation into kbn-journey package and exposes a
way to define client type, generator function & its input arguments:

 ```
import { Journey, SynthtraceOptions } from '@kbn/journeys';
import { subj } from '@kbn/test-subj-selector';
import { generateApmData } from '../synthtrace_data/apm_data';

export const journey = new Journey({
  synthtrace: {
    type: 'apm',
    generator: generateApmData,
    options: {
      from: new Date(Date.now() - 1000 * 60 * 15),
      to: new Date(Date.now() + 1000 * 60 * 15),
    },
  },
})
```

PR also needs review from teams who use Synthtrace to understand if the implementation is matching expectations.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Dzmitry Lemechko 2024-03-19 00:42:45 +01:00 committed by GitHub
parent 45dbfae666
commit aa45c2aee3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 297 additions and 171 deletions

View file

@ -8,6 +8,7 @@ tags: ['kibana', 'onboarding', 'setup', 'performance', 'development']
---
## Overview
In order to achieve our goal of creating best user experience in Kibana, it is important to keep track on its features performance.
To make things easier, we introduced performance journeys, that mimics end-user experience with Kibana.
@ -19,6 +20,7 @@ Journeys core is [kbn-journeys](packages/kbn-journeys/README.mdx) package. It is
by [Playwright](https://playwright.dev/) end-to-end testing tool.
### Adding a new performance journey
Let's assume we instrumented dashboard with load time metrics and want to track sample data flights dashboard performance.
Journey supports loading test data with esArchiver or kbnArchiver. Similar to functional tests, it might require to implement custom wait
for UI rendering to be completed.
@ -42,18 +44,36 @@ export const journey = new Journey({
});
```
Alternative to archives is to use Synthtrace ES client:
```
export const journey = new Journey({
synthtrace: {
type: 'apm',
generator: generateApmData,
options: {
from: new Date(Date.now() - 1000 * 60 * 15),
to: new Date(Date.now() + 1000 * 60 * 15),
},
},
})
```
In oder to get correct and consistent metrics, it is important to design journey properly:
- use archives to generate test data
- use archives or synthtrace to generate test data
- decouple complex scenarios into multiple simple journeys
- use waiting for page loading / UI component rendering
- test locally and check if journey is stable.
- make sure performance metrics are collected on every run.
### Running performance journey locally for troubleshooting purposes
Use the Node script:
`node scripts/run_performance.js --journey-path x-pack/performance/journeys_e2e/$YOUR_JOURNEY_NAME.ts`
`node scripts/run_performance.js --journey-path x-pack/performance/journeys_e2e/$YOUR_JOURNEY_NAME.ts`
Scripts steps include:
- start Elasticsearch
- start Kibana and run journey first time (warmup) only APM metrics being reported
- start Kibana and run journey second time (test): both EBT and APM metrics being reported
@ -65,6 +85,7 @@ Since the tests are run on a local machine, there is also realistic throttling a
simulate real life internet connection. This means that all requests have a fixed latency and limited bandwidth.
### Benchmarking performance on CI
In order to keep track on performance metrics stability, journeys are run on main branch with a scheduled interval.
Bare metal machine is used to produce results as stable and reproducible as possible.
@ -77,9 +98,8 @@ RAM: 128 GB
SSD: 1.92 TB Data center Gen4 NVMe
#### Track performance results
APM metrics are reported to [kibana-ops-e2e-perf](https://kibana-ops-e2e-perf.kb.us-central1.gcp.cloud.es.io/) cluster.
You can filter transactions using labels, e.g. `labels.journeyName : "flight_dashboard"`
Custom metrics reported with EBT are available in [Telemetry Staging](https://telemetry-v2-staging.elastic.dev/) cluster, `kibana-performance` space.