Skip to content

Commit

Permalink
New Relic: add error for agent not being found (#1457)
Browse files Browse the repository at this point in the history
* add error for agent not being found

* Create usenewrelic-agent-error-msg.md

* change error message

* run prettier

Co-authored-by: Laurin Quast <laurinquast@googlemail.com>
  • Loading branch information
zawadzkip and n1ru4l committed Aug 15, 2022
1 parent 0c1b170 commit ff8b447
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .changeset/usenewrelic-agent-error-msg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@envelop/newrelic': patch
---

New Relic: add error for agent not being found
Adds an error message when initializing the new relic plugin

- This error message will occur when the new relic agent is not found when initializing the plugin. Signalling information to a developer that new relic may not be
- installed correctly or may be disabled where this plugin is being instantiated.
5 changes: 5 additions & 0 deletions packages/plugins/newrelic/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ export const useNewRelic = (rawOptions?: UseNewRelicOptions): Plugin => {
const instrumentationApi$ = import('newrelic')
.then(m => m.default || m)
.then(({ shim }) => {
if (!shim?.agent) {
throw new Error(
'Agent unavailable. Please check your New Relic Agent configuration and ensure New Relic is enabled.'
);
}
shim.agent.metrics
.getOrCreateMetric(`Supportability/ExternalModules/${AttributeName.COMPONENT_NAME}`)
.incrementCallCount();
Expand Down

1 comment on commit ff8b447

@vercel
Copy link

@vercel vercel bot commented on ff8b447 Aug 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

envelop – ./

envelop.dev
envelop-theguild.vercel.app
www.envelop.dev
envelop-git-main-theguild.vercel.app

Please sign in to comment.