kibana/x-pack/plugins/apm
2020-12-15 16:34:11 +01:00
..
.storybook Storybook 6 and config changes (#75357) 2020-09-29 19:34:05 -05:00
common License checks for alerts plugin (#85649) 2020-12-14 19:29:39 -08:00
dev_docs Fix dead links to functional testing docs (#85097) 2020-12-14 17:00:53 +01:00
e2e [APM] Makes service overview page default (#85786) 2020-12-14 18:31:34 -05:00
public removing margin for sparkline charts (#85917) 2020-12-15 16:34:11 +01:00
scripts [APM] Update ES archive used for API tests (#85286) 2020-12-08 22:46:41 +01:00
server [APM] Correlations polish (#85116) 2020-12-15 13:15:00 +01:00
typings [APM] Service overview: Dependencies table (#83416) 2020-12-10 10:32:01 +01:00
.prettierrc [APM] NP Migration - Moves plugin server files out of legacy (#57532) 2020-02-19 13:43:03 -08:00
CONTRIBUTING.md [APM] Client new platform migration (#64046) 2020-04-30 13:08:50 -07:00
jest.config.js [APM] Make sure jest script can be run from anywhere (#85111) 2020-12-08 07:55:24 +01:00
kibana.json Closes #79995 by adding new tab in transaction details to show related trace logs. (#85859) 2020-12-14 19:24:01 -05:00
readme.md [APM] Correlations UI POC (#82256) 2020-11-20 08:50:34 +01:00

Documentation for APM UI developers

Local environment setup

Kibana

git clone git@github.com:elastic/kibana.git
cd kibana/
yarn kbn bootstrap
yarn start --no-base-path

APM Server, Elasticsearch and data

To access an elasticsearch instance that has live data you have two options:

A. Connect to Elasticsearch on Cloud (internal devs only)

Find the credentials for the cluster here

B. Start Elastic Stack and APM data generators

git clone git@github.com:elastic/apm-integration-testing.git
cd apm-integration-testing/
./scripts/compose.py start master --all --no-kibana

Docker Compose is required

Testing

E2E (Cypress) tests

x-pack/plugins/apm/e2e/run-e2e.sh

Starts Kibana (:5701), APM Server (:8201) and Elasticsearch (:9201). Ingests sample data into Elasticsearch via APM Server and runs the Cypress tests

Unit testing

Note: Run the following commands from kibana/x-pack/plugins/apm.

Run unit tests

npx jest --watch

Update snapshots

npx jest --updateSnapshot

Coverage

HTML coverage report can be found in target/coverage/jest after tests have run.

open target/coverage/jest/index.html

Functional tests

Start server

node scripts/functional_tests_server --config x-pack/test/functional/config.js

Run tests

node scripts/functional_test_runner --config x-pack/test/functional/config.js --grep='APM specs'

APM tests are located in x-pack/test/functional/apps/apm. For debugging access Elasticsearch on http://localhost:9220` (elastic/changeme)

API integration tests

Our tests are separated in two suites: one suite runs with a basic license, and the other with a trial license (the equivalent of gold+). This requires separate test servers and test runners.

Basic

# Start server
node scripts/functional_tests_server --config x-pack/test/apm_api_integration/basic/config.ts

# Run tests
node scripts/functional_test_runner --config x-pack/test/apm_api_integration/basic/config.ts

The API tests for "basic" are located in x-pack/test/apm_api_integration/basic/tests.

Trial

# Start server
node scripts/functional_tests_server --config x-pack/test/apm_api_integration/trial/config.ts

# Run tests
node scripts/functional_test_runner --config x-pack/test/apm_api_integration/trial/config.ts

The API tests for "trial" are located in x-pack/test/apm_api_integration/trial/tests.

For debugging access Elasticsearch on http://localhost:9220` (elastic/changeme)

Linting

Note: Run the following commands from kibana/.

Typescript

yarn tsc --noEmit --project x-pack/tsconfig.json --skipLibCheck

Prettier

yarn prettier  "./x-pack/plugins/apm/**/*.{tsx,ts,js}" --write

ESLint

yarn eslint ./x-pack/plugins/apm --fix

Setup default APM users

APM behaves differently depending on which the role and permissions a logged in user has. For testing purposes APM uses 3 custom users:

apm_read_user: Apps: read. Indices: read (apm-*)

apm_write_user: Apps: read/write. Indices: read (apm-*)

kibana_write_user Apps: read/write. Indices: None

To create the users with the correct roles run the following script:

node x-pack/plugins/apm/scripts/setup-kibana-security.js --role-suffix <github-username-or-something-unique>

The users will be created with the password specified in kibana.dev.yml for elasticsearch.password

Debugging Elasticsearch queries

All APM api endpoints accept _debug=true as a query param that will result in the underlying ES query being outputted in the Kibana backend process.

Example: /api/apm/services/my_service?_debug=true

Storybook

Start the Storybook development environment with yarn storybook apm. All files with a .stories.tsx extension will be loaded. You can access the development environment at http://localhost:9001.

Experimental features settings

To set up a flagged feature, add the name of the feature key (apm:myFeature) to commmon/ui_settings_keys.ts and the feature parameters to server/ui_settings.ts.

Test for the feature like:

import { myFeatureEnabled } from '../ui_settings_keys';
if (core.uiSettings.get(myFeatureEnabled)) {
  doStuff();
}

Settings can be managed in Kibana under Stack Management > Advanced Settings > Observability.

Further resources