5 |
--------------------------------------------------------------------------------
/packages/rum-core/test/run-apm-server.sh:
--------------------------------------------------------------------------------
1 | ELASTICSEARCH_PORT=9201 STACK_VERSION=6.4.0 APM_SERVER_PORT=8001 docker-compose up apm-server kibana
2 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | Release notes are now available in our documentation at ([elastic.co](https://www.elastic.co/guide/en/apm/agent/rum-js/current/release-notes.html))
--------------------------------------------------------------------------------
/packages/rum/test/benchmarks/pages/basic.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 | <% include head %>
4 |
5 | <% include init %>
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.ci/jobs/apm-agent-rum-mbp.yml:
--------------------------------------------------------------------------------
1 | ---
2 | - job:
3 | name: apm-agent-rum/apm-agent-rum-mbp
4 | display-name: APM Agent RUM
5 | description: Elastic APM Real User Monitoring (RUM) JavaScript agent
6 |
--------------------------------------------------------------------------------
/packages/rum/test/benchmarks/pages/init.ejs:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/packages/rum/test/benchmarks/pages/heavy.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 | <% include head %>
4 |
5 | <% for(var i=0; i < images.length; i++) { %>
6 |
7 | <% } %> <% include init %>
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | .config
3 | .npm
4 | .DS_Store
5 |
6 | *.e2e-bundle.*
7 | *-e2e.html
8 |
9 | dist
10 | tmp
11 |
12 | error-screenshot
13 |
14 | html_docs
15 | build
16 | reports
17 | coverage
18 |
19 | # ignore lerna-debug and npm-debug logs
20 | *debug.log
21 |
--------------------------------------------------------------------------------
/docs/redirects.asciidoc:
--------------------------------------------------------------------------------
1 | ["appendix",role="exclude",id="redirects"]
2 | = Deleted pages
3 |
4 | The following pages have moved or been deleted.
5 |
6 | [role="exclude",id="apm-set-tags"]
7 | === `apm.setTags()`
8 |
9 | This page has moved. Please see <> instead.
10 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # editorconfig.org
2 | root = true
3 |
4 | [*]
5 | indent_style = space
6 | indent_size = 2
7 | end_of_line = lf
8 | charset = utf-8
9 | trim_trailing_whitespace = true
10 | insert_final_newline = true
11 |
12 | [*.{md,asciidoc}]
13 | trim_trailing_whitespace = false
14 | insert_final_newline = false
15 |
--------------------------------------------------------------------------------
/.ci/scripts/benchmarks.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | USER_ID="$(id -u):$(id -g)" \
3 | NODEJS_VERSION=$(cat ./dev-utils/.node-version) \
4 | docker-compose -f ./dev-utils/docker-compose.yml up \
5 | --build \
6 | --abort-on-container-exit \
7 | --exit-code-from node-benchmark \
8 | --remove-orphans \
9 | node-benchmark
10 |
--------------------------------------------------------------------------------
/packages/rum-angular/test/e2e/with-router/data.json:
--------------------------------------------------------------------------------
1 | [
2 | { "id": 1, "name": "Contact 1", "email": "contact1@email.com" },
3 | { "id": 2, "name": "Contact 2", "email": "contact2@email.com" },
4 | { "id": 3, "name": "Contact 3", "email": "contact3@email.com" },
5 | { "id": 4, "name": "Contact 4", "email": "contact4@email.com" }
6 | ]
7 |
--------------------------------------------------------------------------------
/packages/rum/test/e2e/bundle-test/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Bundle test
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.ci/scripts/index.html.template:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Real User Monitoring - Elastic
5 |
6 |
7 | VERSION
8 |
9 |
10 | For further details see this guide.
11 |
12 |
13 |
--------------------------------------------------------------------------------
/docs/framework-integrations.asciidoc:
--------------------------------------------------------------------------------
1 | [[framework-integrations]]
2 | == Framework-specific integrations
3 |
4 | * <>
5 | * <>
6 | * <>
7 |
8 | include::./react-integration.asciidoc[React Integration]
9 | include::./angular-integration.asciidoc[Angular Integration]
10 | include::./vue-integration.asciidoc[Vue Integration]
--------------------------------------------------------------------------------
/packages/rum/test/types/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es6",
4 | "module": "commonjs",
5 | "noEmit": true,
6 | "noImplicitAny": true,
7 | "noImplicitThis": true,
8 | "strictNullChecks": true,
9 | "strictFunctionTypes": true,
10 | "allowJs": true,
11 | "checkJs": true,
12 | "strict": true,
13 | "esModuleInterop": true
14 | },
15 | "include": ["*.ts"]
16 | }
17 |
--------------------------------------------------------------------------------
/packages/rum-vue/test/e2e/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Vue E2E test
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/packages/rum/test/benchmarks/pages/head.ejs:
--------------------------------------------------------------------------------
1 |
2 | Elastic APM RUM agent Benchmarks
3 |
4 |
5 |
6 |
11 |
12 |
--------------------------------------------------------------------------------
/.ci/scripts/test.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | set -xueo pipefail
3 |
4 | pip install docker-compose>=1.25.4
5 |
6 | USER_ID="$(id -u):$(id -g)" \
7 | NODEJS_VERSION=$(cat ./dev-utils/.node-version) \
8 | docker-compose \
9 | -f ./dev-utils/docker-compose.yml \
10 | --log-level INFO \
11 | up \
12 | --quiet-pull \
13 | --exit-code-from node-puppeteer \
14 | --remove-orphans \
15 | node-puppeteer
16 | echo "Exit code from docker-compose $?"
17 |
--------------------------------------------------------------------------------
/packages/rum-react/test/e2e/with-router/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | React test
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/packages/rum-react/test/e2e/with-router/switch.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | React test
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/dev-utils/apm-server-dev/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM golang:1.10.3
2 |
3 | ARG APM_SERVER_BRANCH
4 | ARG APM_SERVER_REPO
5 |
6 | RUN apt-get update \
7 | && apt-get install -y wget git --no-install-recommends \
8 | && apt-get install -y virtualenv
9 |
10 | RUN git clone -b $APM_SERVER_BRANCH --single-branch https://github.com/$APM_SERVER_REPO.git --depth 1 ${GOPATH}/src/github.com/elastic/apm-server
11 |
12 | WORKDIR ${GOPATH}/src/github.com/elastic/apm-server
13 |
14 | RUN make
15 | RUN make update
--------------------------------------------------------------------------------
/packages/rum/test/e2e/manual-timing/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Manual Timing test
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/packages/rum-angular/test/e2e/with-router/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | RUM Angular e2e test
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/.ci/docker/node-puppeteer/run-test.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | cat <Environment Vars
5 |
6 | USER=$(id)
7 | GOAL=${GOAL}
8 | MODE=${MODE}
9 | SCOPE=${SCOPE}
10 | STACK_VERSION=${STACK_VERSION}
11 | NODE_VERSION=${NODE_VERSION}
12 | YARN_VERSION=${YARN_VERSION}
13 |
14 | >Installed tools
15 |
16 | NODE=$(node --version)
17 | NPM=$(npm --version)
18 | NPX=$(npx --version)
19 | EOF
20 |
21 | cd /app
22 | npm install
23 | npm install puppeteer --unsafe-perm=true --allow-root
24 | set -eo pipefail
25 | npm run ${GOAL}
26 |
--------------------------------------------------------------------------------
/docs/release-notes.asciidoc:
--------------------------------------------------------------------------------
1 | :pull: https://github.com/elastic/apm-agent-rum-js/pull/
2 | :issue: https://github.com/elastic/apm-agent-rum-js/issues/
3 | :commit: https://github.com/elastic/apm-agent-rum-js/commit/
4 |
5 | [[release-notes]]
6 | == Release notes
7 |
8 | All notable changes to this project will be documented here.
9 |
10 | * <>
11 | * <>
12 | * <>
13 | * <>
14 | * <>
15 | * <>
16 |
17 | include::../CHANGELOG.asciidoc[]
--------------------------------------------------------------------------------
/packages/rum-angular/README.md:
--------------------------------------------------------------------------------
1 | Elastic APM Real User Monitoring for Angular applications
2 |
3 | This package provides Real User Monitoring (RUM) for Angular applications.
4 |
5 | ## Documentation
6 | You can find our documentation [on our website](https://www.elastic.co/guide/en/apm/agent/rum-js/current/index.html).
7 |
8 | If you are interested in contributing to Elastic APM JavaScript agent, please see [our contributing guide](CONTRIBUTING.md).
9 |
10 |
11 | ## License
12 | This project is [MIT licensed](LICENSE).
13 |
14 | Made with ♥️ and ☕️ by Elastic and our community.
--------------------------------------------------------------------------------
/packages/rum-react/README.md:
--------------------------------------------------------------------------------
1 | # Elastic APM Real User Monitoring (RUM) for React applications
2 |
3 | This package provides Real User Monitoring (RUM) for React applications.
4 |
5 | ## Documentation
6 | You can find our documentation [on our website](https://www.elastic.co/guide/en/apm/agent/rum-js/current/index.html).
7 |
8 | If you are interested in contributing to Elastic APM JavaScript agent, please see [our contributing guide](CONTRIBUTING.md).
9 |
10 |
11 | ## License
12 | This project is [MIT licensed](LICENSE).
13 |
14 | Made with ♥️ and ☕️ by Elastic and our community.
--------------------------------------------------------------------------------
/lerna.json:
--------------------------------------------------------------------------------
1 | {
2 | "packages": [
3 | "packages/*"
4 | ],
5 | "version": "independent",
6 | "registry": "https://registry.npmjs.org",
7 | "command": {
8 | "version": {
9 | "allowBranch": ["master", "4.x"],
10 | "conventionalCommits": true,
11 | "message": "chore(release): publish",
12 | "gitRemote": "upstream",
13 | "loglevel": "verbose"
14 | },
15 | "run": {
16 | "stream": true
17 | },
18 | "publish": {
19 | "loglevel": "verbose"
20 | }
21 | },
22 | "ignoreChanges": [
23 | "**/*.md",
24 | "**/test/**",
25 | "docs"
26 | ]
27 | }
28 |
--------------------------------------------------------------------------------
/codecov.yml:
--------------------------------------------------------------------------------
1 | codecov:
2 | notify:
3 | require_ci_to_pass: no
4 | comment:
5 | layout: "header, changes, diff, files"
6 | behavior: default
7 | coverage:
8 | status:
9 | project:
10 | default:
11 | target: 80%
12 | threshold: 1
13 | if_not_found: success # if parent is not found report status as success, error, or failure
14 | if_ci_failed: error # if ci fails report status as success, error, or failure
15 | base: parent # will always use the parent commit to compare against.
16 | patch: off #https://docs.codecov.io/docs/commit-status#section-patch-status
17 |
--------------------------------------------------------------------------------
/.ci/packer_cache.sh:
--------------------------------------------------------------------------------
1 | # shellcheck disable=SC1091
2 | source /usr/local/bin/bash_standard_lib.sh
3 |
4 | readonly NODEJS_VERSION="$(cat ./dev-utils/.node-version)"
5 |
6 | FLAVOURS="playwright
7 | puppeteer"
8 |
9 | if [ -x "$(command -v docker)" ]; then
10 | for flavour in ${FLAVOURS}
11 | do
12 | di="docker.elastic.co/observability-ci/node-${flavour}:${NODEJS_VERSION}"
13 | (retry 2 docker pull "${di}") || echo "Error pulling ${di} Docker image, we continue"
14 | docker build --build-arg NODEJS_VERSION="${NODEJS_VERSION}" -t "${di}" .ci/docker/node-"${flavour}" || echo "Error building ${flavour} Docker image, we continue"
15 | done
16 | fi
17 |
--------------------------------------------------------------------------------
/packages/rum-vue/README.md:
--------------------------------------------------------------------------------
1 | # Elastic APM Real User Monitoring (RUM) for Vue applications
2 |
3 | This package provides Real User Monitoring (RUM) for Vue applications.
4 |
5 | ### Installation
6 |
7 | ```
8 | npm install @elastic/apm-rum-vue
9 | ```
10 |
11 | ## Documentation
12 | You can find our documentation [on our website](https://www.elastic.co/guide/en/apm/agent/rum-js/current/index.html).
13 |
14 | If you are interested in contributing to Elastic APM JavaScript agent, please see [our contributing guide](CONTRIBUTING.md).
15 |
16 |
17 | ## License
18 | This project is [MIT licensed](LICENSE).
19 |
20 | Made with ♥️ and ☕️ by Elastic and our community.
21 | ```
22 |
--------------------------------------------------------------------------------
/packages/rum/README.md:
--------------------------------------------------------------------------------
1 | # Elastic APM Real User Monitoring (RUM) JavaScript agent
2 |
3 | This is the main package for Elastic APM Real User Monitoring.
4 |
5 | ## Documentation
6 | You can find our documentation [on our website](https://www.elastic.co/guide/en/apm/agent/rum-js/current/index.html).
7 |
8 | If you are interested in contributing to Elastic APM JavaScript agent, please see [our contributing guide](CONTRIBUTING.md).
9 |
10 | We'd love to hear your feedback, please take a minute to fill out our [survey](https://goo.gl/forms/nLCXGCvziqalzjlP2).
11 |
12 |
13 | ## License
14 | This project is [MIT licensed](LICENSE).
15 |
16 | Made with ♥️ and ☕️ by Elastic and our community.
--------------------------------------------------------------------------------
/packages/rum/test/run-apm-server.sh:
--------------------------------------------------------------------------------
1 | #docker run -p 127.0.0.1:8200:8201 elastic/apm-server:6.2.4 /bin/sh -c "apm-server -e -E output.elasticsearch.password=$(ELASTICSEARCH_PASSWORD) -E output.elasticsearch.username=$(ELASTICSEARCH_USERNAME) -E output.elasticsearch.hosts=['$(ELASTICSEARCH_SERVICE_HOST):$(ELASTICSEARCH_SERVICE_PORT)'] -E apm-server.expvar.enabled=true -E apm-server.frontend.enabled=true -E apm-server.frontend.rate_limit=100000 -E apm-server.host=0.0.0.0:8200 -E apm-server.read_timeout=1m -E apm-server.shutdown_timeout=2m -E apm-server.write_timeout=1m"
2 | STACK_VERSION=6.2.4 APM_SERVER_PORT=8001 docker-compose up apm-server
3 | #STACK_VERSION=6.2.4 docker-compose -f ./test/docker-compose.yml start apm-server
--------------------------------------------------------------------------------
/packages/rum/test/e2e/standalone-html/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | test
5 |
6 |
7 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/packages/rum/test/e2e/standalone-html/opentracing.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | test
5 |
6 |
7 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/scripts/build_docs.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -e
4 |
5 | name=$1
6 | path=$2
7 | build_dir=$3
8 |
9 | docs_dir=$build_dir/docs
10 | html_dir=$build_dir/html_docs
11 |
12 | # Checks if docs clone already exists
13 | if [ ! -d $docs_dir ]; then
14 | # Only head is cloned
15 | git clone --depth=1 https://github.com/elastic/docs.git $docs_dir
16 | else
17 | echo "$docs_dir already exists. Not cloning."
18 | fi
19 |
20 |
21 | index="${path}/index.asciidoc"
22 |
23 | echo "Building docs for ${name}..."
24 | echo "Index document: ${index}"
25 |
26 | dest_dir="$html_dir/${name}"
27 | mkdir -p "$dest_dir"
28 | params="--chunk=1"
29 | if [ "$PREVIEW" = "1" ]; then
30 | params="$params --open"
31 | fi
32 | $docs_dir/build_docs $params --doc "$index" --out "$dest_dir"
33 |
--------------------------------------------------------------------------------
/packages/rum-core/README.md:
--------------------------------------------------------------------------------
1 | # Elastic APM JavaScript core (for development)
2 |
3 | This is the core JavaScript module for Elastic APM.
4 |
5 | **Only use this package if you want to implement an integration for a framework that Elastic APM does not support yet.**
6 |
7 | ## Documentation
8 | You can find our documentation [on our website](https://www.elastic.co/guide/en/apm/agent/rum-js/current/index.html).
9 |
10 | If you are interested in contributing to Elastic APM JavaScript agent, please see [our contributing guide](CONTRIBUTING.md).
11 |
12 | We'd love to hear your feedback, please take a minute to fill out our [survey](https://goo.gl/forms/nLCXGCvziqalzjlP2).
13 |
14 | ## License
15 | This project is [MIT licensed](LICENSE).
16 |
17 | Made with ♥️ and ☕️ by Elastic and our community.
18 |
--------------------------------------------------------------------------------
/packages/rum/test/e2e/general-usecase/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | General Usecase test
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/.ci/scripts/pull_and_build.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | export NODEJS_VERSION=$(cat ./dev-utils/.node-version)
3 |
4 | docker-compose -f ./dev-utils/docker-compose.yml --log-level INFO pull --quiet --ignore-pull-failures
5 |
6 | # We are building the images here even though the Docker images are already cached in Packer.
7 | # This is because there could be changes in the PR affecting the files copied to the Docker image,
8 | # which we want to test in the current build.
9 | NODEJS_VERSION=${NODEJS_VERSION} docker-compose -f ./dev-utils/docker-compose.yml --log-level INFO build >docker-compose.log 2>docker-compose.err
10 | if [ $? -gt 0 ] ; then
11 | echo "Docker compose failed, see the below log output"
12 | cat docker-compose.log && rm docker-compose.log
13 | cat docker-compose.err && rm docker-compose.err
14 | exit 1
15 | else
16 | rm docker-compose.log docker-compose.err
17 | fi
18 |
--------------------------------------------------------------------------------
/.devcontainer/Dockerfile:
--------------------------------------------------------------------------------
1 | # See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.158.0/containers/javascript-node/.devcontainer/base.Dockerfile
2 |
3 | # [Choice] Node.js version: 14, 12, 10
4 | ARG VARIANT="14-buster"
5 | FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-${VARIANT}
6 |
7 | # [Optional] Uncomment this section to install additional OS packages.
8 | # RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
9 | # && apt-get -y install --no-install-recommends
10 |
11 | # [Optional] Uncomment if you want to install an additional version of node using nvm
12 | # ARG EXTRA_NODE_VERSION=10
13 | # RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}"
14 |
15 | # [Optional] Uncomment if you want to install more global node modules
16 | # RUN su node -c "npm install -g "
17 |
--------------------------------------------------------------------------------
/scripts/lint-commits.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | set -xeo pipefail
3 |
4 | # Run if we're not on Jenkins
5 | if [[ -n "${JENKINS_URL}" ]]; then
6 | export PATH=$(npm bin):${PATH}
7 | export HOME=$(pwd)
8 | if [[ -z "${CHANGE_ID}" ]]; then
9 | # If on master, just test the latest commit
10 | commitlint --from="${GIT_SHA}~1"
11 | else
12 | # If on a branch, test all commits between this branch and master
13 | commitlint --from="origin/${CHANGE_TARGET}" --to="${GIT_BASE_COMMIT}"
14 |
15 | # Lint PR title
16 | if [[ -n ${CHANGE_TITLE} ]]; then
17 | titleLength=$(echo -n "${CHANGE_TITLE}" | wc -c)
18 | titleResult=0
19 | if [ "${titleLength}" -ge 65 ] ; then
20 | echo "PR title has a long comment. This will fail when squashing and merging the Pull Request"
21 | titleResult=1
22 | fi
23 | echo "${CHANGE_TITLE}" | commitlint
24 | exit ${titleResult}
25 | fi
26 | fi
27 | fi
28 |
--------------------------------------------------------------------------------
/docs/index.asciidoc:
--------------------------------------------------------------------------------
1 | include::{asciidoc-dir}/../../shared/versions/stack/current.asciidoc[]
2 | include::{asciidoc-dir}/../../shared/attributes.asciidoc[]
3 |
4 | ifdef::env-github[]
5 | NOTE: For the best reading experience,
6 | please view this documentation at https://www.elastic.co/guide/en/apm/agent/rum-js[elastic.co]
7 | endif::[]
8 |
9 | = APM Real User Monitoring JavaScript Agent Reference
10 |
11 | include::./intro.asciidoc[]
12 |
13 | include::./supported-technologies.asciidoc[]
14 |
15 | include::./configuration.asciidoc[]
16 |
17 | include::./api.asciidoc[]
18 |
19 | include::./sourcemap.asciidoc[]
20 |
21 | include::./framework-integrations.asciidoc[]
22 |
23 | include::./distributed-tracing-guide.asciidoc[]
24 |
25 | include::./breakdown-metrics.asciidoc[]
26 |
27 | include::./opentracing.asciidoc[]
28 |
29 | include::./advanced-topics.asciidoc[]
30 |
31 | include::./performance-tuning.asciidoc[]
32 |
33 | include::./troubleshooting.asciidoc[]
34 |
35 | include::./upgrading.asciidoc[]
36 |
37 | include::./release-notes.asciidoc[]
38 |
--------------------------------------------------------------------------------
/docs/api.asciidoc:
--------------------------------------------------------------------------------
1 | [[api]]
2 | == API Reference
3 |
4 | The API reference documentation is divided into three parts:
5 |
6 | * <> - All functions and properties on the `Agent` object.
7 | An instance of the `Agent` object is acquired by calling the `init method` the agent either via script element on the page or require the `elastic-apm-rum` module in Node.js.
8 | The `Agent` instance is usually referred to by the variable `apm` in this documentation.
9 |
10 | * <> - All functions and properties on the `Transaction` object.
11 | An instance of the `Transaction` object is acquired by calling `apm.startTransaction()`.
12 |
13 | * <> - All functions and properties on the `Span` object.
14 | An instance of the `Span` object is acquired by calling `apm.startSpan()`.
15 |
16 | include::./agent-api.asciidoc[Agent API documentation]
17 |
18 | include::./transaction-api.asciidoc[Transaction API documentation]
19 |
20 | include::./span-api.asciidoc[Span API documentation]
21 |
22 |
--------------------------------------------------------------------------------
/packages/rum-vue/test/e2e/components/Fetch.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
Loading...
4 |
5 | {{ error }}
6 |
7 |
8 |
{{ data.msg }}
9 |
10 |
11 |
12 |
13 |
49 |
--------------------------------------------------------------------------------
/.devcontainer/devcontainer.json:
--------------------------------------------------------------------------------
1 | // For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2 | // https://github.com/microsoft/vscode-dev-containers/tree/v0.158.0/containers/javascript-node
3 | {
4 | "name": "Node.js",
5 | "build": {
6 | "dockerfile": "Dockerfile",
7 | // Update 'VARIANT' to pick a Node version: 10, 12, 14
8 | "args": { "VARIANT": "14" }
9 | },
10 |
11 | // Set *default* container specific settings.json values on container create.
12 | "settings": {
13 | "terminal.integrated.shell.linux": "/bin/bash"
14 | },
15 |
16 | // Add the IDs of extensions you want installed when the container is created.
17 | "extensions": [
18 | "dbaeumer.vscode-eslint"
19 | ],
20 |
21 | // Use 'forwardPorts' to make a list of ports inside the container available locally.
22 | // "forwardPorts": [],
23 |
24 | // Use 'postCreateCommand' to run commands after the container is created.
25 | // "postCreateCommand": "yarn install",
26 |
27 | // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
28 | "remoteUser": "node"
29 | }
30 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017-present, Elasticsearch BV
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/.ci/docker/node-puppeteer/Dockerfile:
--------------------------------------------------------------------------------
1 | #Dockerfile for docker.elastic.co/observability-ci/node-puppeteer:12
2 | # When changing Node version, please build the Docker image for RUM here:
3 | # https://apm-ci.elastic.co/job/apm-shared/job/apm-docker-images-pipeline/build?delay=0sec
4 | # Remember checking the 'rum' parameter
5 | ARG NODEJS_VERSION
6 | FROM node:${NODEJS_VERSION}
7 |
8 | # Install latest chrome dev package and fonts to support major charsets (Chinese, Japanese, Arabic, Hebrew, Thai and a few others)
9 | # Note: this installs the necessary libs to make the bundled version of Chromium that Puppeteer
10 | # installs, work.
11 | RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
12 | && sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
13 | && apt-get update \
14 | && apt-get install -y \
15 | google-chrome-unstable \
16 | libxss1 \
17 | libxtst6 \
18 | fonts-ipafont-gothic \
19 | fonts-wqy-zenhei \
20 | fonts-thai-tlwg \
21 | fonts-kacst \
22 | ttf-freefont \
23 | --no-install-recommends \
24 | && rm -rf /var/lib/apt/lists/*
25 |
26 | # Always put COPY instructions at the end, so that Docker will reuse the above layers on builds
27 | COPY run-test.sh /run-test.sh
28 |
--------------------------------------------------------------------------------
/packages/rum/test/integration/babel.helper.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | const configFile = require.resolve('../../babel.config')
27 |
28 | require('@babel/register')({ configFile })
29 |
--------------------------------------------------------------------------------
/packages/rum/wdio.conf.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | const { getWebdriveBaseConfig } = require('../../dev-utils/webdriver')
27 |
28 | exports.config = getWebdriveBaseConfig(__dirname)
29 |
--------------------------------------------------------------------------------
/packages/rum-react/wdio.conf.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | const { getWebdriveBaseConfig } = require('../../dev-utils/webdriver')
27 |
28 | exports.config = getWebdriveBaseConfig(__dirname)
29 |
--------------------------------------------------------------------------------
/packages/rum-vue/wdio.conf.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | const { getWebdriveBaseConfig } = require('../../dev-utils/webdriver')
27 |
28 | exports.config = getWebdriveBaseConfig(__dirname)
29 |
--------------------------------------------------------------------------------
/packages/rum-angular/wdio.conf.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | const { getWebdriveBaseConfig } = require('../../dev-utils/webdriver')
27 |
28 | exports.config = getWebdriveBaseConfig(__dirname)
29 |
--------------------------------------------------------------------------------
/packages/rum-core/src/common/ndjson.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | class NDJSON {
27 | static stringify(object) {
28 | return JSON.stringify(object) + '\n'
29 | }
30 | }
31 |
32 | export default NDJSON
33 |
--------------------------------------------------------------------------------
/packages/rum-vue/test/polyfills.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | /**
27 | * Polyfills for unsupported browsers
28 | * - Object.assign is used in @vue/test-utils
29 | */
30 | import 'core-js/es/object/assign'
31 |
--------------------------------------------------------------------------------
/packages/rum-react/test/e2e/components/lazy-component.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | import React from 'react'
27 |
28 | export default function lazyComponent() {
29 | return
lazy component rendered
30 | }
31 |
--------------------------------------------------------------------------------
/packages/rum/babel.config.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | const { getBabelConfig } = require('../../dev-utils/build')
27 |
28 | module.exports = function(api) {
29 | const env = api.env()
30 | return getBabelConfig(env)
31 | }
32 |
--------------------------------------------------------------------------------
/packages/rum-core/babel.config.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | const { getBabelConfig } = require('../../dev-utils/build')
27 |
28 | module.exports = function(api) {
29 | const env = api.env()
30 | return getBabelConfig(env)
31 | }
32 |
--------------------------------------------------------------------------------
/packages/rum-vue/babel.config.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | const { getBabelConfig } = require('../../dev-utils/build')
27 |
28 | module.exports = function(api) {
29 | const env = api.env()
30 | return getBabelConfig(env)
31 | }
32 |
--------------------------------------------------------------------------------
/packages/rum-core/test/fixtures/paint-entries.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | export const fcpEntries = [
27 | {
28 | name: 'first-contentful-paint',
29 | entryType: 'paint',
30 | startTime: 128.5000000023283,
31 | duration: 0
32 | }
33 | ]
34 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Elastic APM Real User Monitoring (RUM) JavaScript agent
2 |
3 | [](https://apm-ci.elastic.co/job/apm-agent-rum/job/apm-agent-rum-mbp/job/master/)
4 | [](https://github.com/feross/standard)
5 | [](https://codecov.io/gh/elastic/apm-agent-rum-js)
6 | [](https://lernajs.io/)
7 |
8 | [](https://saucelabs.com/u/elastic-apm-base)
9 | Cross Browser testing is provided by [Sauce Labs](https://saucelabs.com/)
10 |
11 | This is the official Real User Monitoring JavaScript agent.
12 |
13 | ## Documentation
14 | You can find our documentation [on our website](https://www.elastic.co/guide/en/apm/agent/rum-js/current/index.html).
15 |
16 | If you are interested in contributing to Elastic APM JavaScript agent, please see [our contributing guide](CONTRIBUTING.md).
17 |
18 | We'd love to hear your feedback, please take a minute to fill out our [survey](https://goo.gl/forms/nLCXGCvziqalzjlP2).
19 |
20 | ## License
21 | This project is [MIT licensed](LICENSE).
22 |
23 | Made with ♥️ and ☕️ by Elastic and our community.
24 |
--------------------------------------------------------------------------------
/packages/rum-core/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@elastic/apm-rum-core",
3 | "version": "5.9.0",
4 | "description": "Elastic apm core",
5 | "license": "MIT",
6 | "main": "dist/lib/index.js",
7 | "module": "dist/es/index.js",
8 | "source": "src/index.js",
9 | "sideEffects": false,
10 | "publishConfig": {
11 | "access": "public"
12 | },
13 | "repository": {
14 | "type": "git",
15 | "url": "https://github.com/elastic/apm-agent-rum-js.git",
16 | "directory": "packages/rum-core"
17 | },
18 | "scripts": {
19 | "prepublishOnly": "npm run build",
20 | "build": "run-p build:*",
21 | "build:main": "BABEL_ENV=BROWSER_PROD npx babel src -d dist/lib",
22 | "build:module": "BABEL_ENV=BROWSER_ESM_PROD npx babel src -d dist/es",
23 | "karma:dev": "karma start --auto-watch --restartOnFileChange",
24 | "bench": "NODE_ENV=production karma start karma.bench.conf.js",
25 | "karma:coverage": "karma start --coverage --singleRun",
26 | "test:unit": "npm run script runUnitTests packages/rum-core",
27 | "test:sauce": "npm run script runSauceTests packages/rum-core true test:unit",
28 | "test": "npm run test:sauce",
29 | "script": "node ../../dev-utils/run-script.js"
30 | },
31 | "files": [
32 | "src",
33 | "dist"
34 | ],
35 | "engines": {
36 | "node": ">=8.0.0"
37 | },
38 | "dependencies": {
39 | "error-stack-parser": "^1.3.5",
40 | "opentracing": "^0.14.3",
41 | "promise-polyfill": "^8.1.3"
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/packages/rum-angular/test/e2e/with-router/app/home.component.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | import { Component } from '@angular/core'
27 |
28 | @Component({
29 | selector: 'app-home',
30 | template: `
31 |
Home page
32 | `
33 | })
34 | export class HomeComponent {}
35 |
--------------------------------------------------------------------------------
/packages/rum-angular/test/e2e/with-router/app/not-found.component.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | import { Component } from '@angular/core'
27 |
28 | @Component({
29 | selector: 'app-page-not-found',
30 | template: '
page not found
'
31 | })
32 | export class PageNotFoundComponent {}
33 |
--------------------------------------------------------------------------------
/packages/rum-core/test/polyfills.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | import 'promise-polyfill/src/polyfill'
27 | import 'core-js/features/array/map'
28 |
29 | Object.setPrototypeOf =
30 | Object.setPrototypeOf ||
31 | function(obj, proto) {
32 | obj.__proto__ = proto
33 | return obj
34 | }
35 |
--------------------------------------------------------------------------------
/packages/rum/karma.conf.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | const { baseConfig, prepareConfig } = require('../../dev-utils/karma.js')
27 |
28 | module.exports = function(config) {
29 | config.set(baseConfig)
30 | const preparedConfig = prepareConfig(config, 'rum')
31 | config.set(preparedConfig)
32 | }
33 |
--------------------------------------------------------------------------------
/packages/rum-core/karma.conf.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | const { baseConfig, prepareConfig } = require('../../dev-utils/karma')
27 |
28 | module.exports = function(config) {
29 | config.set(baseConfig)
30 | const preparedConfig = prepareConfig(config, 'rum-core')
31 | config.set(preparedConfig)
32 | }
33 |
--------------------------------------------------------------------------------
/packages/rum-angular/src/index.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | import { apm } from '@elastic/apm-rum'
27 | import { ApmService } from './apm-service'
28 | import { ApmErrorHandler } from './error-handler'
29 |
30 | ApmService.apm = apm
31 | ApmErrorHandler.apm = apm
32 |
33 | export { ApmService, ApmErrorHandler }
34 |
--------------------------------------------------------------------------------
/docs/sourcemap.asciidoc:
--------------------------------------------------------------------------------
1 | [[sourcemap]]
2 | == Source maps
3 |
4 | Minifying JavaScript bundles is a common practice in production as it can improve the load time and network latency of your application.
5 | However, minified code by itself can be hard to debug.
6 | For this reason, Elastic APM supports source maps.
7 | A source map is a file that maps minified files back to the original source code,
8 | allowing you to maintain the speed advantage of minified code,
9 | without losing the ability to quickly and easily debug your applications.
10 |
11 | There are three steps required to enable, upload, and apply a source map to error stack traces.
12 | An overview is listed below, and a complete walk-through is available in the
13 | {apm-server-ref-v}/sourcemaps.html[generate and upload a source map] guide.
14 |
15 | 1. Set the <> when initializing the RUM Agent.
16 | 2. {apm-server-ref-v}/sourcemaps.html#sourcemap-rum-generate[Generate a source map]
17 | for your application with the `serviceVersion` from step one.
18 | 3. {apm-server-ref-v}/sourcemaps.html#sourcemap-rum-upload[Enable and upload the source map file] to APM Server.
19 |
20 | // Don't link to this section
21 | [[secret-token]]
22 | You can also configure a {apm-server-ref-v}/secret-token.html[secret token] or
23 | {apm-server-ref-v}/api-key.html[API key] to restrict the uploading of sourcemaps.
24 |
25 | TIP: Don't forget,
26 | you must enable {apm-server-ref-v}/configuration-rum.html[RUM support] in the APM Server for this endpoint to work.
27 |
--------------------------------------------------------------------------------
/packages/rum-core/test/common/ndjson.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | import NDJSON from '../../src/common/ndjson'
27 |
28 | describe('NDJSON', function() {
29 | it('should stringify', function() {
30 | var result = NDJSON.stringify({ test: 'passed' })
31 | expect(result).toBe('{"test":"passed"}\n')
32 | })
33 | })
34 |
--------------------------------------------------------------------------------
/packages/rum-angular/test/e2e/with-router/main.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | import '../../polyfills'
27 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'
28 |
29 | import { AppModule } from './app/app.module'
30 |
31 | platformBrowserDynamic()
32 | .bootstrapModule(AppModule)
33 | .catch(err => console.error(err))
34 |
--------------------------------------------------------------------------------
/packages/rum-angular/src/error-handler.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | import { ErrorHandler } from '@angular/core'
27 |
28 | export class ApmErrorHandler extends ErrorHandler {
29 | static apm: any
30 |
31 | handleError(error) {
32 | ApmErrorHandler.apm.captureError(error.originalError || error)
33 | super.handleError(error)
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/packages/rum-core/test/fixtures/fid-entries.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | export default [
27 | {
28 | name: 'mousedown',
29 | entryType: 'first-input',
30 | startTime: 5482.669999997597,
31 | duration: 16,
32 | processingStart: 5489.029999997001,
33 | processingEnd: 5489.0550000127405,
34 | cancelable: true
35 | }
36 | ]
37 |
--------------------------------------------------------------------------------
/packages/rum/test/e2e/async-tests/index.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Async Test
5 |
6 |
7 |
38 |
39 |
40 |
41 |
Loading RUM agent Asynchronously
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/packages/rum-angular/babel.config.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | const { getBabelConfig, PACKAGE_TYPES } = require('../../dev-utils/build')
27 |
28 | module.exports = function(api) {
29 | /**
30 | * Reads BABEL_ENV to decide between CJS and ESM formats
31 | */
32 | const env = api.env()
33 | return getBabelConfig(env, PACKAGE_TYPES.ANGULAR)
34 | }
35 |
--------------------------------------------------------------------------------
/packages/rum-react/babel.config.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | const { getBabelConfig, PACKAGE_TYPES } = require('../../dev-utils/build')
27 |
28 | module.exports = function(api) {
29 | /**
30 | * Reads BABEL_ENV to decide between CJS and ESM formats
31 | */
32 | const env = api.env()
33 | return getBabelConfig(env, PACKAGE_TYPES.REACT)
34 | }
35 |
--------------------------------------------------------------------------------
/packages/rum-react/src/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | import { apm } from '@elastic/apm-rum'
27 | import { getWithTransaction } from './get-with-transaction'
28 | import { getApmRoute } from './get-apm-route'
29 |
30 | const withTransaction = getWithTransaction(apm)
31 | const ApmRoute = getApmRoute(apm)
32 |
33 | export { withTransaction, ApmRoute }
34 |
--------------------------------------------------------------------------------
/packages/rum-core/src/state.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | const __DEV__ = process.env.NODE_ENV !== 'production'
27 | const state = {
28 | // Time when agent is bootstrapped and patching of modules happens
29 | bootstrapTime: null,
30 | // Time when the document is last backgrounded
31 | lastHiddenStart: Number.MIN_SAFE_INTEGER
32 | }
33 |
34 | export { __DEV__, state }
35 |
--------------------------------------------------------------------------------
/packages/rum-angular/test/e2e/with-router/app/contact.service.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | import { Injectable } from '@angular/core'
27 | import { HttpClient } from '@angular/common/http'
28 |
29 | @Injectable({
30 | providedIn: 'root'
31 | })
32 | export class ContactService {
33 | CONTACT_URL = '/test/e2e/with-router/data.json'
34 | constructor(private http: HttpClient) {}
35 |
36 | getContacts() {
37 | return this.http.get(this.CONTACT_URL)
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/packages/rum/test/e2e/manual-timing/webpack.config.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | const { join, resolve } = require('path')
27 | const {
28 | getWebpackConfig,
29 | BUNDLE_TYPES
30 | } = require('../../../../../dev-utils/build')
31 |
32 | module.exports = {
33 | entry: join(__dirname, './app.js'),
34 | output: {
35 | path: resolve(__dirname),
36 | filename: 'app.e2e-bundle.js',
37 | libraryTarget: 'umd'
38 | },
39 | ...getWebpackConfig(BUNDLE_TYPES.BROWSER_DEV)
40 | }
41 |
--------------------------------------------------------------------------------
/packages/rum/test/e2e/general-usecase/webpack.config.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | const { join, resolve } = require('path')
27 | const {
28 | getWebpackConfig,
29 | BUNDLE_TYPES
30 | } = require('../../../../../dev-utils/build')
31 |
32 | module.exports = {
33 | entry: join(__dirname, 'app.js'),
34 | output: {
35 | filename: 'app.e2e-bundle.min.js',
36 | path: resolve(__dirname),
37 | libraryTarget: 'umd'
38 | },
39 | ...getWebpackConfig(BUNDLE_TYPES.BROWSER_PROD)
40 | }
41 |
--------------------------------------------------------------------------------
/packages/rum-angular/test/e2e/with-router/app/app.component.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | import { Component } from '@angular/core'
27 |
28 | @Component({
29 | selector: 'app-root',
30 | template: `
31 |
Elastic APM with Angular Router
32 |
37 |
38 | `
39 | })
40 | export class AppComponent {}
41 |
--------------------------------------------------------------------------------
/packages/rum-vue/test/e2e/webpack.config.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | const path = require('path')
27 | const {
28 | getWebpackConfig,
29 | BUNDLE_TYPES,
30 | PACKAGE_TYPES
31 | } = require('../../../../dev-utils/build')
32 |
33 | module.exports = {
34 | entry: {
35 | app: path.join(__dirname, 'app.js')
36 | },
37 | output: {
38 | path: path.resolve(__dirname),
39 | filename: 'app.e2e-bundle.js'
40 | },
41 | ...getWebpackConfig(BUNDLE_TYPES.BROWSER_PROD, PACKAGE_TYPES.VUE)
42 | }
43 |
--------------------------------------------------------------------------------
/packages/rum/test/e2e/standalone-html/base.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | import { testXHR, renderTestElement } from '../utils'
27 | import { getGlobalConfig } from '../../../../../dev-utils/test-config'
28 |
29 | const { serverUrl, mockBackendUrl } = getGlobalConfig().testConfig
30 |
31 | window.elasticApm.init({
32 | serviceName: 'standalone-html',
33 | serverUrl,
34 | distributedTracingOrigins: [mockBackendUrl],
35 | pageLoadTransactionName: '/'
36 | })
37 |
38 | testXHR(mockBackendUrl, renderTestElement)
39 |
--------------------------------------------------------------------------------
/packages/rum-core/src/common/polyfills.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | import PromisePollyfill from 'promise-polyfill'
27 | import { isBrowser } from './utils'
28 |
29 | /**
30 | * Use the globally available promise if it exists and
31 | * fallback to using the polyfilled Promise
32 | */
33 | let local = {}
34 | if (isBrowser) {
35 | local = window
36 | } else if (typeof self !== 'undefined') {
37 | local = self
38 | }
39 | const Promise = 'Promise' in local ? local.Promise : PromisePollyfill
40 |
41 | export { Promise }
42 |
--------------------------------------------------------------------------------
/packages/rum/test/e2e/async-tests/app.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | import { testXHR, renderTestElement } from '../utils'
27 | import { getGlobalConfig } from '../../../../../dev-utils/test-config'
28 |
29 | const { mockBackendUrl } = getGlobalConfig().testConfig
30 |
31 | /**
32 | * Currently, XHR call will not be captured as Spans by the agent
33 | * since agent script is loaded asynchronously and we will not be able to patch
34 | * XHR and FETCH calls on time
35 | */
36 | testXHR(mockBackendUrl, renderTestElement, false)
37 |
--------------------------------------------------------------------------------
/packages/rum-angular/test/e2e/with-router/webpack.config.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | const path = require('path')
27 | const {
28 | getWebpackConfig,
29 | PACKAGE_TYPES,
30 | BUNDLE_TYPES
31 | } = require('../../../../../dev-utils/build')
32 |
33 | module.exports = {
34 | entry: {
35 | app: path.join(__dirname, 'main.ts')
36 | },
37 | output: {
38 | path: path.resolve(__dirname),
39 | filename: '[name].e2e-bundle.js'
40 | },
41 | ...getWebpackConfig(BUNDLE_TYPES.BROWSER_PROD, PACKAGE_TYPES.ANGULAR)
42 | }
43 |
--------------------------------------------------------------------------------
/packages/rum-vue/karma.conf.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | const { baseConfig, prepareConfig } = require('../../dev-utils/karma')
27 | const {
28 | getWebpackConfig,
29 | PACKAGE_TYPES,
30 | BUNDLE_TYPES
31 | } = require('../../dev-utils/build')
32 |
33 | module.exports = function(config) {
34 | config.set(baseConfig)
35 | config.set({
36 | webpack: getWebpackConfig(BUNDLE_TYPES.BROWSER_DEV, PACKAGE_TYPES.VUE)
37 | })
38 | const preparedConfig = prepareConfig(config, 'rum-vue')
39 | config.set(preparedConfig)
40 | }
41 |
--------------------------------------------------------------------------------
/packages/rum-react/karma.conf.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | const { baseConfig, prepareConfig } = require('../../dev-utils/karma.js')
27 | const {
28 | getWebpackConfig,
29 | PACKAGE_TYPES,
30 | BUNDLE_TYPES
31 | } = require('../../dev-utils/build')
32 |
33 | module.exports = function(config) {
34 | config.set(baseConfig)
35 | config.set({
36 | webpack: getWebpackConfig(BUNDLE_TYPES.BROWSER_DEV, PACKAGE_TYPES.REACT)
37 | })
38 | const preparedConfig = prepareConfig(config, 'rum-react')
39 | config.set(preparedConfig)
40 | }
41 |
--------------------------------------------------------------------------------
/packages/rum-angular/karma.conf.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | const { baseConfig, prepareConfig } = require('../../dev-utils/karma.js')
27 | const {
28 | getWebpackConfig,
29 | PACKAGE_TYPES,
30 | BUNDLE_TYPES
31 | } = require('../../dev-utils/build')
32 |
33 | module.exports = function(config) {
34 | config.set(baseConfig)
35 | config.set({
36 | webpack: getWebpackConfig(BUNDLE_TYPES.BROWSER_DEV, PACKAGE_TYPES.ANGULAR)
37 | })
38 | const preparedConfig = prepareConfig(config, 'rum-angular')
39 | config.set(preparedConfig)
40 | }
41 |
--------------------------------------------------------------------------------
/.ci/jobs/defaults.yml:
--------------------------------------------------------------------------------
1 | ---
2 |
3 | ##### GLOBAL METADATA
4 |
5 | - meta:
6 | cluster: apm-ci
7 |
8 | ##### JOB DEFAULTS
9 |
10 | - job:
11 | view: APM-CI
12 | project-type: multibranch
13 | logrotate:
14 | daysToKeep: 30
15 | numToKeep: 100
16 | number-to-keep: '5'
17 | days-to-keep: '1'
18 | concurrent: true
19 | node: linux
20 | script-path: Jenkinsfile
21 | scm:
22 | - github:
23 | branch-discovery: all
24 | discover-pr-forks-strategy: merge-current
25 | discover-pr-forks-trust: permission
26 | discover-pr-origin: merge-current
27 | discover-tags: true
28 | notification-context: 'apm-ci'
29 | repo: apm-agent-rum-js
30 | repo-owner: elastic
31 | credentials-id: 2a9602aa-ab9f-4e52-baf3-b71ca88469c7-UserAndToken
32 | ssh-checkout:
33 | credentials: f6c7695a-671e-4f4f-a331-acdce44ff9ba
34 | build-strategies:
35 | - tags:
36 | ignore-tags-older-than: -1
37 | ignore-tags-newer-than: -1
38 | - regular-branches: true
39 | - change-request:
40 | ignore-target-only-changes: false
41 | clean:
42 | after: true
43 | before: true
44 | prune: true
45 | shallow-clone: true
46 | depth: 3
47 | do-not-fetch-tags: true
48 | submodule:
49 | disable: false
50 | recursive: true
51 | parent-credentials: true
52 | timeout: 100
53 | timeout: '15'
54 | use-author: true
55 | wipe-workspace: 'True'
56 | periodic-folder-trigger: 1d
57 | prune-dead-branches: true
58 | publishers:
59 | - email:
60 | recipients: infra-root+build@elastic.co
61 |
--------------------------------------------------------------------------------
/packages/rum/test/integration/index.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | import { apmBase } from '../../src'
27 | import { getGlobalConfig } from '../../../../dev-utils/test-config'
28 |
29 | const { agentConfig } = getGlobalConfig()
30 |
31 | describe('ApmBase', function() {
32 | it('should not init ApmBase', function() {
33 | apmBase.init(agentConfig)
34 | try {
35 | throw new Error('ApmBase test error')
36 | } catch (error) {
37 | var result = apmBase.captureError(error)
38 | expect(result).toBeUndefined()
39 | }
40 | })
41 | })
42 |
--------------------------------------------------------------------------------
/packages/rum/test/e2e/standalone-html/webpack.config.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | const path = require('path')
27 | const {
28 | getWebpackConfig,
29 | BUNDLE_TYPES
30 | } = require('../../../../../dev-utils/build')
31 |
32 | module.exports = {
33 | entry: {
34 | base: path.join(__dirname, 'base'),
35 | opentracing: path.join(__dirname, 'opentracing')
36 | },
37 | output: {
38 | path: path.resolve(__dirname),
39 | filename: '[name].e2e-bundle.js',
40 | libraryTarget: 'umd'
41 | },
42 | ...getWebpackConfig(BUNDLE_TYPES.BROWSER_DEV)
43 | }
44 |
--------------------------------------------------------------------------------
/packages/rum-core/test/bootstrap.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | import { bootstrap } from '../src/bootstrap'
27 |
28 | describe('bootstrap', function() {
29 | it('should log warning on unsupported environments', () => {
30 | // Pass unsupported check
31 | const nowFn = window.performance.now
32 | window.performance.now = undefined
33 |
34 | spyOn(console, 'log')
35 | bootstrap()
36 |
37 | expect(console.log).toHaveBeenCalledWith(
38 | '[Elastic APM] platform is not supported!'
39 | )
40 | window.performance.now = nowFn
41 | })
42 | })
43 |
--------------------------------------------------------------------------------
/scripts/prompt-release.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | const log = require('npmlog')
27 | const childProcess = require('@lerna/child-process')
28 |
29 | !(async () => {
30 | /**
31 | * Test the agent version with updated package version
32 | */
33 | try {
34 | childProcess.execSync('eslint', [
35 | '--rule',
36 | '{"rulesdir/version-checker": "error"}',
37 | '--fix',
38 | './packages/rum/src/apm-base.js'
39 | ])
40 |
41 | childProcess.execSync('git', ['add', './packages/rum/src/apm-base.js'])
42 | } catch (err) {
43 | log.error(err)
44 | }
45 | })()
46 |
--------------------------------------------------------------------------------
/packages/rum-react/test/e2e/with-router/webpack.config.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | const path = require('path')
27 | const {
28 | getWebpackConfig,
29 | PACKAGE_TYPES,
30 | BUNDLE_TYPES
31 | } = require('../../../../../dev-utils/build')
32 |
33 | module.exports = {
34 | entry: {
35 | general: path.join(__dirname, 'general.js'),
36 | switch: path.join(__dirname, 'switch.js')
37 | },
38 | output: {
39 | path: path.resolve(__dirname),
40 | filename: '[name].e2e-bundle.js',
41 | libraryTarget: 'umd'
42 | },
43 | ...getWebpackConfig(BUNDLE_TYPES.BROWSER_DEV, PACKAGE_TYPES.REACT)
44 | }
45 |
--------------------------------------------------------------------------------
/packages/rum-core/test/common/patch.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | import { patchAll } from '../../src/common/patching/'
27 |
28 | if (!window['__patchEventHandler']) {
29 | var nativeFetch = window.fetch
30 | if (nativeFetch) {
31 | window.fetch = function() {
32 | var delegate = window['__fetchDelegate']
33 | if (typeof delegate === 'function') {
34 | return delegate.apply(this, arguments)
35 | } else {
36 | return nativeFetch.apply(this, arguments)
37 | }
38 | }
39 | }
40 | window['__patchEventHandler'] = patchAll()
41 | }
42 |
43 | export default window['__patchEventHandler']
44 |
--------------------------------------------------------------------------------
/packages/rum-core/test/error-logging/stack-trace.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | import { createStackTraces } from '../../src/error-logging/stack-trace'
27 |
28 | describe('StackTraceService', function() {
29 | it('should produce correct number of frames', function(done) {
30 | function generateError() {
31 | throw new Error('test error')
32 | }
33 | setTimeout(function() {
34 | try {
35 | generateError()
36 | } catch (error) {
37 | var stackTraces = createStackTraces({ error })
38 | expect(stackTraces.length).toBeGreaterThan(1)
39 | done()
40 | }
41 | }, 1)
42 | })
43 | })
44 |
--------------------------------------------------------------------------------
/packages/rum-core/src/common/patching/history-patch.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | import { INVOKE, HISTORY } from '../constants'
27 |
28 | export function patchHistory(callback) {
29 | if (!window.history) {
30 | return
31 | }
32 |
33 | const nativePushState = history.pushState
34 | if (typeof nativePushState === 'function') {
35 | history.pushState = function(state, title, url) {
36 | const task = {
37 | source: HISTORY,
38 | data: {
39 | state,
40 | title,
41 | url
42 | }
43 | }
44 |
45 | callback(INVOKE, task)
46 | nativePushState.apply(this, arguments)
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/packages/rum-core/src/opentracing/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | import Tracer from './tracer'
27 | import Span from './span'
28 |
29 | function createTracer(serviceFactory) {
30 | var performanceMonitoring = serviceFactory.getService('PerformanceMonitoring')
31 | var transactionService = serviceFactory.getService('TransactionService')
32 | var errorLogging = serviceFactory.getService('ErrorLogging')
33 | var loggingService = serviceFactory.getService('LoggingService')
34 | return new Tracer(
35 | performanceMonitoring,
36 | transactionService,
37 | loggingService,
38 | errorLogging
39 | )
40 | }
41 |
42 | export { Span, Tracer, createTracer }
43 |
--------------------------------------------------------------------------------
/packages/rum-vue/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@elastic/apm-rum-vue",
3 | "version": "1.1.10",
4 | "description": "Elastic APM Real User Monitoring for Vue applications",
5 | "keywords": [
6 | "elastic",
7 | "apm",
8 | "vue",
9 | "vue-router"
10 | ],
11 | "homepage": "https://www.elastic.co/guide/en/apm/agent/rum-js/current/index.html",
12 | "license": "MIT",
13 | "main": "dist/lib/index.js",
14 | "module": "dist/es/index.js",
15 | "source": "src/index.js",
16 | "files": [
17 | "dist",
18 | "src"
19 | ],
20 | "engines": {
21 | "node": ">=8.0.0"
22 | },
23 | "scripts": {
24 | "prepublishOnly": "npm run build",
25 | "build": "run-p build:main build:module",
26 | "build:main": "BABEL_ENV=BROWSER_PROD npx babel src -d dist/lib",
27 | "build:module": "BABEL_ENV=BROWSER_ESM_PROD npx babel src -d dist/es",
28 | "build:e2e": "npm run script buildE2eBundles packages/rum-vue/test/e2e",
29 | "karma:dev": "karma start --auto-watch --restartOnFileChange",
30 | "karma:coverage": "karma start --coverage --singleRun",
31 | "test:unit": "npm run script runUnitTests packages/rum-vue",
32 | "test:e2e": "npm run script runE2eTests packages/rum-vue/wdio.conf.js",
33 | "test:sauce": "npm run script runSauceTests packages/rum-vue true build:e2e test:unit test:e2e",
34 | "test": "npm run test:sauce",
35 | "script": "node ../../dev-utils/run-script.js"
36 | },
37 | "publishConfig": {
38 | "access": "public"
39 | },
40 | "repository": {
41 | "type": "git",
42 | "url": "https://github.com/elastic/apm-agent-rum-js.git",
43 | "directory": "packages/rum-vue"
44 | },
45 | "bugs": {
46 | "url": "https://github.com/elastic/apm-agent-rum-js/issues"
47 | },
48 | "dependencies": {
49 | "@elastic/apm-rum": "file:../rum",
50 | "@elastic/apm-rum-core": "file:../rum-core"
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/packages/rum/test/e2e/standalone-html/opentracing.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | import { testXHR, renderTestElement } from '../utils'
27 | import { getGlobalConfig } from '../../../../../dev-utils/test-config'
28 |
29 | const { serverUrl, mockBackendUrl } = getGlobalConfig().testConfig
30 |
31 | window.elasticApm.init({
32 | serviceName: 'standalone-html',
33 | serverUrl,
34 | distributedTracingOrigins: [mockBackendUrl],
35 | pageLoadTransactionName: '/'
36 | })
37 |
38 | const tracer = window.elasticApm.createTracer()
39 | const span = tracer.startSpan('Opentracing span')
40 | span && span.finish(Date.now() + 100)
41 |
42 | testXHR(mockBackendUrl, renderTestElement)
43 |
--------------------------------------------------------------------------------
/packages/rum/wdio-failsafe.conf.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | const { join } = require('path')
27 | const glob = require('glob')
28 | const { config } = require('./wdio.conf')
29 | const { getSauceConnectOptions } = require('../../dev-utils/test-config')
30 |
31 | const { tunnelIdentifier } = getSauceConnectOptions()
32 | const browserList = [
33 | {
34 | browserName: 'internet explorer',
35 | platform: 'Windows 7',
36 | version: '10'
37 | }
38 | ].map(capability => ({ tunnelIdentifier, ...capability }))
39 |
40 | exports.config = Object.assign({}, config, {
41 | specs: glob.sync(join(__dirname, '/test/e2e/**/*failsafe.js')),
42 | capabilities: browserList
43 | })
44 |
--------------------------------------------------------------------------------
/packages/rum/test/integration/integration-test.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | import request from 'request'
27 |
28 | describe('integration-test', function() {
29 | it('should run integration test', function(done) {
30 | request.get(
31 | {
32 | url: 'http://localhost:8000/run_integration_test?echo=done'
33 | },
34 | function(err, resp, body) {
35 | if (err || (resp.statusCode !== 200 && resp.statusCode !== 202)) {
36 | var message = `Integration test failed, error: ${err}, response: ${resp &&
37 | resp.statusCode}, body: ${body}`
38 | fail(message)
39 | }
40 | done()
41 | }
42 | )
43 | })
44 | })
45 |
--------------------------------------------------------------------------------
/packages/rum-core/src/common/throttle.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | export default function throttle(fn, onThrottle, opts) {
27 | var context = this
28 | var limit = opts.limit
29 | var interval = opts.interval
30 | var counter = 0
31 | var timeoutId
32 | return function() {
33 | counter++
34 | if (typeof timeoutId === 'undefined') {
35 | timeoutId = setTimeout(function() {
36 | counter = 0
37 | timeoutId = undefined
38 | }, interval)
39 | }
40 | if (counter > limit && typeof onThrottle === 'function') {
41 | return onThrottle.apply(context, arguments)
42 | } else {
43 | return fn.apply(context, arguments)
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/packages/rum-core/src/error-logging/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | import ErrorLogging from './error-logging'
27 | import { CONFIG_SERVICE, APM_SERVER } from '../common/constants'
28 | import { serviceCreators } from '../common/service-factory'
29 |
30 | function registerServices() {
31 | serviceCreators['ErrorLogging'] = serviceFactory => {
32 | const [
33 | apmServer,
34 | configService,
35 | transactionService
36 | ] = serviceFactory.getService([
37 | APM_SERVER,
38 | CONFIG_SERVICE,
39 | 'TransactionService'
40 | ])
41 | return new ErrorLogging(apmServer, configService, transactionService)
42 | }
43 | }
44 |
45 | export { registerServices }
46 |
--------------------------------------------------------------------------------
/packages/rum-core/test/fixtures/lcp-entries.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | export default [
27 | {
28 | renderTime: 298.51500000222586,
29 | loadTime: 295.4050000116695,
30 | size: 3000,
31 | id: '',
32 | url: 'http://example.com/logo.svg',
33 | element: null, // points to a DOM element
34 | name: '',
35 | entryType: 'largest-contentful-paint',
36 | startTime: 298.51500000222586,
37 | duration: 0
38 | },
39 | {
40 | renderTime: 1040.0399999925867,
41 | loadTime: 0,
42 | size: 5250,
43 | id: '',
44 | url: '',
45 | element: null,
46 | name: '',
47 | entryType: 'largest-contentful-paint',
48 | startTime: 1040.0399999925867,
49 | duration: 0
50 | }
51 | ]
52 |
--------------------------------------------------------------------------------
/packages/rum-react/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@elastic/apm-rum-react",
3 | "version": "1.2.7",
4 | "description": "Elastic APM Real User Monitoring for React applications",
5 | "author": "Hamid ",
6 | "homepage": "https://www.elastic.co/guide/en/apm/agent/rum-js/current/index.html",
7 | "license": "MIT",
8 | "main": "dist/lib/index.js",
9 | "module": "dist/es/index.js",
10 | "source": "src/index.js",
11 | "files": [
12 | "dist",
13 | "src"
14 | ],
15 | "engines": {
16 | "node": ">=8.0.0"
17 | },
18 | "publishConfig": {
19 | "access": "public"
20 | },
21 | "repository": {
22 | "type": "git",
23 | "url": "git+https://github.com/elastic/apm-agent-rum-js.git",
24 | "directory": "packages/rum-react"
25 | },
26 | "scripts": {
27 | "prepublishOnly": "npm run build",
28 | "build": "run-p build:main build:module",
29 | "build:main": "BABEL_ENV=BROWSER_PROD npx babel src -d dist/lib",
30 | "build:module": "BABEL_ENV=BROWSER_ESM_PROD npx babel src -d dist/es",
31 | "build:e2e": "npm run script buildE2eBundles packages/rum-react/test/e2e",
32 | "karma:dev": "karma start --auto-watch --restartOnFileChange",
33 | "karma:coverage": "karma start --coverage --singleRun",
34 | "test:unit": "npm run script runUnitTests packages/rum-react",
35 | "test:e2e": "npm run script runE2eTests packages/rum-react/wdio.conf.js",
36 | "test:sauce": "npm run script runSauceTests packages/rum-react true build:e2e test:unit test:e2e",
37 | "test": "npm run test:sauce",
38 | "script": "node ../../dev-utils/run-script.js"
39 | },
40 | "bugs": {
41 | "url": "https://github.com/elastic/apm-agent-rum-js/issues"
42 | },
43 | "dependencies": {
44 | "@elastic/apm-rum": "file:../rum",
45 | "hoist-non-react-statics": "^3.3.0"
46 | },
47 | "peerDependencies": {
48 | "react": "^16.0.0",
49 | "react-router-dom": "^4.0.0"
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/docs/span-api.asciidoc:
--------------------------------------------------------------------------------
1 | [[span-api]]
2 |
3 | === `Span` API
4 |
5 | A span measures the duration of a single event.
6 | When a span is created it will measure the time until <> is called.
7 |
8 | To get a `Span` object,
9 | you need to call <>.
10 |
11 | [float]
12 | [[span-name]]
13 | ==== `span.name`
14 |
15 | * *Type:* String
16 | * *Default:* `Unknown`
17 |
18 | The name of the span.
19 | This can also be set via <>.
20 |
21 |
22 | [float]
23 | [[span-type]]
24 | ==== `span.type`
25 |
26 | * *Type:* String
27 | * *Default:* `custom`
28 |
29 | The type of span.
30 | This can also be set via <>.
31 |
32 | The type is a hierarchical string used to group similar spans together.
33 | For instance, all outgoing AJAX requests are given the type `external.http`.
34 |
35 | In the above example, `external` is considered the type prefix.
36 | Though there are no naming restrictions for this prefix,
37 | the following are standardized across all Elastic APM agents:
38 | `app`, `db`, `cache`, `template`, and `external`.
39 |
40 |
41 | [float]
42 | [[span-add-labels]]
43 | ==== `span.addLabels()`
44 |
45 | [source,js]
46 | ----
47 | span.addLabels({ [name]: value })
48 | ----
49 |
50 | Add several labels on the span. If an error happens during the span,
51 | it will also get tagged with the same labels.
52 |
53 | Arguments:
54 |
55 | * `name` - Any string. All periods (.), asterisks (*), and double quotation marks (") will be replaced by underscores (_), as those characters have special meaning in Elasticsearch
56 |
57 | * `value` - Any string, boolean, or number. All other data types will be converted to a string
58 | before being sent to the APM Server.
59 |
60 | [float]
61 | [[span-end]]
62 | ==== `span.end()`
63 |
64 | [source,js]
65 | ----
66 | span.end()
67 | ----
68 |
69 | Ends the span. If the span has already ended, nothing happens.
70 |
--------------------------------------------------------------------------------
/docs/intro.asciidoc:
--------------------------------------------------------------------------------
1 | [[intro]]
2 | == Introduction
3 |
4 | The Elastic APM Real User Monitoring (RUM) JavaScript Agent provides detailed performance metrics and error tracking of your web applications.
5 | It has built-in support for popular platforms and frameworks, and an API for custom instrumentation.
6 |
7 | The Agent also supports <> for all outgoing requests.
8 | This enables you to analyze performance throughout your microservice architecture -- all in one view.
9 |
10 | [float]
11 | [[features]]
12 | === Features
13 |
14 | The agent uses browser timing APIs such as https://w3c.github.io/navigation-timing/[Navigation Timing]
15 | https://w3c.github.io/resource-timing/[Resource Timing], https://w3c.github.io/paint-timing/[Paint Timing], https://w3c.github.io/user-timing/[User Timing], etc., and
16 | captures the following information:
17 |
18 | * <>
19 | * Load time of Static Assets (JS, CSS, images, fonts, etc.)
20 | * API requests (XMLHttpRequest and Fetch)
21 | * Single page application navigations
22 | * <> (click events that trigger network activity)
23 | * <> (Long tasks, FCP, LCP, FID, etc.)
24 | * Page information (URLs visited and referrer)
25 | * Network connection information
26 | * JavaScript errors
27 | * <>
28 | * <>
29 |
30 | [float]
31 | [[additional-components]]
32 | === Additional Components
33 |
34 | APM Agents work in conjunction with the {apm-server-ref-v}/index.html[APM Server], {ref}/index.html[Elasticsearch], and {kibana-ref}/index.html[Kibana].
35 | The {apm-overview-ref-v}/index.html[APM Overview] provides details on how these components work together,
36 | and provides a matrix outlining {apm-overview-ref-v}/agent-server-compatibility.html[Agent and Server compatibility].
37 |
38 | include::./set-up.asciidoc[]
39 |
--------------------------------------------------------------------------------
/packages/rum-angular/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@elastic/apm-rum-angular",
3 | "version": "1.1.10",
4 | "description": "Elastic APM Real User Monitoring for Angular applications",
5 | "homepage": "https://www.elastic.co/guide/en/apm/agent/rum-js/current/index.html",
6 | "license": "MIT",
7 | "main": "dist/lib/index.js",
8 | "module": "dist/es/index.js",
9 | "es2015": "dist/es2015/index.js",
10 | "source": "src/index.ts",
11 | "files": [
12 | "dist",
13 | "src"
14 | ],
15 | "publishConfig": {
16 | "access": "public"
17 | },
18 | "repository": {
19 | "type": "git",
20 | "url": "https://github.com/elastic/apm-agent-rum-js.git",
21 | "directory": "packages/rum-angular"
22 | },
23 | "engines": {
24 | "node": ">=8.0.0"
25 | },
26 | "scripts": {
27 | "prepublishOnly": "npm run build",
28 | "build": "run-p build:main build:module build:es2015",
29 | "build:main": "BABEL_ENV=BROWSER_PROD npx babel -x '.ts' src -d dist/lib ",
30 | "build:module": "BABEL_ENV=BROWSER_ESM_PROD npx babel -x '.ts' src -d dist/es",
31 | "build:es2015": "BABEL_ENV=BROWSER_ESM_ES2015 npx babel -x '.ts' src -d dist/es2015",
32 | "build:e2e": "npm run script buildE2eBundles packages/rum-angular/test/e2e",
33 | "test:unit": "npm run script runUnitTests packages/rum-angular",
34 | "test:e2e": "npm run script runE2eTests packages/rum-angular/wdio.conf.js",
35 | "test:sauce": "npm run script runSauceTests packages/rum-angular true test:unit build:e2e test:e2e",
36 | "test": "npm run test:sauce",
37 | "script": "node ../../dev-utils/run-script.js",
38 | "karma:dev": "karma start --auto-watch --restartOnFileChange",
39 | "karma:coverage": "karma start --coverage --singleRun"
40 | },
41 | "dependencies": {
42 | "@elastic/apm-rum": "file:../rum",
43 | "@elastic/apm-rum-core": "file:../rum-core"
44 | },
45 | "peerDependencies": {
46 | "@angular/core": "^8.0.0",
47 | "@angular/router": "^8.0.0"
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/packages/rum-core/test/performance-monitoring/span.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | import Span from '../../src/performance-monitoring/span'
27 |
28 | describe('Span', function() {
29 | it('should return null for duration if not ended', function() {
30 | var s = new Span('test', 'test')
31 | expect(s.duration()).toBe(null)
32 | })
33 |
34 | it('should support dot delimiter in span types', function() {
35 | var s1 = new Span('test1', 'db.mysql.query')
36 | expect(s1.type).toBe('db')
37 | expect(s1.subtype).toBe('mysql')
38 | expect(s1.action).toBe('query')
39 |
40 | var s2 = new Span('test2', 'db-query')
41 | expect(s2.type).toBe('db-query')
42 | expect(s2.subtype).toBe(undefined)
43 | expect(s2.action).toBe(undefined)
44 | })
45 | })
46 |
--------------------------------------------------------------------------------
/packages/rum-core/src/performance-monitoring/span.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | import SpanBase from './span-base'
27 | import { addSpanContext } from '../common/context'
28 |
29 | class Span extends SpanBase {
30 | constructor(name, type, options) {
31 | super(name, type, options)
32 | this.parentId = this.options.parentId
33 | this.subtype = undefined
34 | this.action = undefined
35 | if (this.type.indexOf('.') !== -1) {
36 | var fields = this.type.split('.', 3)
37 | this.type = fields[0]
38 | this.subtype = fields[1]
39 | this.action = fields[2]
40 | }
41 | this.sync = this.options.sync
42 | }
43 |
44 | end(endTime, data) {
45 | super.end(endTime)
46 | addSpanContext(this, data)
47 | }
48 | }
49 |
50 | export default Span
51 |
--------------------------------------------------------------------------------
/packages/rum/test/node/opentracing-export.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 | const opentracing = require('@elastic/apm-rum/dist/lib/opentracing')
26 | const {
27 | init,
28 | apm,
29 | apmBase,
30 | ApmBase,
31 | createTracer
32 | } = require('@elastic/apm-rum/dist/lib/opentracing')
33 |
34 | describe('opentracing', () => {
35 | it('should have default and named exports', () => {
36 | expect(opentracing.default).toEqual(jasmine.any(Function))
37 | expect(createTracer).toEqual(jasmine.any(Function))
38 | expect(init).toEqual(jasmine.any(Function))
39 | expect(apm).toEqual(jasmine.any(Object))
40 | expect(apmBase).toEqual(jasmine.any(Object))
41 | expect(apmBase.init).toEqual(jasmine.any(Function))
42 | expect(ApmBase).toEqual(jasmine.any(Function))
43 | })
44 | })
45 |
--------------------------------------------------------------------------------
/packages/rum-core/src/common/instrument.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | import {
27 | XMLHTTPREQUEST,
28 | FETCH,
29 | HISTORY,
30 | PAGE_LOAD,
31 | ERROR,
32 | EVENT_TARGET
33 | } from './constants'
34 |
35 | export function getInstrumentationFlags(instrument, disabledInstrumentations) {
36 | /**
37 | * Valid instrumentation flags
38 | */
39 | const flags = {
40 | [XMLHTTPREQUEST]: false,
41 | [FETCH]: false,
42 | [HISTORY]: false,
43 | [PAGE_LOAD]: false,
44 | [ERROR]: false,
45 | [EVENT_TARGET]: false
46 | }
47 |
48 | if (!instrument) {
49 | return flags
50 | }
51 |
52 | Object.keys(flags).forEach(key => {
53 | if (disabledInstrumentations.indexOf(key) === -1) {
54 | flags[key] = true
55 | }
56 | })
57 | return flags
58 | }
59 |
--------------------------------------------------------------------------------
/packages/rum-vue/test/e2e/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | import 'promise-polyfill/src/polyfill'
27 | import { apmBase } from '@elastic/apm-rum'
28 | import { getGlobalConfig } from '../../../../dev-utils/test-config'
29 | import ApmServerMock from '@elastic/apm-rum-core/test/utils/apm-server-mock'
30 |
31 | const globalConfig = getGlobalConfig()
32 |
33 | export function getApmBase() {
34 | console.log('E2E Global Configs', JSON.stringify(globalConfig, null, 2))
35 | const apmServer = apmBase.serviceFactory.getService('ApmServer')
36 | const serverMock = new ApmServerMock(apmServer, globalConfig.useMocks)
37 | apmBase.serviceFactory.instances['ApmServer'] = serverMock
38 | return apmBase
39 | }
40 |
41 | export function getServerUrl() {
42 | return globalConfig.agentConfig.serverUrl
43 | }
44 |
--------------------------------------------------------------------------------
/packages/rum-core/test/fixtures/user-timing-entries.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | export default [
27 | {
28 | duration: 1052.5299999972049,
29 | entryType: 'measure',
30 | name: 'measure_1',
31 | startTime: 0
32 | },
33 | {
34 | duration: 2119.7900000006484,
35 | entryType: 'measure',
36 | name: 'measure_2',
37 | startTime: 0
38 | },
39 | {
40 | duration: 2.4300000004586764,
41 | entryType: 'measure',
42 | name: 'measure_3',
43 | startTime: 1617.57999999827
44 | },
45 | {
46 | duration: 8.760000000620494,
47 | entryType: 'measure',
48 | name: 'measure_4',
49 | startTime: 2110.949999998411
50 | },
51 | {
52 | duration: 100.7900000006484,
53 | entryType: 'measure',
54 | name: 'measure_5',
55 | startTime: 0
56 | }
57 | ]
58 |
--------------------------------------------------------------------------------
/packages/rum/src/opentracing.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | import { init, apm, apmBase, ApmBase } from './index'
27 | import { Tracer } from 'opentracing/lib/tracer'
28 | import { createTracer as createElasticTracer } from '@elastic/apm-rum-core'
29 |
30 | function createTracer(apmBase) {
31 | /**
32 | * If the platform is not supported, return
33 | * the default tracer from OT
34 | */
35 | if (apmBase._disable) {
36 | return new Tracer()
37 | }
38 | return createElasticTracer(apmBase.serviceFactory)
39 | }
40 |
41 | if (typeof window !== 'undefined' && window.elasticApm) {
42 | window.elasticApm.createTracer = createTracer.bind(
43 | window.elasticApm,
44 | window.elasticApm
45 | )
46 | }
47 |
48 | export default createTracer
49 | export { createTracer, init, apm, apmBase, ApmBase }
50 |
--------------------------------------------------------------------------------
/packages/rum-angular/test/index.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | import 'promise-polyfill/src/polyfill'
27 | import { apmBase } from '@elastic/apm-rum'
28 | import { getGlobalConfig } from '../../../dev-utils/test-config'
29 | import ApmServerMock from '../../rum-core/test/utils/apm-server-mock'
30 |
31 | const globalConfig = getGlobalConfig()
32 |
33 | export function initializeApmService(service, config) {
34 | console.log('E2E Global Configs', JSON.stringify(globalConfig, null, 2))
35 | const apmServer = apmBase.serviceFactory.getService('ApmServer')
36 | const { serverUrl } = globalConfig.agentConfig
37 | config.serverUrl = serverUrl
38 | const serverMock = new ApmServerMock(apmServer, globalConfig.useMocks)
39 | apmBase.serviceFactory.instances['ApmServer'] = serverMock
40 |
41 | return service.init(config)
42 | }
43 |
--------------------------------------------------------------------------------
/packages/rum-react/test/e2e/components/func-component.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | import React, { useEffect, useState, Suspense, lazy } from 'react'
27 |
28 | const LazyComponent = lazy(() => import('./lazy-component'))
29 |
30 | export default function FunctionalComponent(props) {
31 | const [count, setCount] = useState(0)
32 |
33 | useEffect(() => {
34 | async function dummyGet() {
35 | try {
36 | await fetch('/test/e2e/data.json')
37 | } catch (_) {
38 | } finally {
39 | setCount(2)
40 | }
41 | }
42 |
43 | dummyGet()
44 | }, [])
45 |
46 | return (
47 |
}>
50 |
51 |
52 |
53 | )
54 | }
55 |
--------------------------------------------------------------------------------
/packages/rum-react/test/e2e/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | import 'promise-polyfill/src/polyfill'
27 | import { apmBase } from '@elastic/apm-rum'
28 | import { getGlobalConfig } from '../../../../dev-utils/test-config'
29 | import ApmServerMock from '../../../rum-core/test/utils/apm-server-mock'
30 |
31 | const globalConfig = getGlobalConfig()
32 |
33 | export default function createApmBase(config) {
34 | console.log('E2E Global Configs', JSON.stringify(globalConfig, null, 2))
35 | const apmServer = apmBase.serviceFactory.getService('ApmServer')
36 | const { serverUrl } = globalConfig.agentConfig
37 | config.serverUrl = serverUrl
38 | const serverMock = new ApmServerMock(apmServer, globalConfig.useMocks)
39 | apmBase.serviceFactory.instances['ApmServer'] = serverMock
40 |
41 | return apmBase.init(config)
42 | }
43 |
--------------------------------------------------------------------------------
/packages/rum-core/test/mock-apm-server.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | import express from 'express'
27 |
28 | const app = express()
29 | var port = 8201
30 |
31 | app.use(function(req, res, next) {
32 | res.header('Access-Control-Allow-Origin', '*')
33 | res.header(
34 | 'Access-Control-Allow-Headers',
35 | 'Origin, X-Requested-With, Content-Type, Accept'
36 | )
37 | next()
38 | })
39 |
40 | app.get('/healthcheck', function(req, res) {
41 | res.send('OK')
42 | })
43 |
44 | function respondSuccess(req, res) {
45 | res.status(202).end()
46 | }
47 |
48 | // app.post('/v1/client-side/*', respondSuccess)
49 | app.post('/v1/client-side/transactions', respondSuccess)
50 | app.post('/v1/client-side/errors', respondSuccess)
51 | app.post('/v1/rum/*', respondSuccess)
52 |
53 | app.listen(port)
54 |
55 | console.log('serving MockApmServer on: ', port)
56 |
--------------------------------------------------------------------------------
/packages/rum-core/test/performance-monitoring/span-base.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | import SpanBase from '../../src/performance-monitoring/span-base'
27 |
28 | describe('SpanBase', function() {
29 | it('should add default name and type for span', () => {
30 | const span = new SpanBase('', undefined)
31 |
32 | expect(span.name).toEqual('Unknown')
33 | expect(span.type).toEqual('custom')
34 | })
35 |
36 | it('should addLabels', function() {
37 | var span = new SpanBase()
38 | span.addLabels({ test: 'passed', 'test.new': 'new' })
39 | expect(span.context).toEqual({
40 | tags: { test: 'passed', test_new: 'new' }
41 | })
42 | })
43 |
44 | it('should addContext', function() {
45 | var span = new SpanBase()
46 | span.addContext({ test: { ctx: 'hamid' } })
47 | expect(span.context).toEqual({ test: { ctx: 'hamid' } })
48 | })
49 | })
50 |
--------------------------------------------------------------------------------
/packages/rum-core/test/benchmarks/breakdown.bench.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 | import { captureBreakdown } from '../../src/performance-monitoring/breakdown'
26 | import Transaction from '../../src/performance-monitoring/transaction'
27 | import { PAGE_LOAD } from '../../src/common/constants'
28 | import { generateTestTransaction } from './'
29 | import { TIMING_LEVEL1_ENTRY } from '../fixtures/navigation-entries'
30 |
31 | suite('CaptureBreakdown', () => {
32 | benchmark('page-load transaction', () => {
33 | const pageLoadTr = new Transaction('/index', PAGE_LOAD, {
34 | startTime: 0,
35 | transactionSampleRate: 1
36 | })
37 | pageLoadTr.end(5000)
38 | captureBreakdown(pageLoadTr, TIMING_LEVEL1_ENTRY)
39 | })
40 |
41 | benchmark('other transaction', () => {
42 | const nonPageLoadTr = generateTestTransaction(10, true)
43 | captureBreakdown(nonPageLoadTr)
44 | })
45 | })
46 |
--------------------------------------------------------------------------------
/packages/rum-react/test/e2e/components/topic-component.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | import React from 'react'
27 |
28 | class TopicComponent extends React.Component {
29 | constructor(props, state) {
30 | super(props, state)
31 | this.state = {
32 | userName: ''
33 | }
34 | }
35 |
36 | componentDidMount() {
37 | this.fetchData()
38 | }
39 |
40 | fetchData() {
41 | var url = '/test/e2e/data.json'
42 | fetch(url)
43 | .then(resp => {
44 | return resp.json()
45 | })
46 | .then(data => {
47 | this.setState({ userName: data.userName })
48 | })
49 | }
50 |
51 | render() {
52 | return (
53 |
54 |
55 | {this.props.match.path}
56 |
57 | {this.state.userName}
58 |
59 | )
60 | }
61 | }
62 |
63 | export default TopicComponent
64 |
--------------------------------------------------------------------------------
/packages/rum/src/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | import {
27 | createServiceFactory,
28 | bootstrap,
29 | isBrowser
30 | } from '@elastic/apm-rum-core'
31 | import ApmBase from './apm-base'
32 |
33 | /**
34 | * Use a single instance of ApmBase across all instance of the agent
35 | * including the instanes used in framework specific integrations
36 | */
37 | function getApmBase() {
38 | if (isBrowser && window.elasticApm) {
39 | return window.elasticApm
40 | }
41 | const enabled = bootstrap()
42 | const serviceFactory = createServiceFactory()
43 | const apmBase = new ApmBase(serviceFactory, !enabled)
44 |
45 | if (isBrowser) {
46 | window.elasticApm = apmBase
47 | }
48 |
49 | return apmBase
50 | }
51 |
52 | const apmBase = getApmBase()
53 |
54 | const init = apmBase.init.bind(apmBase)
55 |
56 | export default init
57 | export { init, apmBase, ApmBase, apmBase as apm }
58 |
--------------------------------------------------------------------------------
/packages/rum-angular/test/e2e/with-router/app/app.routing.module.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | import { NgModule } from '@angular/core'
27 | import { RouterModule, Routes } from '@angular/router'
28 |
29 | import { HomeComponent } from './home.component'
30 | import { PageNotFoundComponent } from './not-found.component'
31 | import { ContactListComponent } from './contact-list.component'
32 | import { ContactDetailComponent } from './contact-detail.component'
33 |
34 | const routes: Routes = [
35 | { path: 'contacts', component: ContactListComponent },
36 | { path: 'contact/:id', component: ContactDetailComponent },
37 | { path: '', redirectTo: 'home', pathMatch: 'full' },
38 | { path: 'home', component: HomeComponent },
39 | { path: '**', component: PageNotFoundComponent }
40 | ]
41 |
42 | @NgModule({
43 | imports: [RouterModule.forRoot(routes)],
44 | exports: [RouterModule]
45 | })
46 | export class AppRoutingModule {}
47 |
--------------------------------------------------------------------------------
/packages/rum-core/src/common/after-frame.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | const RAF_TIMEOUT = 100
27 |
28 | /**
29 | * Schedule a callback to be invoked after the browser paints a new frame.
30 | *
31 | * There are multiple ways to do this like double rAF, MessageChannel, But we
32 | * use the requestAnimationFrame + setTimeout
33 | *
34 | * Also, RAF does not fire if the current tab is not visible, so we schedule a
35 | * timeout in parallel to ensure the callback is invoked
36 | *
37 | * Based on the code from preact!
38 | * https://github.com/preactjs/preact/blob/f6577c495306f1e93174d69bd79f9fb8a418da75/hooks/src/index.js#L285-L297
39 | */
40 | export default function afterFrame(callback) {
41 | const handler = () => {
42 | clearTimeout(timeout)
43 | cancelAnimationFrame(raf)
44 | setTimeout(callback)
45 | }
46 | const timeout = setTimeout(handler, RAF_TIMEOUT)
47 |
48 | const raf = requestAnimationFrame(handler)
49 | }
50 |
--------------------------------------------------------------------------------
/packages/rum/test/benchmarks/config.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | const port = 9000
27 | module.exports = {
28 | scenarios: ['basic', 'heavy'],
29 | runs: 3,
30 | noOfImages: 30,
31 | browserTypes: ['chromium', 'firefox', 'webkit'],
32 | port,
33 | default: {
34 | launchOptions: {
35 | headless: true,
36 | dumpio: true
37 | }
38 | },
39 | chromium: {
40 | /**
41 | * By default the CPU samples are taken at 1000 microseconds, To get
42 | * more samples in each run within page-load event, we have to tune it so that
43 | * number of samples are more than 50 to get clear idea of the overall profile
44 | *
45 | * https://chromedevtools.github.io/devtools-protocol/tot/Profiler#method-setSamplingInterval
46 | */
47 | cpuSamplingInterval: 200,
48 | memorySamplingInterval: 10,
49 | launchOptions: {
50 | headless: true,
51 | args: ['--no-sandbox', '--disable-setuid-sandbox']
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/packages/rum-angular/test/e2e/with-router/app/contact-list.component.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | import { Component, OnInit } from '@angular/core'
27 | import { ContactService } from './contact.service'
28 |
29 | @Component({
30 | selector: 'app-contact-list',
31 | template: `
32 |
33 | Name - {{ contact.name }}
34 | Email - {{ contact.email }}
35 |
36 | Go to details
37 |
38 |
39 | `,
40 | styles: [
41 | `
42 | span {
43 | margin-right: 10px;
44 | }
45 | `
46 | ]
47 | })
48 | export class ContactListComponent implements OnInit {
49 | contacts: any[] = []
50 |
51 | constructor(private contactService: ContactService) {}
52 |
53 | ngOnInit() {
54 | this.contactService.getContacts().subscribe((data: any[]) => {
55 | this.contacts = data
56 | })
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/packages/rum/test/e2e/async-tests/webpack.config.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | const path = require('path')
27 | const HtmlWebpackPlugin = require('html-webpack-plugin')
28 | const { getGlobalConfig } = require('../../../../../dev-utils/test-config')
29 | const {
30 | getWebpackConfig,
31 | BUNDLE_TYPES
32 | } = require('../../../../../dev-utils/build')
33 |
34 | const { serverUrl, mockBackendUrl } = getGlobalConfig().testConfig
35 |
36 | module.exports = {
37 | entry: path.join(__dirname, 'app.js'),
38 | output: {
39 | path: path.resolve(__dirname),
40 | filename: 'app.e2e-bundle.min.js'
41 | },
42 | ...getWebpackConfig(BUNDLE_TYPES.BROWSER_DEV),
43 | plugins: [
44 | new HtmlWebpackPlugin({
45 | template: path.resolve(__dirname, 'index.ejs'),
46 | filename: path.resolve(__dirname, 'async-e2e.html'),
47 | templateParameters: {
48 | serverUrl,
49 | mockBackendUrl
50 | },
51 | inject: false
52 | })
53 | ]
54 | }
55 |
--------------------------------------------------------------------------------
/docs/troubleshooting.asciidoc:
--------------------------------------------------------------------------------
1 | [[troubleshooting]]
2 | == Troubleshooting
3 |
4 | [float]
5 | [[errors-originating-from-agent]]
6 | === Some errors in the application appear to be originating from the agent's JavaScript file
7 | In some cases when you look at the stack trace of an error, it appears to be originating from
8 | the agent's JavaScript file. However, since we need to patch some browser APIs in order to provide
9 | some of the core functionalities of the agent, our JavaScript file appears in the error stack trace.
10 | Often, the error is generated from another part your application, you can follow the stack trace
11 | further to identify the offending code.
12 |
13 |
14 | Of course, there are errors that might have been caused by the agent itself and we appreciate it if
15 | you <>.
16 |
17 |
18 | [float]
19 | [[no-stack-trace-available]]
20 | === No stack trace available in the Span detail view
21 | The RUM JS agent does not support stack traces for spans due to performance concerns related to gathering stack information.
22 |
23 | [float]
24 | [[debugging]]
25 | === Debugging
26 |
27 | In order to debug the agent consider performing the following steps:
28 |
29 | 1. Add `logLevel: 'debug'` to the agent configuration
30 | 2. Reload the application
31 | 3. Wait at least 5 seconds after the page has loaded
32 | 4. Monitor the Console and Network panel in your browsers developer tools
33 |
34 | [float]
35 | [[disable-agent]]
36 | === Disable the Agent
37 |
38 | In the unlikely event the agent causes disruptions to a production application,
39 | you can disable the agent while you troubleshoot.
40 |
41 | To disable the agent, set <> to `false`.
42 |
43 | [float]
44 | [[get-in-touch]]
45 | === Get in touch
46 |
47 | If you have any questions, please create a new topic in the https://discuss.elastic.co/c/apm[Elastic APM discuss forum].
48 |
49 | For bug reports and feature requests, please https://github.com/elastic/apm-agent-rum-js/issues/new[create an issue] on our https://github.com/elastic/apm-agent-rum-js[github repo]
50 | and include as much information as possible. See <> for how to gather debugging information.
51 |
--------------------------------------------------------------------------------
/packages/rum-core/test/benchmarks/compress.bench.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 | import { compressPayload } from '../../src/common/compress'
26 | import { createServiceFactory } from '../../src'
27 | import { generateTestTransaction } from './'
28 |
29 | suite('Compress', () => {
30 | const serviceFactory = createServiceFactory()
31 | const performanceMonitoring = serviceFactory.getService(
32 | 'PerformanceMonitoring'
33 | )
34 | const apmServer = serviceFactory.getService('ApmServer')
35 | const sampledTransactions = Array(10).fill(generateTestTransaction(10, true))
36 |
37 | const transactions = sampledTransactions.map(tr =>
38 | performanceMonitoring.createTransactionDataModel(tr)
39 | )
40 |
41 | const ndjsonPayload = apmServer
42 | .ndjsonTransactions(transactions, true)
43 | .join('')
44 |
45 | benchmark('compress payload', async () => {
46 | await compressPayload(ndjsonPayload, {
47 | 'Content-Type': 'application/x-ndjson'
48 | })
49 | })
50 | })
51 |
--------------------------------------------------------------------------------
/packages/rum/test/e2e/logs-to-dom.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | ;(function() {
27 | function _patchDebugMethods() {
28 | function patch(target, name) {
29 | var orig = target[name]
30 | target[name] = function() {
31 | var debugElement = document.createElement('li')
32 | var logs = [].slice.call(arguments)
33 | debugElement.innerHTML = name + ': ' + JSON.stringify(logs) //.slice(0, 1000)
34 | document.body.appendChild(debugElement)
35 | orig && orig.apply(this, arguments)
36 | }
37 | }
38 | patch(console, 'log')
39 | patch(console, 'info')
40 | patch(console, 'error')
41 | patch(console, 'debug')
42 | patch(console, 'warn')
43 | patch(window, 'onerror')
44 |
45 | // Use this to scroll the logs into the view
46 | // setInterval(function () {
47 | // window.scrollTo(0, document.body.scrollHeight);
48 | // }, 1000)
49 | }
50 |
51 | _patchDebugMethods()
52 | console.log('Patched debug methods!')
53 | })()
54 |
--------------------------------------------------------------------------------
/packages/rum/test/e2e/standalone-html/app.e2e-spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | const { allowSomeBrowserErrors } = require('../../../../../dev-utils/webdriver')
27 |
28 | describe('standalone-html', function() {
29 | it('should run the usecase', function() {
30 | browser.url('/test/e2e/standalone-html/index.html')
31 | browser.waitUntil(
32 | () => {
33 | return $('#test-element').getText() === 'Passed'
34 | },
35 | 10000,
36 | 'expected element #test-element'
37 | )
38 |
39 | return allowSomeBrowserErrors(['timeout test error with a secret'])
40 | })
41 |
42 | it('should run the opentracing use-case', function() {
43 | browser.url('/test/e2e/standalone-html/opentracing.html')
44 | browser.waitUntil(
45 | () => {
46 | return $('#test-element').getText() === 'Passed'
47 | },
48 | 10000,
49 | 'expected element #test-element'
50 | )
51 |
52 | return allowSomeBrowserErrors(['timeout test error with a secret'])
53 | })
54 | })
55 |
--------------------------------------------------------------------------------
/packages/rum/test/e2e/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | /**
27 | * Polyfill the global promise since webdriver
28 | * functions uses promise based API
29 | * ex: browser.execute, browser.executeAsy
30 | */
31 | import 'promise-polyfill/src/polyfill'
32 | import { apmBase } from '../../src'
33 | import { getGlobalConfig } from '../../../../dev-utils/test-config'
34 | import ApmServerMock from '../../../rum-core/test/utils/apm-server-mock'
35 |
36 | const globalConfig = getGlobalConfig()
37 |
38 | function createApmBase(config) {
39 | console.log('E2E Global Configs', JSON.stringify(globalConfig, null, 2))
40 | const apmServer = apmBase.serviceFactory.getService('ApmServer')
41 | const { serverUrl } = globalConfig.agentConfig
42 | if (serverUrl) {
43 | config.serverUrl = serverUrl
44 | }
45 | const serverMock = new ApmServerMock(apmServer, globalConfig.useMocks)
46 | apmBase.serviceFactory.instances['ApmServer'] = serverMock
47 |
48 | return apmBase.init(config)
49 | }
50 |
51 | export default createApmBase
52 |
--------------------------------------------------------------------------------
/packages/rum-core/test/common/history-patch.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | import patchEventHandler from './patch'
27 | import { HISTORY } from '../../src/common/constants'
28 | describe('historyPatch', function() {
29 | var events = []
30 | var cancelFn
31 |
32 | beforeAll(function() {
33 | cancelFn = patchEventHandler.observe(HISTORY, function(event, task) {
34 | events.push({
35 | event,
36 | task
37 | })
38 | })
39 | })
40 |
41 | afterAll(function() {
42 | cancelFn()
43 | })
44 |
45 | beforeEach(function() {
46 | events = []
47 | })
48 |
49 | it('should patch history.pushState', function() {
50 | history.pushState(undefined, 'test', 'test')
51 |
52 | expect(events).toEqual([
53 | {
54 | event: 'invoke',
55 | task: {
56 | source: HISTORY,
57 | data: {
58 | state: undefined,
59 | title: 'test',
60 | url: 'test'
61 | }
62 | }
63 | }
64 | ])
65 | })
66 | })
67 |
--------------------------------------------------------------------------------
/packages/rum-react/test/e2e/components/manual-component.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | import React from 'react'
27 | import { withTransaction } from '../../../src'
28 |
29 | class ManualComponent extends React.Component {
30 | constructor(props, state) {
31 | super(props, state)
32 | this.state = {
33 | userName: ''
34 | }
35 | }
36 |
37 | componentDidMount() {
38 | this.fetchData()
39 | if (typeof performance.measure === 'function') {
40 | performance.measure('manual-component-mounted', 'manual-component-start')
41 | }
42 | }
43 |
44 | fetchData() {
45 | const url = '/test/e2e/data.json'
46 | fetch(url)
47 | .then(resp => {
48 | return resp.json()
49 | })
50 | .then(data => {
51 | this.setState({ userName: data.userName })
52 | })
53 | }
54 |
55 | render() {
56 | return
Manual {this.state.userName}
57 | }
58 | }
59 |
60 | export default withTransaction('ManualComponent', 'component')(ManualComponent)
61 |
--------------------------------------------------------------------------------
/packages/rum-vue/src/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | import { apmBase } from '@elastic/apm-rum'
27 | import { routeHooks } from './route-hooks'
28 | import { getErrorHandler } from './error-handler'
29 |
30 | export const ApmVuePlugin = {
31 | install: (Vue, options) => {
32 | const { router, apm = apmBase, config, captureErrors = true } = options
33 | /**
34 | * Initialize the APM with the config
35 | */
36 | apm.init(config)
37 |
38 | if (apm.isActive()) {
39 | /**
40 | * Hook router if provided
41 | */
42 | if (router) {
43 | routeHooks(router, apm)
44 | }
45 |
46 | if (captureErrors) {
47 | /**
48 | * Global error handler for capturing errors during
49 | * component renders
50 | */
51 | Vue.config.errorHandler = getErrorHandler(Vue, apm)
52 | }
53 | }
54 | /**
55 | * Provide the APM instance via $apm to be accessed in all Vue Components
56 | */
57 | Vue.prototype.$apm = apm
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/packages/rum-core/src/common/queue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | class Queue {
27 | constructor(onFlush, opts = {}) {
28 | this.onFlush = onFlush
29 | this.items = []
30 | this.queueLimit = opts.queueLimit || -1
31 | this.flushInterval = opts.flushInterval || 0
32 | this.timeoutId = undefined
33 | }
34 |
35 | _setTimer() {
36 | this.timeoutId = setTimeout(() => this.flush(), this.flushInterval)
37 | }
38 |
39 | _clear() {
40 | if (typeof this.timeoutId !== 'undefined') {
41 | clearTimeout(this.timeoutId)
42 | this.timeoutId = undefined
43 | }
44 | this.items = []
45 | }
46 |
47 | flush() {
48 | this.onFlush(this.items)
49 | this._clear()
50 | }
51 |
52 | add(item) {
53 | this.items.push(item)
54 | if (this.queueLimit !== -1 && this.items.length >= this.queueLimit) {
55 | this.flush()
56 | } else {
57 | if (typeof this.timeoutId === 'undefined') {
58 | this._setTimer()
59 | }
60 | }
61 | }
62 | }
63 |
64 | export default Queue
65 |
--------------------------------------------------------------------------------
/packages/rum/test/node/index-export.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | const elasticApm = require('@elastic/apm-rum')
27 | const { init: namedInit, apm, apmBase, ApmBase } = require('@elastic/apm-rum')
28 |
29 | describe('apm base', () => {
30 | it('should have default and named exports', () => {
31 | expect(elasticApm.init).toEqual(jasmine.any(Function))
32 | expect(namedInit).toEqual(jasmine.any(Function))
33 | expect(apm).toEqual(jasmine.any(Object))
34 | expect(apmBase).toEqual(jasmine.any(Object))
35 | expect(apmBase.init).toEqual(jasmine.any(Function))
36 | expect(ApmBase).toEqual(jasmine.any(Function))
37 | })
38 |
39 | it('should not log platform message on Node.js', () => {
40 | spyOn(console, 'log')
41 | /**
42 | * Delete module cache and run bootstrap again
43 | */
44 | let cache = require.cache
45 | for (let moduleId in cache) {
46 | delete cache[moduleId]
47 | }
48 | require('@elastic/apm-rum')
49 |
50 | expect(console.log).not.toHaveBeenCalled()
51 | })
52 | })
53 |
--------------------------------------------------------------------------------
/scripts/eslint-rules/version-checker.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | const { version: agentVersion } = require('@elastic/apm-rum/package.json')
27 |
28 | module.exports = context => {
29 | return {
30 | MemberExpression(node) {
31 | const { name, type } = node.property
32 | if (type === 'Identifier' && name === 'setVersion') {
33 | const args = node.parent.arguments
34 | if (args.length > 0 && args[0].type === 'Literal') {
35 | const literalNode = args[0]
36 | const version = literalNode.value
37 | if (version !== agentVersion) {
38 | context.report({
39 | node: literalNode,
40 | message: `Agent version: ${agentVersion} should match with build version: ${version}`,
41 | fix(fixer) {
42 | return fixer.replaceTextRange(
43 | literalNode.range,
44 | "'" + agentVersion + "'"
45 | )
46 | }
47 | })
48 | }
49 | }
50 | }
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/packages/rum-core/test/benchmarks/capture-navigation.bench.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 | import { captureNavigation } from '../../src/performance-monitoring/capture-navigation'
26 | import Transaction from '../../src/performance-monitoring/transaction'
27 | import { PAGE_LOAD, ROUTE_CHANGE } from '../../src/common/constants'
28 |
29 | suite('CaptureNavigation', () => {
30 | const options = {
31 | startTime: 0,
32 | transactionSampleRate: 1
33 | }
34 | const endTime = 10000
35 |
36 | benchmark('hard navigation', () => {
37 | const pageLoadTr = new Transaction('/index', PAGE_LOAD, options)
38 | pageLoadTr.captureTimings = true
39 | pageLoadTr.end(endTime)
40 | captureNavigation(pageLoadTr)
41 | })
42 |
43 | benchmark('soft navigation', () => {
44 | /**
45 | * Does not include navigation timing spans and agent marks
46 | */
47 | const nonPageLoadTr = new Transaction('/index', ROUTE_CHANGE, options)
48 | nonPageLoadTr.captureTimings = true
49 | nonPageLoadTr.end(endTime)
50 | captureNavigation(nonPageLoadTr)
51 | })
52 | })
53 |
--------------------------------------------------------------------------------
/packages/rum-core/src/bootstrap.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | import { isPlatformSupported, isBrowser, now } from './common/utils'
27 | import { patchAll } from './common/patching'
28 | import { state } from './state'
29 |
30 | let enabled = false
31 | export function bootstrap() {
32 | if (isPlatformSupported()) {
33 | patchAll()
34 | bootstrapPerf()
35 | state.bootstrapTime = now()
36 | enabled = true
37 | } else if (isBrowser) {
38 | /**
39 | * Print this error message only on the browser console
40 | * on unsupported browser versions
41 | */
42 | console.log('[Elastic APM] platform is not supported!')
43 | }
44 |
45 | return enabled
46 | }
47 |
48 | export function bootstrapPerf() {
49 | if (document.visibilityState === 'hidden') {
50 | state.lastHiddenStart = 0
51 | }
52 |
53 | window.addEventListener(
54 | 'visibilitychange',
55 | () => {
56 | if (document.visibilityState === 'hidden') {
57 | state.lastHiddenStart = performance.now()
58 | }
59 | },
60 | { capture: true }
61 | )
62 | }
63 |
--------------------------------------------------------------------------------
/packages/rum-angular/test/polyfills.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | /**
27 | * Polyfills required for Angular to work on all browsers
28 | * https://angular.io/guide/browser-support#polyfills-for-non-cli-users
29 | */
30 |
31 | /*
32 | * IE9, IE10 and IE11 requires all of the following polyfills.
33 | */
34 | import 'core-js/features/symbol'
35 | import 'core-js/features/object'
36 | import 'core-js/features/function'
37 | import 'core-js/features/parse-int'
38 | import 'core-js/features/parse-float'
39 | import 'core-js/features/number'
40 | import 'core-js/features/math'
41 | import 'core-js/features/string'
42 | import 'core-js/features/date'
43 | import 'core-js/features/array'
44 | import 'core-js/features/regexp'
45 | import 'core-js/features/map'
46 | import 'core-js/features/weak-map'
47 | import 'core-js/features/set'
48 | import 'core-js/features/reflect'
49 |
50 | /*
51 | * Evergreen browsers require these
52 | */
53 | import 'core-js/proposals/reflect-metadata'
54 |
55 | /*
56 | * Zone JS is required by default for Angular itself.
57 | */
58 | import 'zone.js/dist/zone'
59 |
--------------------------------------------------------------------------------
/docs/performance-tuning.asciidoc:
--------------------------------------------------------------------------------
1 | [[performance-tuning]]
2 | == Performance Tuning
3 |
4 | There are different ways to optimize/tune the performance of the RUM agent.
5 | Which options to adjust depends on whether you are optimizing for speed, memory
6 | usage, bandwidth or storage.
7 |
8 |
9 | [float]
10 | [[performance-sampling]]
11 | === Sampling
12 |
13 | The first knob to reach for when tuning the performance of the agent is <>.
14 | Adjusting the sampling rate controls what ratio of requests are traced.
15 | By default, the sample rate is set at `1.0`, meaning _all_ requests are traced
16 | and sent to the APM server.
17 |
18 | The sample rate will impact all four performance categories,
19 | so simply turning down the sample rate is an easy way to improve performance.
20 |
21 | Here's an example of setting the sample rate to 20%:
22 |
23 | [source,js]
24 | ----
25 | import { apm } from "@elastic/apm-rum"
26 |
27 | apm.init({
28 | transactionSampleRate: 0.2
29 | })
30 | ----
31 |
32 | The Agent will still record the overall duration and result of unsampled
33 | transactions, but will discard associated spans, context information or labels
34 | before sending to the APM server.
35 |
36 | [float]
37 | [[performance-breakdown-metrics]]
38 | === Breakdown Metrics
39 |
40 | Breakdown metrics help visualize where your application is spending the majority of
41 | its time. The <> config controls whether metrics
42 | should be calculated for each transaction based on its corresponding type.
43 |
44 | Setting this to `true` will increase the payload/bandwidth usage data to
45 | the APM server.
46 |
47 |
48 | [float]
49 | [[performance-central-config]]
50 | === APM Agent Configuration
51 |
52 | Activate agent configuration via Kibana to start fetching new configuration
53 | changes from the APM server during the agent initialization phase.
54 |
55 | Setting the config option <> to `true`
56 | incurs the cost of one additional HTTP request when the agent is
57 | initialized and generates more load to the APM server. As a result,
58 | central configuration is disabled by default in RUM agent.
59 |
60 | It is recommended to disable this configuration when the instrumented
61 | application is under heavy load.
62 |
63 |
--------------------------------------------------------------------------------
/packages/rum-angular/test/e2e/with-router/app/contact-detail.component.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | import { Component, OnInit } from '@angular/core'
27 | import { ActivatedRoute } from '@angular/router'
28 | import { ContactService } from './contact.service'
29 |
30 | @Component({
31 | selector: 'app-contact-detail',
32 | template: `
33 |
34 |
Contact # {{ contact.id }}
35 |
Name: {{ contact.name }}
36 |
Email: {{ contact.email }}
37 |
38 | `
39 | })
40 | export class ContactDetailComponent implements OnInit {
41 | contact: any
42 | isDataAvailable = false
43 |
44 | constructor(
45 | private contactService: ContactService,
46 | private route: ActivatedRoute
47 | ) {}
48 |
49 | ngOnInit() {
50 | this.route.paramMap.subscribe(params => {
51 | const contactId = Number(params.get('id'))
52 | this.contactService.getContacts().subscribe((contacts: any[]) => {
53 | this.contact = contacts.filter(({ id }) => id === contactId)[0]
54 | this.isDataAvailable = true
55 | })
56 | })
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/dev-utils/jasmine.js:
--------------------------------------------------------------------------------
1 | /**
2 | * MIT License
3 | *
4 | * Copyright (c) 2017-present, Elasticsearch BV
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | *
24 | */
25 |
26 | /**
27 | * waitfor a specific number of cycles
28 | * @param {*} conditionFn
29 | * @param {*} count
30 | * @param {*} message
31 | */
32 | export function waitFor(
33 | conditionFn,
34 | count = 1,
35 | message = 'Waiting for condition exceeded allowed cycles.'
36 | ) {
37 | const checkCondition = (resolve, reject) => {
38 | if (count >= 0) {
39 | count--
40 | if (conditionFn(count)) {
41 | resolve()
42 | } else {
43 | setTimeout(() => checkCondition(resolve, reject))
44 | }
45 | } else {
46 | reject(message)
47 | }
48 | }
49 |
50 | return new Promise(checkCondition)
51 | }
52 |
53 | /**
54 | * Conditional describe
55 | * @param {*} description
56 | * @param {*} specDefinitions
57 | * @param {*} condition
58 | */
59 | export function describeIf(description, specDefinitions, condition) {
60 | let describeFn = describe
61 | if (arguments.length > 2) {
62 | if (!condition) {
63 | describeFn = xdescribe
64 | }
65 | }
66 |
67 | return describeFn.apply(this, [description, specDefinitions])
68 | }
69 |
--------------------------------------------------------------------------------