@envelop/newrelic 3.4.0 → 4.0.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 +1 -1
- package/index.d.ts +5 -2
- package/index.js +3 -4
- package/index.mjs +3 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -45,7 +45,7 @@ const getEnveloped = envelop({
|
|
|
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
47
|
skipError: error => { ... return true; }, // a function that allows you to skip reporting a given error to NewRelic. By default custom `EnvelopError`s will be skipped
|
|
48
|
-
|
|
48
|
+
extractOperationName: (context) => context.request.body.customOperationName, // Allows to set a custom operation name to be used as transaction name and attribute
|
|
49
49
|
}),
|
|
50
50
|
],
|
|
51
51
|
});
|
package/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Plugin } from '@envelop/core';
|
|
1
|
+
import { Plugin, DefaultContext } from '@envelop/core';
|
|
2
2
|
import { GraphQLError } from 'graphql';
|
|
3
3
|
export declare type UseNewRelicOptions = {
|
|
4
4
|
includeOperationDocument?: boolean;
|
|
@@ -7,7 +7,10 @@ export declare type UseNewRelicOptions = {
|
|
|
7
7
|
trackResolvers?: boolean;
|
|
8
8
|
includeResolverArgs?: boolean | RegExp;
|
|
9
9
|
rootFieldsNaming?: boolean;
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Function that returns a custom operation name to be used as transaction name and attribute
|
|
12
|
+
*/
|
|
13
|
+
extractOperationName?: (context: DefaultContext) => string | undefined;
|
|
11
14
|
/**
|
|
12
15
|
* Indicates whether or not to skip reporting a given error to NewRelic.
|
|
13
16
|
* By default, this plugin skips all `EnvelopError` errors and does not report them to NewRelic.
|
package/index.js
CHANGED
|
@@ -46,7 +46,6 @@ const DEFAULT_OPTIONS = {
|
|
|
46
46
|
trackResolvers: false,
|
|
47
47
|
includeResolverArgs: false,
|
|
48
48
|
rootFieldsNaming: false,
|
|
49
|
-
operationNameProperty: '',
|
|
50
49
|
skipError: defaultSkipError,
|
|
51
50
|
};
|
|
52
51
|
function defaultSkipError(error) {
|
|
@@ -72,7 +71,7 @@ const useNewRelic = (rawOptions) => {
|
|
|
72
71
|
});
|
|
73
72
|
return {
|
|
74
73
|
async onExecute({ args }) {
|
|
75
|
-
var _a;
|
|
74
|
+
var _a, _b;
|
|
76
75
|
const instrumentationApi = await instrumentationApi$;
|
|
77
76
|
const transactionNameState = instrumentationApi.agent.tracer.getTransaction().nameState;
|
|
78
77
|
const spanContext = instrumentationApi.agent.tracer.getSpanContext();
|
|
@@ -80,9 +79,9 @@ const useNewRelic = (rawOptions) => {
|
|
|
80
79
|
const rootOperation = args.document.definitions.find(definitionNode => definitionNode.kind === graphql.Kind.OPERATION_DEFINITION);
|
|
81
80
|
const operationType = rootOperation.operation;
|
|
82
81
|
const document = graphql.print(args.document);
|
|
83
|
-
const operationName =
|
|
82
|
+
const operationName = ((_a = options.extractOperationName) === null || _a === void 0 ? void 0 : _a.call(options, args.contextValue)) ||
|
|
84
83
|
args.operationName ||
|
|
85
|
-
((
|
|
84
|
+
((_b = rootOperation.name) === null || _b === void 0 ? void 0 : _b.value) ||
|
|
86
85
|
AttributeName.ANONYMOUS_OPERATION;
|
|
87
86
|
let rootFields = null;
|
|
88
87
|
if (options.rootFieldsNaming) {
|
package/index.mjs
CHANGED
|
@@ -23,7 +23,6 @@ const DEFAULT_OPTIONS = {
|
|
|
23
23
|
trackResolvers: false,
|
|
24
24
|
includeResolverArgs: false,
|
|
25
25
|
rootFieldsNaming: false,
|
|
26
|
-
operationNameProperty: '',
|
|
27
26
|
skipError: defaultSkipError,
|
|
28
27
|
};
|
|
29
28
|
function defaultSkipError(error) {
|
|
@@ -49,7 +48,7 @@ const useNewRelic = (rawOptions) => {
|
|
|
49
48
|
});
|
|
50
49
|
return {
|
|
51
50
|
async onExecute({ args }) {
|
|
52
|
-
var _a;
|
|
51
|
+
var _a, _b;
|
|
53
52
|
const instrumentationApi = await instrumentationApi$;
|
|
54
53
|
const transactionNameState = instrumentationApi.agent.tracer.getTransaction().nameState;
|
|
55
54
|
const spanContext = instrumentationApi.agent.tracer.getSpanContext();
|
|
@@ -57,9 +56,9 @@ const useNewRelic = (rawOptions) => {
|
|
|
57
56
|
const rootOperation = args.document.definitions.find(definitionNode => definitionNode.kind === Kind.OPERATION_DEFINITION);
|
|
58
57
|
const operationType = rootOperation.operation;
|
|
59
58
|
const document = print(args.document);
|
|
60
|
-
const operationName =
|
|
59
|
+
const operationName = ((_a = options.extractOperationName) === null || _a === void 0 ? void 0 : _a.call(options, args.contextValue)) ||
|
|
61
60
|
args.operationName ||
|
|
62
|
-
((
|
|
61
|
+
((_b = rootOperation.name) === null || _b === void 0 ? void 0 : _b.value) ||
|
|
63
62
|
AttributeName.ANONYMOUS_OPERATION;
|
|
64
63
|
let rootFields = null;
|
|
65
64
|
if (options.rootFieldsNaming) {
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@envelop/newrelic",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
|
-
"@envelop/core": "^2.3.
|
|
6
|
+
"@envelop/core": "^2.3.1",
|
|
7
7
|
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0",
|
|
8
8
|
"newrelic": "^7 || ^8.0.0"
|
|
9
9
|
},
|