13 |
14 |
--------------------------------------------------------------------------------
/docs/reference/advanced-topics.md:
--------------------------------------------------------------------------------
1 | ---
2 | mapped_pages:
3 | - https://www.elastic.co/guide/en/apm/agent/rum-js/current/advanced-topics.html
4 | applies_to:
5 | stack:
6 | serverless: unavailable
7 | product:
8 | apm_agent_rum: ga
9 | ---
10 |
11 | # Advanced topics [advanced-topics]
12 |
13 | * [How to interpret long task spans in the UI](/reference/longtasks.md)
14 | * [Using with TypeScript](/reference/typescript.md)
15 | * [Initial Page load transaction names](/reference/custom-transaction-name.md)
16 | * [Custom Transactions](/reference/custom-transactions.md)
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/docs/reference/typescript.md:
--------------------------------------------------------------------------------
1 | ---
2 | mapped_pages:
3 | - https://www.elastic.co/guide/en/apm/agent/rum-js/current/typescript.html
4 | applies_to:
5 | stack:
6 | serverless: unavailable
7 | product:
8 | apm_agent_rum: ga
9 | ---
10 |
11 | # Using with TypeScript [typescript]
12 |
13 | RUM agent publishes the type definitions for the `@elastic/apm-rum` package via `types` property in `package.json`. If you are importing the package on a TypeScript codebase, you will get automatic code completion, hover info and method signature information on supported platforms (Visual Studio Code, etc)
14 |
15 |
--------------------------------------------------------------------------------
/dev-utils/elasticsearch/users:
--------------------------------------------------------------------------------
1 | admin:$2a$10$xiY0ZzOKmDDN1p3if4t4muUBwh2.bFHADoMRAWQgSClm4ZJ4132Y.
2 | apm_server_user:$2a$10$iTy29qZaCSVn4FXlIjertuO8YfYVLCbvoUAJ3idaXfLRclg9GXdGG
3 | apm_user_ro:$2a$10$hQfy2o2u33SapUClsx8NCuRMpQyHP9b2l4t3QqrBA.5xXN2S.nT4u
4 | beats_user:$2a$10$LRpKi4/Q3Qo4oIbiu26rH.FNIL4aOH4aj2Kwi58FkMo1z9FgJONn2
5 | filebeat_user:$2a$10$sFxIEX8tKyOYgsbJLbUhTup76ssvSD3L4T0H6Raaxg4ewuNr.lUFC
6 | heartbeat_user:$2a$10$nKUGDr/V5ClfliglJhfy8.oEkjrDtklGQfhd9r9NoFqQeoNxr7uUK
7 | kibana_system_user:$2a$10$nN6sRtQl2KX9Gn8kV/.NpOLSk6Jwn8TehEDnZ7aaAgzyl/dy5PYzW
8 | metricbeat_user:$2a$10$5PyTd121U2ZXnFk9NyqxPuLxdptKbB8nK5egt6M5/4xrKUkk.GReG
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/lerna.json:
--------------------------------------------------------------------------------
1 | {
2 | "packages": [
3 | "packages/*"
4 | ],
5 | "version": "independent",
6 | "registry": "https://registry.npmjs.org",
7 | "command": {
8 | "version": {
9 | "allowBranch": ["main", "4.x", "release", "prerelease/*"],
10 | "conventionalCommits": true,
11 | "message": "chore(release): publish",
12 | "changelogPreset": "conventionalcommits",
13 | "gitRemote": "origin",
14 | "loglevel": "verbose"
15 | },
16 | "run": {
17 | "stream": true
18 | },
19 | "publish": {
20 | "loglevel": "verbose"
21 | }
22 | },
23 | "ignoreChanges": [
24 | "**/*.md",
25 | "**/test/**",
26 | "docs"
27 | ]
28 | }
29 |
--------------------------------------------------------------------------------
/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=8.19.6 APM_SERVER_PORT=8001 docker compose up apm-server
3 | #STACK_VERSION=8.19.6 docker compose -f ./test/docker compose.yml start apm-server
4 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/.github/workflows/ci-docs.yml:
--------------------------------------------------------------------------------
1 | ---
2 | # This workflow sets the test / all status check to success in case it's a docs only PR and ci.yml is not triggered
3 | # https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks#handling-skipped-but-required-checks
4 | name: ci # The name must be the same as ci.yml
5 |
6 | on:
7 | pull_request:
8 | paths-ignore: # This expression needs to match the paths ignored on ci.yml.
9 | - '**'
10 | - '!**/*.md'
11 | - '!**/*.asciidoc'
12 |
13 | permissions:
14 | contents: read
15 |
16 | jobs:
17 | all:
18 | runs-on: ubuntu-latest
19 | steps:
20 | - run: 'echo "No build required"'
21 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/packages/rum-angular/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compileOnSave": false,
3 | "compilerOptions": {
4 | "baseUrl": "./",
5 | "outDir": "./dist/out-tsc",
6 | "sourceMap": true,
7 | "declaration": false,
8 | "downlevelIteration": true,
9 | "experimentalDecorators": true,
10 | "module": "esnext",
11 | "moduleResolution": "node",
12 | "importHelpers": true,
13 | "target": "es2015",
14 | "lib": ["es2018", "dom"],
15 | "paths": {
16 | "@elastic/apm-rum-core": ["../rum-core/dist/es"],
17 | "@elastic/apm-rum": ["../rum/src/dist/es"],
18 | "@elastic/apm-rum-angular": ["src"]
19 | }
20 | },
21 | "angularCompilerOptions": {
22 | "fullTemplateTypeCheck": true,
23 | "strictInjectionParameters": true
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/scripts/ci-bundlesize.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | # Bash strict mode
4 | set -eo pipefail
5 | trap 's=$?; echo >&2 "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $s' ERR
6 |
7 | # Create a tmp dir
8 | WORKSPACE=$(mktemp -d)
9 | BUNDLESIZE_PATH="${WORKSPACE}/bundlesize.txt"
10 |
11 | # Execute bundlesize
12 | npm run bundlesize | tee "${BUNDLESIZE_PATH}" || true
13 |
14 | # Extract passed and failed
15 | BUNDLESIZE_PASS=$(grep "✔" "${BUNDLESIZE_PATH}" | wc -l) || true
16 | BUNDLESIZE_FAIL=$(grep "✖" "${BUNDLESIZE_PATH}" | wc -l) || true
17 | if [ ! -z "${GITHUB_OUTPUT}" ]; then
18 | echo "bundlesize_pass=${BUNDLESIZE_PASS}" >> "${GITHUB_OUTPUT}"
19 | echo "bundlesize_fail=${BUNDLESIZE_FAIL}" >> "${GITHUB_OUTPUT}"
20 | fi
21 |
22 | # Cleanup
23 | rm -rf "${WORKSPACE}"
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 |
--------------------------------------------------------------------------------
/docs/reference/set-up-apm-real-user-monitoring-javascript-agent.md:
--------------------------------------------------------------------------------
1 | ---
2 | mapped_pages:
3 | - https://www.elastic.co/guide/en/apm/agent/rum-js/current/getting-started.html
4 | applies_to:
5 | stack:
6 | serverless: unavailable
7 | product:
8 | apm_agent_rum: ga
9 | ---
10 |
11 | # Set up the APM Real User Monitoring JavaScript Agent [getting-started]
12 |
13 | To start reporting your web page performance to Elastic APM, you must first [enable the RUM endpoint](docs-content://solutions/observability/apm/configure-real-user-monitoring-rum.md) in your `apm-server` configuration.
14 |
15 | Once the APM Server endpoint has been configured, you can:
16 |
17 | * [Install the Agent](/reference/install-agent.md)
18 | * [Configure CORS](/reference/configuring-cors.md)
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.github/workflows/test-reporter.yml:
--------------------------------------------------------------------------------
1 | ---
2 | ## Workflow to process the JUnit test results and add a report to the checks.
3 | name: test-reporter
4 | on:
5 | workflow_run:
6 | workflows:
7 | - ci
8 | types:
9 | - completed
10 |
11 | permissions:
12 | contents: read
13 | actions: read
14 | checks: write
15 |
16 | jobs:
17 | report:
18 | runs-on: ubuntu-latest
19 | steps:
20 | - uses: elastic/oblt-actions/test-report@v1
21 | with:
22 | artifact: /test-results(.*)/ # artifact name pattern
23 | name: 'Test Report $1' # Name of the check run which will be created
24 | path: "**/*.xml" # Path to test results (inside artifact .zip)
25 | reporter: java-junit # Format of test results
26 |
--------------------------------------------------------------------------------
/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/load-testing.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | STACK_VERSION=${1:-8.19.6}
4 | USER_ID="$(id -u):$(id -g)"
5 | # The migration of this to Node.js 18 will wait. To update playwright (and browsers)
6 | # to make it work in Node.js 18 and latest version in ubuntu (or another OS)
7 | # will require us to invest a certain amount of time
8 | NODEJS_VERSION=14
9 |
10 | USER_ID="${USER_ID}" \
11 | NODEJS_VERSION="${NODEJS_VERSION}" \
12 | STACK_VERSION=${STACK_VERSION} \
13 | docker-compose -f ./dev-utils/docker-compose.yml down \
14 | --remove-orphans \
15 | --volumes || true
16 |
17 | USER_ID="${USER_ID}" \
18 | NODEJS_VERSION="${NODEJS_VERSION}" \
19 | STACK_VERSION=${STACK_VERSION} \
20 | docker-compose -f ./dev-utils/docker-compose.yml up \
21 | --build \
22 | --exit-code-from load-testing \
23 | load-testing
24 |
--------------------------------------------------------------------------------
/scripts/lint-commits.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | set -xeo pipefail
3 |
4 | # Run if we're not on CI
5 | if [[ -z "${CI}" ]]; then
6 | export PATH=$(npm bin):${PATH}
7 | export HOME=$(pwd)
8 | if [[ -z "${CHANGE_ID}" ]]; then
9 | # If on main, 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 main
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 |
--------------------------------------------------------------------------------
/.ci/scripts/benchmarks.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | USER_ID="$(id -u):$(id -g)"
4 | # The migration of this to Node.js 18 will wait. To update playwright (and browsers)
5 | # to make it work in Node.js 18 and latest version in ubuntu (or another OS)
6 | # will require us to invest a certain amount of time
7 | NODEJS_VERSION=14
8 |
9 | # Ensure local bin is in PATH, needed for updated docker-compose, see https://github.com/elastic/observability-robots/issues/2960
10 | export PATH="$HOME/.local/bin:$PATH"
11 |
12 | USER_ID="${USER_ID}" \
13 | NODEJS_VERSION="${NODEJS_VERSION}" \
14 | docker-compose -f ./dev-utils/docker-compose.yml down \
15 | --remove-orphans \
16 | --volumes || true
17 |
18 | USER_ID="${USER_ID}" \
19 | NODEJS_VERSION="${NODEJS_VERSION}" \
20 | docker-compose -f ./dev-utils/docker-compose.yml up \
21 | --build \
22 | --abort-on-container-exit \
23 | --exit-code-from node-benchmark \
24 | --remove-orphans \
25 | node-benchmark
26 |
--------------------------------------------------------------------------------
/.ci/scripts/pull_and_build.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | export NODEJS_VERSION=$(cat .nvmrc)
3 | export STACK_VERSION=${STACK_VERSION:-8.19.6}
4 |
5 | STACK_VERSION=${STACK_VERSION} \
6 | docker --log-level INFO compose -f ./dev-utils/docker-compose.yml pull --quiet --ignore-pull-failures
7 |
8 | # We are building the images here even though the Docker images are already cached in Packer.
9 | # This is because there could be changes in the PR affecting the files copied to the Docker image,
10 | # which we want to test in the current build.
11 | NODEJS_VERSION="${NODEJS_VERSION}" \
12 | STACK_VERSION=${STACK_VERSION} \
13 | docker --log-level INFO compose -f ./dev-utils/docker-compose.yml build >docker-compose.log 2>docker-compose.err
14 | if [ $? -gt 0 ] ; then
15 | echo "Docker compose failed, see the below log output"
16 | cat docker-compose.log && rm docker-compose.log
17 | cat docker-compose.err && rm docker-compose.err
18 | exit 1
19 | else
20 | rm docker-compose.log docker-compose.err
21 | fi
22 |
--------------------------------------------------------------------------------
/docs/release-notes/known-issues.md:
--------------------------------------------------------------------------------
1 | ---
2 | navigation_title: "Known issues"
3 | applies_to:
4 | stack:
5 | serverless: unavailable
6 | product:
7 | apm_agent_rum: ga
8 | ---
9 | # Elastic APM Real User Monitoring JavaScript Agent known issues [elastic-apm-rum-javascript-agent-known-issues]
10 |
11 | Known issues are significant defects or limitations that may impact your implementation. These issues are actively being worked on and will be addressed in a future release. Review the Elastic APM Real User Monitoring JavaScript Agent known issues to help you make informed decisions, such as upgrading to a new version.
12 |
13 | % Use the following template to add entries to this page.
14 |
15 | % :::{dropdown} Title of known issue
16 | % **Details**
17 | % On [Month/Day/Year], a known issue was discovered that [description of known issue].
18 |
19 | % **Workaround**
20 | % Workaround description.
21 |
22 | % **Resolved**
23 | % On [Month/Day/Year], this issue was resolved.
24 |
25 | :::
26 |
27 | _No known issues_
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/docs/reference/api-reference.md:
--------------------------------------------------------------------------------
1 | ---
2 | mapped_pages:
3 | - https://www.elastic.co/guide/en/apm/agent/rum-js/current/api.html
4 | applies_to:
5 | stack:
6 | serverless: unavailable
7 | product:
8 | apm_agent_rum: ga
9 | ---
10 |
11 | # API reference [api]
12 |
13 | The API reference documentation is divided into three parts:
14 |
15 | * [The `Agent` API](/reference/agent-api.md) - All functions and properties on the `Agent` object. 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. The `Agent` instance is usually referred to by the variable `apm` in this documentation.
16 | * [The `Transaction` API](/reference/transaction-api.md) - All functions and properties on the `Transaction` object. An instance of the `Transaction` object is acquired by calling `apm.startTransaction()`.
17 | * [The `Span` API](/reference/span-api.md) - All functions and properties on the `Span` object. An instance of the `Span` object is acquired by calling `apm.startSpan()`.
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Elastic APM Real User Monitoring (RUM) JavaScript agent
2 |
3 | [](https://github.com/elastic/apm-agent-rum-js/actions/workflows/ci.yml)
4 | [](https://github.com/feross/standard)
5 | [](https://codecov.io/gh/elastic/apm-agent-rum-js)
6 | [](https://lernajs.io/)
7 |
8 | This is the official Real User Monitoring JavaScript agent.
9 |
10 | ## Documentation
11 | You can find our documentation [on our website](https://www.elastic.co/guide/en/apm/agent/rum-js/current/index.html).
12 |
13 | If you are interested in contributing to Elastic APM JavaScript agent, please see [our contributing guide](CONTRIBUTING.md).
14 |
15 | We'd love to hear your feedback, please take a minute to fill out our [survey](https://goo.gl/forms/nLCXGCvziqalzjlP2).
16 |
17 | ## License
18 | This project is [MIT licensed](LICENSE).
19 |
20 | Made with ♥️ and ☕️ by Elastic and our community.
21 |
--------------------------------------------------------------------------------
/docs/reference/toc.yml:
--------------------------------------------------------------------------------
1 | project: 'APM Real User Monitoring (RUM) JavaScript Agent reference'
2 | toc:
3 | - file: index.md
4 | - file: set-up-apm-real-user-monitoring-javascript-agent.md
5 | children:
6 | - file: install-agent.md
7 | - file: configuring-cors.md
8 | - file: supported-technologies.md
9 | - file: configuration.md
10 | - file: api-reference.md
11 | children:
12 | - file: agent-api.md
13 | - file: transaction-api.md
14 | - file: span-api.md
15 | - file: source-maps.md
16 | - file: framework-specific-integrations.md
17 | children:
18 | - file: react-integration.md
19 | - file: angular-integration.md
20 | - file: vue-integration.md
21 | - file: distributed-tracing.md
22 | - file: breakdown-metrics.md
23 | - file: opentracing.md
24 | - file: advanced-topics.md
25 | children:
26 | - file: longtasks.md
27 | - file: typescript.md
28 | - file: custom-transaction-name.md
29 | - file: custom-transactions.md
30 | - file: performance-tuning.md
31 | - file: upgrading.md
32 | - title: Troubleshooting
33 | crosslink: docs-content://troubleshoot/observability/apm-agent-rum-js/apm-real-user-monitoring-javascript-agent.md
--------------------------------------------------------------------------------
/dev-utils/elasticsearch/roles.yml:
--------------------------------------------------------------------------------
1 | apm_server:
2 | cluster: ['manage_ilm', 'manage_security', 'manage_api_key']
3 | indices:
4 | - names: ['apm-*', 'traces-apm*', 'logs-apm*', 'metrics-apm*']
5 | privileges: ['write', 'create_index', 'manage', 'manage_ilm']
6 | applications:
7 | - application: 'apm'
8 | privileges: ['sourcemap:write', 'event:write', 'config_agent:read']
9 | resources: '*'
10 | beats:
11 | cluster: ['manage_index_templates', 'monitor', 'manage_ingest_pipelines', 'manage_ilm', 'manage_security', 'manage_api_key']
12 | indices:
13 | - names: ['filebeat-*', 'shrink-filebeat-*']
14 | privileges: ['all']
15 | filebeat:
16 | cluster: ['manage_index_templates', 'monitor', 'manage_ingest_pipelines', 'manage_ilm']
17 | indices:
18 | - names: ['filebeat-*', 'shrink-filebeat-*']
19 | privileges: ['all']
20 | heartbeat:
21 | cluster: ['manage_index_templates', 'monitor', 'manage_ingest_pipelines', 'manage_ilm']
22 | indices:
23 | - names: ['heartbeat-*', 'shrink-heartbeat-*']
24 | privileges: ['all']
25 | metricbeat:
26 | cluster: ['manage_index_templates', 'monitor', 'manage_ingest_pipelines', 'manage_ilm']
27 | indices:
28 | - names: ['metricbeat-*', 'shrink-metricbeat-*']
29 | privileges: ['all']
--------------------------------------------------------------------------------
/.ci/scripts/test.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | set -xo pipefail
3 |
4 | STACK_VERSION=${STACK_VERSION:-"8.19.6"}
5 | APM_SERVER_PORT=${APM_SERVER_PORT:-"8200"}
6 | APM_SERVER_URL=${APM_SERVER_URL:-"http://apm-server:8200"}
7 | KIBANA_URL=${KIBANA_URL:-"http://kibana:5601"}
8 |
9 | # Tests are run within the node-puppeteer container and can fails.
10 | # To avoid flakiness, we retry up to 3 times to run them.
11 | for i in {1..3};
12 | do
13 | USER_ID="$(id -u):$(id -g)" \
14 | NODEJS_VERSION=$(cat .nvmrc) \
15 | STACK_VERSION=${STACK_VERSION} \
16 | APM_SERVER_PORT=${APM_SERVER_PORT} \
17 | APM_SERVER_URL=${APM_SERVER_URL} \
18 | KIBANA_URL=${KIBANA_URL} \
19 | docker --log-level INFO compose \
20 | -f ./dev-utils/docker-compose.yml \
21 | up \
22 | --quiet-pull \
23 | --exit-code-from node-puppeteer \
24 | --remove-orphans \
25 | node-puppeteer \
26 | >docker-compose.log 2>docker-compose.err;
27 | status=${?}
28 | if [ "${status}" -eq "0" ]; then
29 | break
30 | else
31 | echo "Docker compose failed, see the below log output"
32 | cat docker-compose.log && rm docker-compose.log
33 | cat docker-compose.err && rm docker-compose.err
34 | fi
35 | sleep 5;
36 | done
37 | echo "Exit code from docker compose ${status}"
38 | exit ${status}
39 |
--------------------------------------------------------------------------------
/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 | export * from './apm.module'
27 | export * from './apm.service'
28 | export * from './error-handler'
29 |
--------------------------------------------------------------------------------
/.github/workflows/bump-elastic-stack.yml:
--------------------------------------------------------------------------------
1 | ---
2 | name: bump-elastic-stack
3 |
4 | on:
5 | workflow_dispatch:
6 | schedule:
7 | - cron: '0 15 * * 1-5'
8 |
9 | permissions:
10 | contents: read
11 |
12 | jobs:
13 | bump:
14 | runs-on: ubuntu-latest
15 | steps:
16 |
17 | - uses: actions/checkout@v6
18 |
19 | - name: Get token
20 | id: get_token
21 | uses: actions/create-github-app-token@v2
22 | with:
23 | app-id: ${{ secrets.OBS_AUTOMATION_APP_ID }}
24 | private-key: ${{ secrets.OBS_AUTOMATION_APP_PEM }}
25 | permission-contents: write
26 | permission-pull-requests: write
27 | permission-workflows: write
28 |
29 | - uses: elastic/oblt-actions/updatecli/run@v1
30 | with:
31 | command: "--experimental apply --config .ci/bump-elastic-stack.yml"
32 | env:
33 | GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}
34 |
35 | - if: failure()
36 | uses: elastic/oblt-actions/slack/send@v1
37 | with:
38 | bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
39 | channel-id: "#apm-agent-js"
40 | message: ":traffic_cone: updatecli failed for `${{ github.repository }}@${{ github.ref_name }}`, @robots-ci please look what's going on "
41 |
--------------------------------------------------------------------------------
/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-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-angular/test/e2e/with-router/environments/environment.prod.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 | export const environment = {
27 | production: true,
28 | serverUrl: 'http://apm-server:8200'
29 | }
30 |
--------------------------------------------------------------------------------
/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-react/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 | * - Symbol is used by Cheerio, which is an Enzyme dependency
29 | */
30 |
31 | import 'core-js/es/symbol'
32 |
--------------------------------------------------------------------------------
/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/src/common/observers/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 { observePageVisibility } from './page-visibility'
27 | import { observePageClicks } from './page-clicks'
28 |
29 | export { observePageVisibility, observePageClicks }
30 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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: `
Home page
`
31 | })
32 | export class HomeComponent {}
33 |
--------------------------------------------------------------------------------
/packages/rum-core/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@elastic/apm-rum-core",
3 | "version": "5.24.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 | "provenance": true
13 | },
14 | "repository": {
15 | "type": "git",
16 | "url": "https://github.com/elastic/apm-agent-rum-js.git",
17 | "directory": "packages/rum-core"
18 | },
19 | "scripts": {
20 | "prepublishOnly": "npm run build",
21 | "build": "run-p build:*",
22 | "build:main": "BABEL_ENV=BROWSER_PROD npx babel src -d dist/lib",
23 | "build:module": "BABEL_ENV=BROWSER_ESM_PROD npx babel src -d dist/es",
24 | "karma:dev": "karma start --auto-watch --restartOnFileChange",
25 | "bench": "NODE_ENV=production karma start karma.bench.conf.js",
26 | "karma:coverage": "karma start --coverage --singleRun",
27 | "test:unit": "npm run script runUnitTests packages/rum-core",
28 | "test": "npm run test:unit",
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 | "browserslist": [
44 | "ie 11"
45 | ]
46 | }
47 |
--------------------------------------------------------------------------------
/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/src/common/http/response-status.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 function isResponseSuccessful(status) {
27 | // An http 4xx or 5xx error. Signal an error.
28 | if (status === 0 || (status > 399 && status < 600)) {
29 | return false
30 | }
31 |
32 | return true
33 | }
34 |
--------------------------------------------------------------------------------
/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-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-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 | const { getBrowserList } = require('../../dev-utils/test-config')
28 |
29 | exports.config = getWebdriveBaseConfig(
30 | __dirname,
31 | './test/e2e/**/*.e2e-spec.js',
32 | getBrowserList('vue')
33 | )
34 |
--------------------------------------------------------------------------------
/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 | import 'core-js/features/string/pad-end'
29 |
30 | Object.setPrototypeOf =
31 | Object.setPrototypeOf ||
32 | function (obj, proto) {
33 | obj.__proto__ = proto
34 | return obj
35 | }
36 |
--------------------------------------------------------------------------------
/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 | const { getBrowserList } = require('../../dev-utils/test-config')
28 |
29 | exports.config = getWebdriveBaseConfig(
30 | __dirname,
31 | './test/e2e/**/*.e2e-spec.js',
32 | getBrowserList('react')
33 | )
34 |
--------------------------------------------------------------------------------
/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-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 { getApmRoutes } from './get-apm-routes'
29 |
30 | const withTransaction = getWithTransaction(apm)
31 | const ApmRoutes = getApmRoutes(apm)
32 |
33 | export { withTransaction, ApmRoutes }
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 |
28 | const state = {
29 | // Time when agent is bootstrapped and patching of modules happens
30 | bootstrapTime: null,
31 | // Time when the document is last backgrounded
32 | lastHiddenStart: Number.MIN_SAFE_INTEGER
33 | }
34 |
35 | export { __DEV__, state }
36 |
--------------------------------------------------------------------------------
/packages/rum/test/e2e/async-tests/index.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Async Test
5 |
6 |
7 |
39 |
40 |
41 |
42 |
Async test for RUM
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/.github/workflows/microbenchmark.yml:
--------------------------------------------------------------------------------
1 | name: microbenchmark
2 |
3 | on:
4 | workflow_dispatch:
5 | inputs:
6 | stack_version:
7 | description: 'Stack Version'
8 | default: '8.19.8'
9 | required: false
10 | push:
11 | branches:
12 | - main
13 | paths-ignore:
14 | - '**.md'
15 | - '**.asciidoc'
16 |
17 | # limit the access of the generated GITHUB_TOKEN
18 | permissions:
19 | contents: read
20 |
21 | jobs:
22 | microbenchmark:
23 | runs-on: ubuntu-latest
24 | timeout-minutes: 60
25 | steps:
26 | - name: Run buildkite pipeline
27 | uses: elastic/oblt-actions/buildkite/run@v1
28 | env:
29 | STACK_VERSION: ${{ inputs.stack_version || '8.19.8' }}
30 | with:
31 | token: ${{ secrets.BUILDKITE_TOKEN }}
32 | pipeline: apm-agent-microbenchmark
33 | wait-for: true
34 | env-vars: |
35 | script=.ci/scripts/bench.sh
36 | repo=apm-agent-rum-js
37 | sha=${{ github.sha }}
38 | STACK_VERSION=${{ env.STACK_VERSION }}
39 | BRANCH_NAME=${{ github.ref_name }}
40 |
41 | - if: ${{ failure() }}
42 | uses: elastic/oblt-actions/slack/send@v1
43 | with:
44 | bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
45 | channel-id: "#apm-agent-js"
46 | message: |
47 | :ghost: [${{ github.repository }}] microbenchmark *${{ github.ref_name }}* failed to run in Buildkite.
48 | Build: (<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|here>)
49 |
--------------------------------------------------------------------------------
/packages/rum-angular/test/e2e/with-router/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 | * This file includes polyfills needed by Angular and is loaded before the app.
28 | * You can add your own extra polyfills to this file.
29 | * Learn more in https://angular.io/guide/browser-support
30 | */
31 |
32 | /**
33 | * Zone JS is required by default for Angular itself.
34 | */
35 | import 'zone.js/dist/zone'
36 |
--------------------------------------------------------------------------------
/packages/rum-angular/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@elastic/apm-rum-angular",
3 | "version": "3.0.8",
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 | "publishConfig": {
8 | "access": "public",
9 | "directory": "dist",
10 | "provenance": true
11 | },
12 | "repository": {
13 | "type": "git",
14 | "url": "https://github.com/elastic/apm-agent-rum-js.git",
15 | "directory": "packages/rum-angular"
16 | },
17 | "engines": {
18 | "node": ">=16.0.0"
19 | },
20 | "scripts": {
21 | "prepublishOnly": "npm run build",
22 | "build": "ng build --configuration production",
23 | "build:e2e": "NODE_OPTIONS='--openssl-legacy-provider' ng build app --configuration production",
24 | "test:unit": "NODE_OPTIONS='--openssl-legacy-provider' ng test",
25 | "test:e2e": "NODE_OPTIONS='--openssl-legacy-provider' npm run script runE2eTests packages/rum-angular/wdio.conf.js",
26 | "test": "npm run test:unit && npm run build:e2e && npm run test:e2e",
27 | "script": "node ../../dev-utils/run-script.js",
28 | "karma:dev": "ng test --watch",
29 | "karma:coverage": "NODE_OPTIONS='--openssl-legacy-provider' ng test --code-coverage"
30 | },
31 | "dependencies": {
32 | "@elastic/apm-rum": "file:../rum",
33 | "@elastic/apm-rum-core": "file:../rum-core",
34 | "tslib": "^2.1.0"
35 | },
36 | "peerDependencies": {
37 | "@angular/core": ">=12.0.0",
38 | "@angular/router": ">=12.0.0"
39 | },
40 | "browserslist": [
41 | "ie 11"
42 | ]
43 | }
44 |
--------------------------------------------------------------------------------
/packages/rum-angular/test/e2e/with-router/environments/environment.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 | // This file can be replaced during build by using the `fileReplacements` array.
27 | // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.
28 | // The list of file replacements can be found in `angular.json`.
29 |
30 | export const environment = {
31 | production: false,
32 | serverUrl: 'http://localhost:8001'
33 | }
34 |
--------------------------------------------------------------------------------
/packages/rum-angular/src/apm.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 { InjectionToken, NgModule } from '@angular/core'
27 | import { RouterModule } from '@angular/router'
28 | import { apm, ApmBase } from '@elastic/apm-rum'
29 |
30 | export const APM = new InjectionToken('APM Base Client')
31 |
32 | @NgModule({
33 | imports: [RouterModule],
34 | providers: [{ provide: APM, useValue: apm }]
35 | })
36 | export class ApmModule {}
37 |
--------------------------------------------------------------------------------
/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 { apmBase } from '@elastic/apm-rum'
27 | import ApmServerMock from '../../rum-core/test/utils/apm-server-mock'
28 |
29 | export function initializeApmService(service, config) {
30 | const apmServer = apmBase.serviceFactory.getService('ApmServer')
31 | const serverMock = new ApmServerMock(apmServer, false)
32 | apmBase.serviceFactory.instances['ApmServer'] = serverMock
33 | return service.init(config)
34 | }
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/build/assets/data.json'
34 | constructor(private http: HttpClient) {}
35 |
36 | getContacts() {
37 | return this.http.get(this.CONTACT_URL)
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/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-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 { enableProdMode } from '@angular/core'
27 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'
28 |
29 | import { AppModule } from './app/app.module'
30 | import { environment } from './environments/environment'
31 |
32 | if (environment.production) {
33 | enableProdMode()
34 | }
35 |
36 | platformBrowserDynamic()
37 | .bootstrapModule(AppModule)
38 | .catch(err => console.error(err))
39 |
--------------------------------------------------------------------------------
/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 |
30 | const browserList = [
31 | {
32 | browserName: 'internet explorer',
33 | platformName: 'Windows 7',
34 | browserVersion: '10'
35 | }
36 | ]
37 |
38 | exports.config = Object.assign({}, config, {
39 | specs: glob.sync(join(__dirname, '/test/e2e/**/*failsafe.js')),
40 | capabilities: browserList
41 | })
42 |
--------------------------------------------------------------------------------
/dev-utils/object-configurable.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 (defineProperty) {
27 | Object.defineProperty = function (obj, prop, desc) {
28 | // CI was giving issue about defininig the prototype of
29 | // certain Objects. This patch is for use `spyOn` on functions
30 | // imported from modules so we can skip this property
31 | if (prop === 'prototype') return
32 | desc.configurable = true
33 | return defineProperty.call(obj, obj, prop, desc)
34 | }
35 | })(Object.defineProperty)
36 |
--------------------------------------------------------------------------------
/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-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, Inject, Injectable } from '@angular/core'
27 | import { ApmBase } from '@elastic/apm-rum'
28 | import { APM } from './apm.module'
29 |
30 | @Injectable()
31 | export class ApmErrorHandler extends ErrorHandler {
32 | constructor(@Inject(APM) public apm: ApmBase) {
33 | super()
34 | }
35 |
36 | handleError(error) {
37 | this.apm.captureError(error.originalError || error)
38 | super.handleError(error)
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/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/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 | WEBPACK_HASH_FN
31 | } = require('../../../../../dev-utils/build')
32 |
33 | module.exports = {
34 | entry: join(__dirname, './app.js'),
35 | output: {
36 | path: resolve(__dirname),
37 | filename: 'app.e2e-bundle.js',
38 | libraryTarget: 'umd',
39 | hashFunction: WEBPACK_HASH_FN
40 | },
41 | ...getWebpackConfig(BUNDLE_TYPES.BROWSER_DEV)
42 | }
43 |
--------------------------------------------------------------------------------
/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 | WEBPACK_HASH_FN
31 | } = require('../../../../../dev-utils/build')
32 |
33 | module.exports = {
34 | entry: join(__dirname, 'app.js'),
35 | output: {
36 | filename: 'app.e2e-bundle.min.js',
37 | path: resolve(__dirname),
38 | libraryTarget: 'umd',
39 | hashFunction: WEBPACK_HASH_FN
40 | },
41 | ...getWebpackConfig(BUNDLE_TYPES.BROWSER_PROD)
42 | }
43 |
--------------------------------------------------------------------------------
/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 | WEBPACK_HASH_FN
32 | } = require('../../../../dev-utils/build')
33 |
34 | module.exports = {
35 | entry: {
36 | app: path.join(__dirname, 'app.js')
37 | },
38 | output: {
39 | path: path.resolve(__dirname),
40 | filename: 'app.e2e-bundle.js',
41 | hashFunction: WEBPACK_HASH_FN
42 | },
43 | ...getWebpackConfig(BUNDLE_TYPES.BROWSER_DEV, PACKAGE_TYPES.VUE)
44 | }
45 |
--------------------------------------------------------------------------------
/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/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 |
--------------------------------------------------------------------------------
/docs/reference/longtasks.md:
--------------------------------------------------------------------------------
1 | ---
2 | mapped_pages:
3 | - https://www.elastic.co/guide/en/apm/agent/rum-js/current/longtasks.html
4 | applies_to:
5 | stack:
6 | serverless: unavailable
7 | product:
8 | apm_agent_rum: ga
9 | ---
10 |
11 | # How to interpret long task spans in the UI [longtasks]
12 |
13 | Long tasks is a new performance metric that can be used for measuring the responsiveness of an application and helps developers to understand the bad user experience. It enables detecting tasks that monopolize the UI thread for extended periods (greater than 50 milliseconds) and block other critical tasks from being executed as stated in the [official spec](https://github.com/w3c/longtasks).
14 |
15 | RUM agent automatically captures these Long tasks and include them as spans as part of the transaction. Since long tasks currently does not have the full information on which part of code cause slowness, it would be hard to interpret these spans. Below you can find some tips to help with interpreting long task spans:
16 |
17 | * The name of the long task span, e.g.: `self`, `same-origin`, etc., implies the origin of the task. It could be the current browsing context or inside iframes.
18 | * Context of the span is enriched with useful information like `attribution` (the type of work, such as script, layout, etc), `type`, `id` and `name`, which determines the culprit container (such as window, iframe, embed or object) responsible for the long task.
19 |
20 | With the help of the transaction timeline and span timings, one could dig deeper by marking slow application code with the [User Timing API](https://developer.mozilla.org/en-US/docs/Web/API/Performance/mark). When these spans are then captured by the agent again, you could combine them with long tasks to reveal the true source code location.
21 |
22 |
--------------------------------------------------------------------------------
/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-core/test/common/http/response-status.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 { isResponseSuccessful } from '../../../src/common/http/response-status'
27 |
28 | describe('isResponseSuccessful', () => {
29 | it('should return true if response status is 204', () => {
30 | expect(isResponseSuccessful(204)).toBe(true)
31 | })
32 |
33 | it('should return false if response status is 500', () => {
34 | expect(isResponseSuccessful(500)).toBe(false)
35 | })
36 |
37 | it('should return false if response status is 400', () => {
38 | expect(isResponseSuccessful(400)).toBe(false)
39 | })
40 | })
41 |
--------------------------------------------------------------------------------
/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-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 { getBrowserList } = require('../../dev-utils/test-config')
28 | const {
29 | getWebpackConfig,
30 | PACKAGE_TYPES,
31 | BUNDLE_TYPES
32 | } = require('../../dev-utils/build')
33 |
34 | module.exports = function (config) {
35 | config.set(baseConfig)
36 | config.set({
37 | webpack: getWebpackConfig(BUNDLE_TYPES.BROWSER_DEV, PACKAGE_TYPES.VUE),
38 | customLaunchers: getBrowserList('vue')
39 | })
40 | const preparedConfig = prepareConfig(config, 'rum-vue')
41 | config.set(preparedConfig)
42 | }
43 |
--------------------------------------------------------------------------------
/.github/workflows/run-test/action.yml:
--------------------------------------------------------------------------------
1 | ---
2 |
3 | name: common tasks
4 | description: Pull/Build docker images and run tests
5 |
6 | inputs:
7 | goal:
8 | description: 'Goal to execute'
9 | required: true
10 | stack-version:
11 | description: 'Stack Version'
12 | required: true
13 | scope:
14 | description: 'Scope'
15 | default: ''
16 | type: string
17 | mode:
18 | description: 'Mode to use'
19 | default: 'none'
20 | type: choice
21 | options:
22 | - none
23 |
24 | runs:
25 | using: "composite"
26 | steps:
27 | - uses: actions/setup-node@v6
28 | with:
29 | node-version-file: '.nvmrc'
30 | - name: Pull and build docker infra
31 | run: './.ci/scripts/pull_and_build.sh'
32 | shell: bash
33 | - name: Run tests Elastic Stack ${{ matrix.stack-version }} - ${{ matrix.scope }} - ${{ fromJSON('{"none":"Puppeteer"}')[inputs.mode] || inputs.mode }}
34 | run: './.ci/scripts/test.sh'
35 | shell: bash
36 | env:
37 | GOAL: ${{ inputs.goal }}
38 | MODE: ${{ inputs.mode }}
39 | SCOPE: ${{ inputs.scope }}
40 | STACK_VERSION: ${{ inputs.stack-version }}
41 | # The upload-artifact action fails if the name contains slashes `/` or colons `:`.
42 | # This step creates a slugified version that will not contain these characters.
43 | - uses: gacts/github-slug@91cb78e803e07ccf88570afeddeabaad93c8f4cb # 1.3.4
44 | id: slug
45 | if: success() || failure()
46 | with:
47 | to-slug: ${{ inputs.goal }}-${{ inputs.mode }}-${{ inputs.scope }}-${{ inputs.stack-version }}
48 | - name: Store test results
49 | if: success() || failure()
50 | uses: actions/upload-artifact@v6
51 | with:
52 | name: test-results-${{ steps.slug.outputs.slug }}
53 | path: |
54 | packages/**/reports/TESTS-*.xml
55 |
--------------------------------------------------------------------------------
/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 | state.bootstrapTime = now()
35 | enabled = true
36 | } else if (isBrowser) {
37 | /**
38 | * Print this error message only on the browser console
39 | * on unsupported browser versions
40 | */
41 | console.log('[Elastic APM] platform is not supported!')
42 | }
43 |
44 | return enabled
45 | }
46 |
--------------------------------------------------------------------------------
/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 { getBrowserList } = require('../../dev-utils/test-config')
28 | const {
29 | getWebpackConfig,
30 | PACKAGE_TYPES,
31 | BUNDLE_TYPES
32 | } = require('../../dev-utils/build')
33 |
34 | module.exports = function (config) {
35 | config.set(baseConfig)
36 | config.set({
37 | webpack: getWebpackConfig(BUNDLE_TYPES.BROWSER_DEV, PACKAGE_TYPES.REACT),
38 | customLaunchers: getBrowserList('react')
39 | })
40 | const preparedConfig = prepareConfig(config, 'rum-react')
41 | config.set(preparedConfig)
42 | }
43 |
--------------------------------------------------------------------------------
/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-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 | WEBPACK_HASH_FN
32 | } = require('../../../../../dev-utils/build')
33 |
34 | module.exports = {
35 | entry: {
36 | general: path.join(__dirname, 'general.js'),
37 | routes: path.join(__dirname, 'routes.js')
38 | },
39 | output: {
40 | path: path.resolve(__dirname),
41 | filename: '[name].e2e-bundle.js',
42 | libraryTarget: 'umd',
43 | hashFunction: WEBPACK_HASH_FN
44 | },
45 | ...getWebpackConfig(BUNDLE_TYPES.BROWSER_DEV, PACKAGE_TYPES.REACT)
46 | }
47 |
--------------------------------------------------------------------------------
/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-vue/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@elastic/apm-rum-vue",
3 | "version": "2.1.11",
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": "npm run build:e2e && npm run test:unit && npm run test:e2e",
34 | "script": "node ../../dev-utils/run-script.js"
35 | },
36 | "publishConfig": {
37 | "access": "public",
38 | "provenance": true
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 | "browserslist": [
53 | "ie 11"
54 | ]
55 | }
56 |
--------------------------------------------------------------------------------
/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/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: ${
37 | resp && resp.statusCode
38 | }, body: ${body}`
39 | fail(message)
40 | }
41 | done()
42 | }
43 | )
44 | })
45 | })
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 |
--------------------------------------------------------------------------------
/docs/reference/source-maps.md:
--------------------------------------------------------------------------------
1 | ---
2 | mapped_pages:
3 | - https://www.elastic.co/guide/en/apm/agent/rum-js/current/sourcemap.html
4 | applies_to:
5 | stack:
6 | serverless: unavailable
7 | product:
8 | apm_agent_rum: ga
9 | ---
10 |
11 | # Source maps [sourcemap]
12 |
13 | Minifying JavaScript bundles is a common practice in production as it can improve the load time and network latency of your application. However, minified code by itself can be hard to debug. For this reason, Elastic APM supports source maps. A source map is a file that maps minified files back to the original source code, allowing you to maintain the speed advantage of minified code, without losing the ability to quickly and easily debug your applications.
14 |
15 | There are three steps required to enable, upload, and apply a source map to error stack traces. An overview is listed below, and a complete walk-through is available in the [generate and upload a source map](docs-content://solutions/observability/apm/create-upload-source-maps-rum.md) guide.
16 |
17 | 1. Set the [`serviceVersion`](/reference/configuration.md#service-version) when initializing the RUM Agent.
18 | 2. [Generate a source map](docs-content://solutions/observability/apm/create-upload-source-maps-rum.md#apm-source-map-rum-generate) for your application with the `serviceVersion` from step one.
19 | 3. [Enable and upload the source map file](docs-content://solutions/observability/apm/create-upload-source-maps-rum.md#apm-source-map-rum-upload) to APM Server.
20 |
21 | $$$secret-token$$$
22 | You can also configure a [secret token](docs-content://solutions/observability/apm/secret-token.md) or [API key](docs-content://solutions/observability/apm/api-keys.md) to restrict the uploading of sourcemaps.
23 |
24 | ::::{tip}
25 | Don’t forget, you must enable [RUM support](docs-content://solutions/observability/apm/configure-real-user-monitoring-rum.md) in the APM Server for this endpoint to work.
26 | ::::
27 |
28 |
29 |
--------------------------------------------------------------------------------
/packages/rum-react/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@elastic/apm-rum-react",
3 | "version": "2.0.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 | "provenance": true
21 | },
22 | "repository": {
23 | "type": "git",
24 | "url": "git+https://github.com/elastic/apm-agent-rum-js.git",
25 | "directory": "packages/rum-react"
26 | },
27 | "scripts": {
28 | "prepublishOnly": "npm run build",
29 | "build": "run-p build:main build:module",
30 | "build:main": "BABEL_ENV=BROWSER_PROD npx babel src -d dist/lib",
31 | "build:module": "BABEL_ENV=BROWSER_ESM_PROD npx babel src -d dist/es",
32 | "build:e2e": "npm run script buildE2eBundles packages/rum-react/test/e2e",
33 | "karma:dev": "karma start --auto-watch --restartOnFileChange",
34 | "karma:coverage": "karma start --coverage --singleRun",
35 | "test:unit": "npm run script runUnitTests packages/rum-react",
36 | "test:e2e": "npm run script runE2eTests packages/rum-react/wdio.conf.js",
37 | "test": "npm run build:e2e && npm run test:unit && npm run test:e2e",
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": ">=6.0.0"
50 | },
51 | "browserslist": [
52 | "ie 11"
53 | ]
54 | }
55 |
--------------------------------------------------------------------------------
/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) {
30 | super(props)
31 | this.state = {
32 | userName: ''
33 | }
34 | }
35 |
36 | componentDidMount() {
37 | var url = '/test/e2e/data.json'
38 | fetch(url)
39 | .then(resp => resp.json())
40 | .then(data => this.setState({ userName: data.userName }))
41 | }
42 |
43 | render() {
44 | return (
45 |
46 |
47 | {this.props.path}
48 |
49 | {this.state.userName}
50 |
51 | )
52 | }
53 | }
54 |
55 | export default TopicComponent
56 |
--------------------------------------------------------------------------------
/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 {
28 | CONFIG_SERVICE,
29 | TRANSACTION_SERVICE,
30 | ERROR_LOGGING,
31 | APM_SERVER
32 | } from '../common/constants'
33 | import { serviceCreators } from '../common/service-factory'
34 |
35 | function registerServices() {
36 | serviceCreators[ERROR_LOGGING] = serviceFactory => {
37 | const [
38 | apmServer,
39 | configService,
40 | transactionService
41 | ] = serviceFactory.getService([
42 | APM_SERVER,
43 | CONFIG_SERVICE,
44 | TRANSACTION_SERVICE
45 | ])
46 | return new ErrorLogging(apmServer, configService, transactionService)
47 | }
48 | }
49 |
50 | export { registerServices }
51 |
--------------------------------------------------------------------------------
/.github/workflows/README.md:
--------------------------------------------------------------------------------
1 | ## CI/CD
2 |
3 | There are 4 main stages that run on GitHub actions:
4 |
5 | * Lint
6 | * Test
7 | * Coverage
8 | * Release
9 |
10 | There are some other stages that run for every push on the main branches:
11 |
12 | * [Microbenchmark](./microbenchmark.yml)
13 |
14 | ### Scenarios
15 |
16 | * Tests should be triggered on branch, tag and PR basis.
17 | * Commits that are only affecting the docs files should not trigger any test or similar stages that are not required.
18 | * Automated release in the CI gets triggered through a GitHub workflow.
19 | * **This is not the case yet**, but if Github secrets are required then Pull Requests from forked repositories won't run any build accessing those secrets. If needed, then create a feature branch.
20 |
21 | ### How to interact with the CI?
22 |
23 | #### On a PR basis
24 |
25 | Once a PR has been opened then there are two different ways you can trigger builds in the CI:
26 |
27 | 1. Commit based
28 | 1. UI based, any Elasticians can force a build through the GitHub UI
29 |
30 | #### Branches
31 |
32 | Every time there is a merge to main or any release branches the whole workflow will compile and test on Linux.
33 |
34 | ### Release process
35 |
36 | This process has been fully automated and it gets triggered manually when running the [release](https://github.com/elastic/apm-agent-java/actions/workflows/release.yml) workflow.
37 |
38 | The tag release follows the naming convention: `v...`, where ``, `` and ``.
39 |
40 | ### OpenTelemetry
41 |
42 | Every workflow and its logs are exported to OpenTelemetry traces/logs/metrics. Those details can be seen [here](https://ela.st/oblt-ci-cd-stats) (**NOTE**: only available for Elasticians).
43 |
44 | ## Bump automation
45 |
46 | [updatecli](https://www.updatecli.io/) is the tool we use to automatically bump some of the dependencies related to
47 | the [Elastic Stack versions](./bump-elastic-stack.yml) used for the different tests.
48 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/docs/reference/upgrading.md:
--------------------------------------------------------------------------------
1 | ---
2 | mapped_pages:
3 | - https://www.elastic.co/guide/en/apm/agent/rum-js/current/upgrading.html
4 | applies_to:
5 | stack:
6 | serverless: unavailable
7 | product:
8 | apm_agent_rum: ga
9 | ---
10 |
11 | # Upgrading [upgrading]
12 |
13 | Upgrades between minor versions of the agent, like from 3.1 to 3.2 are always backwards compatible. Upgrades that involve a major version bump often come with some backwards incompatible changes.
14 |
15 | Before upgrading the agent, be sure to review the:
16 |
17 | * [Agent release notes](/release-notes/index.md)
18 | * [Agent and Server compatibility chart](docs-content://solutions/observability/apm/apm-agent-compatibility.md)
19 |
20 | The following upgrade guides are also available:
21 |
22 | * [Upgrade to version 5.x](/release-notes/breaking-changes.md) - Follow this guide to upgrade from version `4.x` to version `5.x` of the Elastic APM RUM JS Agent.
23 |
24 |
25 | ## End of life dates [end-of-life-dates]
26 |
27 | We love all our products, but sometimes we must say goodbye to a release so that we can continue moving forward on future development and innovation. Our [End of life policy](https://www.elastic.co/support/eol) defines how long a given release is considered supported, as well as how long a release is considered still in active development or maintenance. The table below is a simplified description of this policy.
28 |
29 | | Agent version | EOL Date | Maintained until |
30 | | --- | --- | --- |
31 | | 4.8.x | 2021-08-13 | 4.9.0 |
32 | | 4.7.x | 2021-07-15 | 4.8.0 |
33 | | 4.6.x | 2021-05-19 | 4.7.0 |
34 | | 4.5.x | 2021-03-30 | 4.6.0 |
35 | | 4.4.x | 2021-02-05 | 4.5.0 |
36 | | 4.3.x | 2021-01-11 | 4.4.0 |
37 | | 4.2.x | 2021-01-08 | 4.3.0 |
38 | | 4.1.x | 2020-12-12 | 4.2.0 |
39 | | 4.0.x | 2020-09-11 | 4.1.0 |
40 | | 3.0.x | 2020-07-29 | 5.0.0 |
41 | | 2.3.x | 2020-06-18 | 4.0.0 |
42 | | 2.2.x | 2020-06-05 | 2.3.0 |
43 | | 2.1.x | 2020-06-03 | 2.2.0 |
44 | | 2.0.x | 2020-05-14 | 2.1.0 |
45 | | 1.0.x | 2020-02-23 | 3.0.0 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/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-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 | import {
29 | TRANSACTION_SERVICE,
30 | LOGGING_SERVICE,
31 | PERFORMANCE_MONITORING,
32 | ERROR_LOGGING
33 | } from '../common/constants'
34 |
35 | function createTracer(serviceFactory) {
36 | var performanceMonitoring = serviceFactory.getService(PERFORMANCE_MONITORING)
37 | var transactionService = serviceFactory.getService(TRANSACTION_SERVICE)
38 | var errorLogging = serviceFactory.getService(ERROR_LOGGING)
39 | var loggingService = serviceFactory.getService(LOGGING_SERVICE)
40 | return new Tracer(
41 | performanceMonitoring,
42 | transactionService,
43 | loggingService,
44 | errorLogging
45 | )
46 | }
47 |
48 | export { Span, Tracer, createTracer }
49 |
--------------------------------------------------------------------------------
/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 |
48 | {props.path + '\n'} {count}
49 | Loading...
}>
50 |
51 |
52 |
53 | )
54 | }
55 |
--------------------------------------------------------------------------------
/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 | CLICK
34 | } from './constants'
35 |
36 | export function getInstrumentationFlags(instrument, disabledInstrumentations) {
37 | /**
38 | * Valid instrumentation flags
39 | */
40 | const flags = {
41 | [XMLHTTPREQUEST]: false,
42 | [FETCH]: false,
43 | [HISTORY]: false,
44 | [PAGE_LOAD]: false,
45 | [ERROR]: false,
46 | [EVENT_TARGET]: false,
47 | [CLICK]: false
48 | }
49 |
50 | if (!instrument) {
51 | return flags
52 | }
53 |
54 | Object.keys(flags).forEach(key => {
55 | if (disabledInstrumentations.indexOf(key) === -1) {
56 | flags[key] = true
57 | }
58 | })
59 | return flags
60 | }
61 |
--------------------------------------------------------------------------------
/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 { APM_SERVER } from '@elastic/apm-rum-core'
29 | import { getGlobalConfig } from '../../../../dev-utils/test-config'
30 | import ApmServerMock from '@elastic/apm-rum-core/test/utils/apm-server-mock'
31 |
32 | const globalConfig = getGlobalConfig()
33 |
34 | export function getApmBase() {
35 | console.log('E2E Global Configs', JSON.stringify(globalConfig, null, 2))
36 | const apmServer = apmBase.serviceFactory.getService(APM_SERVER)
37 | const serverMock = new ApmServerMock(apmServer, globalConfig.useMocks)
38 | apmBase.serviceFactory.instances[APM_SERVER] = serverMock
39 | return apmBase
40 | }
41 |
42 | export function getServerUrl() {
43 | return globalConfig.agentConfig.serverUrl
44 | }
45 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/docs/reference/span-api.md:
--------------------------------------------------------------------------------
1 | ---
2 | mapped_pages:
3 | - https://www.elastic.co/guide/en/apm/agent/rum-js/current/span-api.html
4 | applies_to:
5 | stack:
6 | serverless: unavailable
7 | product:
8 | apm_agent_rum: ga
9 | ---
10 |
11 | # Span API [span-api]
12 |
13 | A span measures the duration of a single event. When a span is created it will measure the time until [`span.end()`](#span-end) is called.
14 |
15 | To get a `Span` object, you need to call [`apm.startSpan()`](/reference/agent-api.md#apm-start-span).
16 |
17 |
18 | ## `span.name` [span-name]
19 |
20 | * **Type:** String
21 | * **Default:** `Unknown`
22 |
23 | The name of the span. This can also be set via [`apm.startSpan()`](/reference/agent-api.md#apm-start-span).
24 |
25 |
26 | ## `span.type` [span-type]
27 |
28 | * **Type:** String
29 | * **Default:** `custom`
30 |
31 | The type of span. This can also be set via [`apm.startSpan()`](/reference/agent-api.md#apm-start-span).
32 |
33 | The type is a hierarchical string used to group similar spans together. For instance, all outgoing AJAX requests are given the type `external.http`.
34 |
35 | In the above example, `external` is considered the type prefix. Though there are no naming restrictions for this prefix, the following are standardized across all Elastic APM agents: `app`, `db`, `cache`, `template`, and `external`.
36 |
37 |
38 | ## `span.addLabels()` [span-add-labels]
39 |
40 | ```js
41 | span.addLabels({ [name]: value })
42 | ```
43 |
44 | Add several labels on the span. If an error happens during the span, it will also get tagged with the same labels.
45 |
46 | Arguments:
47 |
48 | * `name` - Any string. All periods (.), asterisks (*), and double quotation marks (") will be replaced by underscores (_), as those characters have special meaning in Elasticsearch
49 | * `value` - Any string, boolean, or number. All other data types will be converted to a string before being sent to the APM Server.
50 |
51 |
52 | ## `span.end()` [span-end]
53 |
54 | ```js
55 | span.end()
56 | ```
57 |
58 | Ends the span. If the span has already ended, nothing happens.
59 |
60 |
--------------------------------------------------------------------------------
/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 { APM_SERVER } from '@elastic/apm-rum-core'
29 | import { getGlobalConfig } from '../../../../dev-utils/test-config'
30 | import ApmServerMock from '../../../rum-core/test/utils/apm-server-mock'
31 |
32 | const globalConfig = getGlobalConfig()
33 |
34 | export default function createApmBase(config) {
35 | console.log('E2E Global Configs', JSON.stringify(globalConfig, null, 2))
36 | const apmServer = apmBase.serviceFactory.getService(APM_SERVER)
37 | const { serverUrl } = globalConfig.agentConfig
38 | config.serverUrl = serverUrl
39 | const serverMock = new ApmServerMock(apmServer, globalConfig.useMocks)
40 | apmBase.serviceFactory.instances[APM_SERVER] = serverMock
41 |
42 | return apmBase.init(config)
43 | }
44 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/.ci/bump-elastic-stack.yml:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bump elastic stack to latest version
3 |
4 | actions:
5 | default:
6 | title: '[updatecli] Bump elastic stack version to {{ source "latestRelease" }}'
7 | kind: github/pullrequest
8 | spec:
9 | labels:
10 | - dependencies
11 | scmid: default
12 |
13 | scms:
14 | default:
15 | kind: github
16 | spec:
17 | user: '{{ requiredEnv "GITHUB_ACTOR" }}'
18 | owner: elastic
19 | repository: apm-agent-rum-js
20 | token: '{{ requiredEnv "GITHUB_TOKEN" }}'
21 | username: '{{ requiredEnv "GITHUB_ACTOR" }}'
22 | branch: main
23 | commitusingapi: true
24 |
25 | sources:
26 | latestRelease:
27 | name: Get Latest Elastic Release
28 | kind: githubrelease
29 | transformers:
30 | - trimprefix: v
31 | spec:
32 | owner: elastic
33 | repository: elasticsearch
34 | token: '{{ requiredEnv "GITHUB_TOKEN" }}'
35 | username: '{{ requiredEnv "GITHUB_ACTOR" }}'
36 | versionfilter:
37 | kind: regex
38 | pattern: ^v8\.(\d+)\.(\d+)$
39 |
40 | conditions:
41 | dockerTag:
42 | name: Is docker image elasticsearch:{{ source "latestRelease" }} published
43 | kind: dockerimage
44 | spec:
45 | image: elasticsearch
46 | tag: '{{ source "latestRelease" }}'
47 | sourceid: latestRelease
48 |
49 | targets:
50 |
51 | update-ci-workflow:
52 | name: 'Update elastic stack version to {{ source "latestRelease" }}'
53 | sourceid: latestRelease
54 | scmid: default
55 | kind: file
56 | spec:
57 | file: .github/workflows/ci.yml
58 | content: >-
59 | '{{ source `latestRelease` }}'
60 | matchpattern: \'[0-9]+\.[0-9]+\.[0-9]+\'
61 |
62 | update-microbenchmark-workflow:
63 | name: 'Update elastic stack version to {{ source "latestRelease" }}'
64 | sourceid: latestRelease
65 | scmid: default
66 | kind: file
67 | spec:
68 | file: .github/workflows/microbenchmark.yml
69 | content: >-
70 | '{{ source `latestRelease` }}'
71 | matchpattern: \'[0-9]+\.[0-9]+\.[0-9]+\'
72 |
--------------------------------------------------------------------------------
/docs/reference/configuring-cors.md:
--------------------------------------------------------------------------------
1 | ---
2 | mapped_pages:
3 | - https://www.elastic.co/guide/en/apm/agent/rum-js/current/configuring-cors.html
4 | applies_to:
5 | stack:
6 | serverless: unavailable
7 | product:
8 | apm_agent_rum: ga
9 | ---
10 |
11 | # Configure CORS [configuring-cors]
12 |
13 | If APM Server is deployed in an origin different than the page’s origin, you will need to configure Cross-Origin Resource Sharing (CORS).
14 |
15 | A list of permitted origins can be supplied to the [`apm-server.rum.allow_origins`](docs-content://solutions/observability/apm/configure-real-user-monitoring-rum.md#apm-rum-allow-origins) configuration option. By default, APM Server allows all origins.
16 |
17 |
18 | ## How CORS works [_how_cors_works]
19 |
20 | When the RUM agent makes its initial `POST` request, the browser will check to see if it is a cross-origin request. If it is, the browser automatically makes a preflight `OPTIONS` request to the server to ensure the original `POST` request is allowed. If this `OPTIONS` check passes, then the original `POST` request is allowed. This request will fail if RUM support is not configured in the APM Server.
21 |
22 | If you use a proxy, the preflight request headers may be necessary for your configuration:
23 |
24 | ```js
25 | Access-Control-Request-Headers: Content-Type
26 | Access-Control-Request-Method: POST
27 | Origin: [request-origin]
28 | ```
29 |
30 | The response should include these headers:
31 |
32 | ```js
33 | Access-Control-Allow-Headers: Content-Type
34 | Access-Control-Allow-Methods: POST, OPTIONS
35 | Access-Control-Allow-Origin: [request-origin]
36 | ```
37 |
38 | If you enable the [`sendCredentials`](/reference/configuration.md#send-credentials) configuration option, your proxy’s response must include the header `Access-Control-Allow-Origin` with the page’s origin as a value, and the following header:
39 |
40 | ```js
41 | Access-Control-Allow-Credentials: true
42 | ```
43 |
44 | ::::{tip}
45 | To learn more about CORS, see the MDN page on [Cross-Origin Resource Sharing](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS).
46 | ::::
47 |
48 |
49 |
--------------------------------------------------------------------------------
/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-core/src/performance-monitoring/navigation/user-timing.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 { USER_TIMING_THRESHOLD } from '../../common/constants'
27 | import { shouldCreateSpan } from './utils'
28 | import Span from '../span'
29 |
30 | function createUserTimingSpans(entries, trStart, trEnd) {
31 | const userTimingSpans = []
32 | for (let i = 0; i < entries.length; i++) {
33 | const { name, startTime, duration } = entries[i]
34 | const end = startTime + duration
35 |
36 | if (
37 | duration <= USER_TIMING_THRESHOLD ||
38 | !shouldCreateSpan(startTime, end, trStart, trEnd)
39 | ) {
40 | continue
41 | }
42 | const kind = 'app'
43 | const span = new Span(name, kind)
44 | span._start = startTime
45 | span.end(end)
46 |
47 | userTimingSpans.push(span)
48 | }
49 | return userTimingSpans
50 | }
51 |
52 | export { createUserTimingSpans }
53 |
--------------------------------------------------------------------------------
/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) {
31 | super(props)
32 | this.state = {
33 | userName: ''
34 | }
35 | }
36 |
37 | componentDidMount() {
38 | const url = '/test/e2e/data.json'
39 | fetch(url)
40 | .then(resp => resp.json())
41 | .then(data => this.setState({ userName: data.userName }))
42 |
43 | if (typeof performance.measure === 'function') {
44 | performance.measure('manual-component-mounted', 'manual-component-start')
45 | }
46 | }
47 |
48 | render() {
49 | return
Manual {this.state.userName}
50 | }
51 | }
52 |
53 | export default withTransaction('ManualComponent', 'component')(ManualComponent)
54 |
--------------------------------------------------------------------------------
/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 instances 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-core/src/common/patching/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 { patchXMLHttpRequest } from './xhr-patch'
27 | import { patchFetch } from './fetch-patch'
28 | import { patchHistory } from './history-patch'
29 | import EventHandler from '../event-handler'
30 | import { HISTORY, FETCH, XMLHTTPREQUEST } from '../constants'
31 |
32 | const patchEventHandler = new EventHandler()
33 | let alreadyPatched = false
34 |
35 | function patchAll() {
36 | if (!alreadyPatched) {
37 | alreadyPatched = true
38 | patchXMLHttpRequest(function (event, task) {
39 | patchEventHandler.send(XMLHTTPREQUEST, [event, task])
40 | })
41 | patchFetch(function (event, task) {
42 | patchEventHandler.send(FETCH, [event, task])
43 | })
44 | patchHistory(function (event, task) {
45 | patchEventHandler.send(HISTORY, [event, task])
46 | })
47 | }
48 | return patchEventHandler
49 | }
50 |
51 | export { patchAll, patchEventHandler }
52 |
--------------------------------------------------------------------------------
/packages/rum-angular/test/specs/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 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files
27 |
28 | import 'zone.js/dist/zone'
29 | import 'zone.js/dist/zone-testing'
30 | import { getTestBed } from '@angular/core/testing'
31 | import {
32 | BrowserDynamicTestingModule,
33 | platformBrowserDynamicTesting
34 | } from '@angular/platform-browser-dynamic/testing'
35 |
36 | declare const require: {
37 | context(
38 | path: string,
39 | deep?: boolean,
40 | filter?: RegExp
41 | ): {
42 | keys(): string[]
43 | (id: string): T
44 | }
45 | }
46 |
47 | // First, initialize the Angular testing environment.
48 | getTestBed().initTestEnvironment(
49 | BrowserDynamicTestingModule,
50 | platformBrowserDynamicTesting()
51 | )
52 | // Then we find all the tests.
53 | const context = require.context('./', true, /\.spec\.ts$/)
54 | // And load the modules.
55 | context.keys().map(context)
56 |
--------------------------------------------------------------------------------
/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 |