From 7aa1c98efe766ee2badc641776c4a266d92e1892 Mon Sep 17 00:00:00 2001 From: Vemparala Surya Vamsi <121419957+vsvamsi1@users.noreply.github.com> Date: Mon, 6 Nov 2023 15:05:17 +0530 Subject: [PATCH] chore: added new relic OTLP exporter (#28480) ## Description - Added new relic OTLP exporter to export eval traces, click event and api calls. - Conditionally loading both browser agent and OTLP scripts based on env variables. #### PR fixes following issue(s) Fixes #28504 and #28506 #### Type of change - Chore (housekeeping or task changes that don't impact user perception) #### How Has This Been Tested? - [x] Manual - [ ] JUnit - [ ] Jest - [ ] Cypress > > #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed --- .../docker/templates/nginx-app.conf.template | 3 +- app/client/jest.config.js | 7 + app/client/package.json | 8 + app/client/public/index.html | 51 +- app/client/src/auto-otel-web.js | 65 +++ app/client/src/ce/configs/index.ts | 42 ++ app/client/src/ce/configs/types.ts | 7 + app/client/src/index.tsx | 14 + app/client/src/utils/WorkerUtil.ts | 6 + app/client/yarn.lock | 482 +++++++++++++++++- 10 files changed, 640 insertions(+), 45 deletions(-) create mode 100644 app/client/src/auto-otel-web.js diff --git a/app/client/docker/templates/nginx-app.conf.template b/app/client/docker/templates/nginx-app.conf.template index cc11b83c09..c21b7fe84d 100644 --- a/app/client/docker/templates/nginx-app.conf.template +++ b/app/client/docker/templates/nginx-app.conf.template @@ -50,8 +50,9 @@ server { sub_filter __APPSMITH_DISABLE_IFRAME_WIDGET_SANDBOX__ '${APPSMITH_DISABLE_IFRAME_WIDGET_SANDBOX}'; sub_filter __APPSMITH_NEW_RELIC_ACCOUNT_ID__ '${APPSMITH_NEW_RELIC_ACCOUNT_ID}'; sub_filter __APPSMITH_NEW_RELIC_APPLICATION_ID__ '${APPSMITH_NEW_RELIC_APPLICATION_ID}'; - sub_filter __APPSMITH_APP_NEW_RELIC_LICENSE_KEY__ '${APPSMITH_APP_NEW_RELIC_LICENSE_KEY}'; + sub_filter __APPSMITH_NEW_RELIC_BROWSER_AGENT_LICENSE_KEY__ '${APPSMITH_NEW_RELIC_BROWSER_AGENT_LICENSE_KEY}'; sub_filter __APPSMITH_NEW_RELIC_ACCOUNT_ENABLE__ '${APPSMITH_NEW_RELIC_ACCOUNT_ENABLE}'; + sub_filter __APPSMITH_NEW_RELIC_OTLP_LICENSE_KEY__ '${APPSMITH_NEW_RELIC_OTLP_LICENSE_KEY}'; } diff --git a/app/client/jest.config.js b/app/client/jest.config.js index 678475e3b9..7006556898 100644 --- a/app/client/jest.config.js +++ b/app/client/jest.config.js @@ -83,6 +83,13 @@ module.exports = { apiKey: parseConfig("__APPSMITH_SEGMENT_KEY__"), ceKey: parseConfig("__APPSMITH_SEGMENT_CE_KEY__"), }, + newRelic:{ + enableNewRelic: parseConfig("__APPSMITH_NEW_RELIC_ACCOUNT_ENABLE__"), + accountId: parseConfig("__APPSMITH_NEW_RELIC_ACCOUNT_ID__"), + applicationId: parseConfig("__APPSMITH_NEW_RELIC_APPLICATION_ID__"), + browserAgentlicenseKey: parseConfig("__APPSMITH_NEW_RELIC_BROWSER_AGENT_LICENSE_KEY__"), + otlpLicenseKey: parseConfig("__APPSMITH_NEW_RELIC_OTLP_LICENSE_KEY__"), + }, fusioncharts: { licenseKey: parseConfig("__APPSMITH_FUSIONCHARTS_LICENSE_KEY__"), }, diff --git a/app/client/package.json b/app/client/package.json index ec10b8d35e..e7d7f0bc5f 100644 --- a/app/client/package.json +++ b/app/client/package.json @@ -61,6 +61,14 @@ "@loadable/component": "^5.15.3", "@manaflair/redux-batch": "^1.0.0", "@mantine/hooks": "^5.10.1", + "@opentelemetry/auto-instrumentations-web": "^0.33.2", + "@opentelemetry/context-zone": "^1.17.1", + "@opentelemetry/exporter-trace-otlp-proto": "^0.44.0", + "@opentelemetry/instrumentation": "^0.44.0", + "@opentelemetry/resources": "^1.17.1", + "@opentelemetry/sdk-trace-base": "^1.17.1", + "@opentelemetry/sdk-trace-web": "^1.17.1", + "@opentelemetry/semantic-conventions": "^1.17.1", "@sentry/react": "^6.2.4", "@sentry/tracing": "^6.2.4", "@shared/ast": "workspace:^", diff --git a/app/client/public/index.html b/app/client/public/index.html index 1bcb8a1026..d7efcbc795 100755 --- a/app/client/public/index.html +++ b/app/client/public/index.html @@ -40,30 +40,30 @@ const CLOUD_HOSTING = parseConfig("__APPSMITH_CLOUD_HOSTING__"); const ZIPY_KEY = parseConfig("__APPSMITH_ZIPY_SDK_KEY__"); const AIRGAPPED = parseConfig("__APPSMITH_AIRGAP_ENABLED__"); + // NREUM variable is required when we are we are are dynamically loading new relic browser agent script + NREUM = undefined - -