@envelop/newrelic 4.1.0 → 4.1.1-alpha-72027859.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -7
- package/cjs/index.js +6 -3
- package/esm/index.js +6 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -31,8 +31,8 @@ yarn add newrelic @envelop/newrelic
|
|
|
31
31
|
## Basic usage Example
|
|
32
32
|
|
|
33
33
|
```ts
|
|
34
|
-
import { envelop } from '@envelop/core'
|
|
35
|
-
import { useNewRelic } from '@envelop/newrelic'
|
|
34
|
+
import { envelop } from '@envelop/core'
|
|
35
|
+
import { useNewRelic } from '@envelop/newrelic'
|
|
36
36
|
|
|
37
37
|
const getEnveloped = envelop({
|
|
38
38
|
plugins: [
|
|
@@ -44,11 +44,13 @@ const getEnveloped = envelop({
|
|
|
44
44
|
trackResolvers: true, // default `false`. When set to `true`, track resolvers as segments to monitor their performance
|
|
45
45
|
includeResolverArgs: false, // default `false`. When set to `true`, includes all the arguments passed to resolvers with their values
|
|
46
46
|
rootFieldsNaming: true, // default `false`. When set to `true` append the names of operation root fields to the transaction name
|
|
47
|
-
skipError: error => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
})
|
|
47
|
+
skipError: error => {
|
|
48
|
+
return true // a function that allows you to skip reporting a given error to NewRelic. By default custom `EnvelopError`s will be skipped
|
|
49
|
+
},
|
|
50
|
+
extractOperationName: context => context.request.body.customOperationName // Allows to set a custom operation name to be used as transaction name and attribute
|
|
51
|
+
})
|
|
52
|
+
]
|
|
53
|
+
})
|
|
52
54
|
```
|
|
53
55
|
|
|
54
56
|
> Note: Transaction and segment/span timings may be affected by other plugins used. In order to get more accurate tracking, it is recommended to add the New Relic plugin last.
|
package/cjs/index.js
CHANGED
|
@@ -57,13 +57,15 @@ exports.defaultSkipError = defaultSkipError;
|
|
|
57
57
|
const useNewRelic = (rawOptions) => {
|
|
58
58
|
const options = {
|
|
59
59
|
...DEFAULT_OPTIONS,
|
|
60
|
-
...
|
|
60
|
+
...rawOptions,
|
|
61
61
|
};
|
|
62
62
|
options.isExecuteVariablesRegex = options.includeExecuteVariables instanceof RegExp;
|
|
63
63
|
options.isResolverArgsRegex = options.includeResolverArgs instanceof RegExp;
|
|
64
64
|
const instrumentationApi$ = Promise.resolve().then(() => __importStar(require('newrelic'))).then(m => m.default || m)
|
|
65
65
|
.then(({ shim }) => {
|
|
66
|
-
shim.agent.metrics
|
|
66
|
+
shim.agent.metrics
|
|
67
|
+
.getOrCreateMetric(`Supportability/ExternalModules/${AttributeName.COMPONENT_NAME}`)
|
|
68
|
+
.incrementCallCount();
|
|
67
69
|
return shim;
|
|
68
70
|
});
|
|
69
71
|
const logger$ = instrumentationApi$.then(({ logger }) => {
|
|
@@ -93,7 +95,8 @@ const useNewRelic = (rawOptions) => {
|
|
|
93
95
|
transactionNameState.setName(transactionNameState.prefix, transactionNameState.verb, delimiter, operationType + delimiter + operationName + (rootFields ? delimiter + rootFields.join('&') : ''));
|
|
94
96
|
spanContext.addCustomAttribute(AttributeName.EXECUTION_OPERATION_NAME, operationName);
|
|
95
97
|
spanContext.addCustomAttribute(AttributeName.EXECUTION_OPERATION_TYPE, operationType);
|
|
96
|
-
options.includeOperationDocument &&
|
|
98
|
+
options.includeOperationDocument &&
|
|
99
|
+
spanContext.addCustomAttribute(AttributeName.EXECUTION_OPERATION_DOCUMENT, document);
|
|
97
100
|
if (options.includeExecuteVariables) {
|
|
98
101
|
const rawVariables = args.variableValues || {};
|
|
99
102
|
const executeVariablesToTrack = options.isExecuteVariablesRegex
|
package/esm/index.js
CHANGED
|
@@ -30,14 +30,16 @@ export function defaultSkipError(error) {
|
|
|
30
30
|
export const useNewRelic = (rawOptions) => {
|
|
31
31
|
const options = {
|
|
32
32
|
...DEFAULT_OPTIONS,
|
|
33
|
-
...
|
|
33
|
+
...rawOptions,
|
|
34
34
|
};
|
|
35
35
|
options.isExecuteVariablesRegex = options.includeExecuteVariables instanceof RegExp;
|
|
36
36
|
options.isResolverArgsRegex = options.includeResolverArgs instanceof RegExp;
|
|
37
37
|
const instrumentationApi$ = import('newrelic')
|
|
38
38
|
.then(m => m.default || m)
|
|
39
39
|
.then(({ shim }) => {
|
|
40
|
-
shim.agent.metrics
|
|
40
|
+
shim.agent.metrics
|
|
41
|
+
.getOrCreateMetric(`Supportability/ExternalModules/${AttributeName.COMPONENT_NAME}`)
|
|
42
|
+
.incrementCallCount();
|
|
41
43
|
return shim;
|
|
42
44
|
});
|
|
43
45
|
const logger$ = instrumentationApi$.then(({ logger }) => {
|
|
@@ -67,7 +69,8 @@ export const useNewRelic = (rawOptions) => {
|
|
|
67
69
|
transactionNameState.setName(transactionNameState.prefix, transactionNameState.verb, delimiter, operationType + delimiter + operationName + (rootFields ? delimiter + rootFields.join('&') : ''));
|
|
68
70
|
spanContext.addCustomAttribute(AttributeName.EXECUTION_OPERATION_NAME, operationName);
|
|
69
71
|
spanContext.addCustomAttribute(AttributeName.EXECUTION_OPERATION_TYPE, operationType);
|
|
70
|
-
options.includeOperationDocument &&
|
|
72
|
+
options.includeOperationDocument &&
|
|
73
|
+
spanContext.addCustomAttribute(AttributeName.EXECUTION_OPERATION_DOCUMENT, document);
|
|
71
74
|
if (options.includeExecuteVariables) {
|
|
72
75
|
const rawVariables = args.variableValues || {};
|
|
73
76
|
const executeVariablesToTrack = options.isExecuteVariablesRegex
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@envelop/newrelic",
|
|
3
|
-
"version": "4.1.0",
|
|
3
|
+
"version": "4.1.1-alpha-72027859.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
|
-
"@envelop/core": "
|
|
6
|
+
"@envelop/core": "2.4.1-alpha-72027859.0",
|
|
7
7
|
"newrelic": "^7 || ^8.0.0",
|
|
8
8
|
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
|
|
9
9
|
},
|