@graphql-mesh/plugin-newrelic 1.0.0-alpha-20230523154231-8c60b52d9 → 1.0.0-alpha-20230523155104-df277a22b
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/cjs/index.js +5 -6
- package/esm/index.js +5 -6
- package/package.json +8 -5
package/cjs/index.js
CHANGED
|
@@ -11,8 +11,8 @@ const string_interpolation_1 = require("@graphql-mesh/string-interpolation");
|
|
|
11
11
|
const utils_1 = require("@graphql-mesh/utils");
|
|
12
12
|
const EnvelopAttributeName = 'Envelop_NewRelic_Plugin';
|
|
13
13
|
function useMeshNewrelic(options) {
|
|
14
|
-
const instrumentationApi = newrelic_1.default
|
|
15
|
-
if (!
|
|
14
|
+
const instrumentationApi = newrelic_1.default?.shim;
|
|
15
|
+
if (!instrumentationApi?.agent) {
|
|
16
16
|
options.logger.debug('Agent unavailable. Please check your New Relic Agent configuration and ensure New Relic is enabled.');
|
|
17
17
|
return {};
|
|
18
18
|
}
|
|
@@ -38,11 +38,10 @@ function useMeshNewrelic(options) {
|
|
|
38
38
|
segmentByRequestContext.set(contextValue.request || contextValue, operationSegment);
|
|
39
39
|
},
|
|
40
40
|
onDelegate({ sourceName, fieldName, args, context, key }) {
|
|
41
|
-
var _a, _b;
|
|
42
41
|
const parentSegment = instrumentationApi.getActiveSegment() ||
|
|
43
42
|
instrumentationApi.getSegment() ||
|
|
44
43
|
segmentByRequestContext.get(context.request || context);
|
|
45
|
-
const delimiter =
|
|
44
|
+
const delimiter = parentSegment?.transaction?.nameState?.delimiter || '/';
|
|
46
45
|
const sourceSegment = instrumentationApi.createSegment(`source${delimiter}${sourceName || 'unknown'}${delimiter}${fieldName}`, null, parentSegment);
|
|
47
46
|
if (!sourceSegment) {
|
|
48
47
|
return undefined;
|
|
@@ -64,7 +63,7 @@ function useMeshNewrelic(options) {
|
|
|
64
63
|
};
|
|
65
64
|
},
|
|
66
65
|
onFetch({ url, options, context }) {
|
|
67
|
-
const agent = instrumentationApi
|
|
66
|
+
const agent = instrumentationApi?.agent;
|
|
68
67
|
const parentSegment = instrumentationApi.getActiveSegment() ||
|
|
69
68
|
instrumentationApi.getSegment() ||
|
|
70
69
|
(context ? segmentByRequestContext.get(context.request || context) : undefined);
|
|
@@ -81,7 +80,7 @@ function useMeshNewrelic(options) {
|
|
|
81
80
|
httpDetailSegment.addAttribute(`request.parameters.${key}`, value);
|
|
82
81
|
});
|
|
83
82
|
httpDetailSegment.addAttribute('procedure', options.method || 'GET');
|
|
84
|
-
const transaction = parentSegment
|
|
83
|
+
const transaction = parentSegment?.transaction;
|
|
85
84
|
if (transaction) {
|
|
86
85
|
const outboundHeaders = Object.create(null);
|
|
87
86
|
if (agent.config.encoding_key && transaction.syntheticsHeader) {
|
package/esm/index.js
CHANGED
|
@@ -8,8 +8,8 @@ import { stringInterpolator } from '@graphql-mesh/string-interpolation';
|
|
|
8
8
|
import { getHeadersObj } from '@graphql-mesh/utils';
|
|
9
9
|
const EnvelopAttributeName = 'Envelop_NewRelic_Plugin';
|
|
10
10
|
export default function useMeshNewrelic(options) {
|
|
11
|
-
const instrumentationApi = newRelic
|
|
12
|
-
if (!
|
|
11
|
+
const instrumentationApi = newRelic?.shim;
|
|
12
|
+
if (!instrumentationApi?.agent) {
|
|
13
13
|
options.logger.debug('Agent unavailable. Please check your New Relic Agent configuration and ensure New Relic is enabled.');
|
|
14
14
|
return {};
|
|
15
15
|
}
|
|
@@ -35,11 +35,10 @@ export default function useMeshNewrelic(options) {
|
|
|
35
35
|
segmentByRequestContext.set(contextValue.request || contextValue, operationSegment);
|
|
36
36
|
},
|
|
37
37
|
onDelegate({ sourceName, fieldName, args, context, key }) {
|
|
38
|
-
var _a, _b;
|
|
39
38
|
const parentSegment = instrumentationApi.getActiveSegment() ||
|
|
40
39
|
instrumentationApi.getSegment() ||
|
|
41
40
|
segmentByRequestContext.get(context.request || context);
|
|
42
|
-
const delimiter =
|
|
41
|
+
const delimiter = parentSegment?.transaction?.nameState?.delimiter || '/';
|
|
43
42
|
const sourceSegment = instrumentationApi.createSegment(`source${delimiter}${sourceName || 'unknown'}${delimiter}${fieldName}`, null, parentSegment);
|
|
44
43
|
if (!sourceSegment) {
|
|
45
44
|
return undefined;
|
|
@@ -61,7 +60,7 @@ export default function useMeshNewrelic(options) {
|
|
|
61
60
|
};
|
|
62
61
|
},
|
|
63
62
|
onFetch({ url, options, context }) {
|
|
64
|
-
const agent = instrumentationApi
|
|
63
|
+
const agent = instrumentationApi?.agent;
|
|
65
64
|
const parentSegment = instrumentationApi.getActiveSegment() ||
|
|
66
65
|
instrumentationApi.getSegment() ||
|
|
67
66
|
(context ? segmentByRequestContext.get(context.request || context) : undefined);
|
|
@@ -78,7 +77,7 @@ export default function useMeshNewrelic(options) {
|
|
|
78
77
|
httpDetailSegment.addAttribute(`request.parameters.${key}`, value);
|
|
79
78
|
});
|
|
80
79
|
httpDetailSegment.addAttribute('procedure', options.method || 'GET');
|
|
81
|
-
const transaction = parentSegment
|
|
80
|
+
const transaction = parentSegment?.transaction;
|
|
82
81
|
if (transaction) {
|
|
83
82
|
const outboundHeaders = Object.create(null);
|
|
84
83
|
if (agent.config.encoding_key && transaction.syntheticsHeader) {
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-mesh/plugin-newrelic",
|
|
3
|
-
"version": "1.0.0-alpha-
|
|
3
|
+
"version": "1.0.0-alpha-20230523155104-df277a22b",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
|
-
"@graphql-mesh/cross-helpers": "0.4.0-alpha-
|
|
7
|
-
"@graphql-mesh/types": "1.0.0-alpha-
|
|
8
|
-
"@graphql-mesh/utils": "1.0.0-alpha-
|
|
6
|
+
"@graphql-mesh/cross-helpers": "0.4.0-alpha-20230523155104-df277a22b",
|
|
7
|
+
"@graphql-mesh/types": "1.0.0-alpha-20230523155104-df277a22b",
|
|
8
|
+
"@graphql-mesh/utils": "1.0.0-alpha-20230523155104-df277a22b",
|
|
9
9
|
"graphql": "*",
|
|
10
10
|
"newrelic": "^7 || ^8.0.0",
|
|
11
11
|
"tslib": "^2.4.0"
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@envelop/core": "^4.0.0",
|
|
15
15
|
"@envelop/newrelic": "6.0.0",
|
|
16
|
-
"@graphql-mesh/string-interpolation": "0.5.0-alpha-
|
|
16
|
+
"@graphql-mesh/string-interpolation": "0.5.0-alpha-20230523155104-df277a22b"
|
|
17
17
|
},
|
|
18
18
|
"repository": {
|
|
19
19
|
"type": "git",
|
|
@@ -21,6 +21,9 @@
|
|
|
21
21
|
"directory": "packages/plugins/newrelic"
|
|
22
22
|
},
|
|
23
23
|
"license": "MIT",
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=16.0.0"
|
|
26
|
+
},
|
|
24
27
|
"main": "cjs/index.js",
|
|
25
28
|
"module": "esm/index.js",
|
|
26
29
|
"typings": "typings/index.d.ts",
|