@graphql-mesh/plugin-newrelic 0.94.2 → 0.94.3-alpha-20230702153114-2df3e7ed6
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 +13 -0
- package/esm/index.js +13 -0
- package/package.json +4 -3
- package/typings/index.d.cts +2 -1
- package/typings/index.d.ts +2 -1
package/cjs/index.js
CHANGED
|
@@ -21,6 +21,7 @@ function useMeshNewrelic(options) {
|
|
|
21
21
|
.incrementCallCount();
|
|
22
22
|
const logger = instrumentationApi.logger.child({ component: EnvelopAttributeName });
|
|
23
23
|
const segmentByRequestContext = new WeakMap();
|
|
24
|
+
const transactionCallback = new WeakMap();
|
|
24
25
|
return {
|
|
25
26
|
onPluginInit({ addPlugin }) {
|
|
26
27
|
addPlugin((0, newrelic_2.useNewRelic)({
|
|
@@ -33,6 +34,12 @@ function useMeshNewrelic(options) {
|
|
|
33
34
|
: undefined,
|
|
34
35
|
}));
|
|
35
36
|
},
|
|
37
|
+
onRequest({ request, url }) {
|
|
38
|
+
const currentTransaction = instrumentationApi.getTransaction();
|
|
39
|
+
if (!currentTransaction) {
|
|
40
|
+
instrumentationApi.startWebTransaction(url.pathname, () => new Promise(resolve => transactionCallback.set(request, resolve)));
|
|
41
|
+
}
|
|
42
|
+
},
|
|
36
43
|
onExecute({ args: { contextValue } }) {
|
|
37
44
|
const operationSegment = instrumentationApi.getActiveSegment() || instrumentationApi.getSegment();
|
|
38
45
|
segmentByRequestContext.set(contextValue.request || contextValue, operationSegment);
|
|
@@ -125,6 +132,12 @@ function useMeshNewrelic(options) {
|
|
|
125
132
|
httpDetailSegment.end();
|
|
126
133
|
};
|
|
127
134
|
},
|
|
135
|
+
onResponse({ request }) {
|
|
136
|
+
const callback = transactionCallback.get(request);
|
|
137
|
+
if (callback) {
|
|
138
|
+
callback();
|
|
139
|
+
}
|
|
140
|
+
},
|
|
128
141
|
};
|
|
129
142
|
}
|
|
130
143
|
exports.default = useMeshNewrelic;
|
package/esm/index.js
CHANGED
|
@@ -18,6 +18,7 @@ export default function useMeshNewrelic(options) {
|
|
|
18
18
|
.incrementCallCount();
|
|
19
19
|
const logger = instrumentationApi.logger.child({ component: EnvelopAttributeName });
|
|
20
20
|
const segmentByRequestContext = new WeakMap();
|
|
21
|
+
const transactionCallback = new WeakMap();
|
|
21
22
|
return {
|
|
22
23
|
onPluginInit({ addPlugin }) {
|
|
23
24
|
addPlugin(useNewRelic({
|
|
@@ -30,6 +31,12 @@ export default function useMeshNewrelic(options) {
|
|
|
30
31
|
: undefined,
|
|
31
32
|
}));
|
|
32
33
|
},
|
|
34
|
+
onRequest({ request, url }) {
|
|
35
|
+
const currentTransaction = instrumentationApi.getTransaction();
|
|
36
|
+
if (!currentTransaction) {
|
|
37
|
+
instrumentationApi.startWebTransaction(url.pathname, () => new Promise(resolve => transactionCallback.set(request, resolve)));
|
|
38
|
+
}
|
|
39
|
+
},
|
|
33
40
|
onExecute({ args: { contextValue } }) {
|
|
34
41
|
const operationSegment = instrumentationApi.getActiveSegment() || instrumentationApi.getSegment();
|
|
35
42
|
segmentByRequestContext.set(contextValue.request || contextValue, operationSegment);
|
|
@@ -122,5 +129,11 @@ export default function useMeshNewrelic(options) {
|
|
|
122
129
|
httpDetailSegment.end();
|
|
123
130
|
};
|
|
124
131
|
},
|
|
132
|
+
onResponse({ request }) {
|
|
133
|
+
const callback = transactionCallback.get(request);
|
|
134
|
+
if (callback) {
|
|
135
|
+
callback();
|
|
136
|
+
}
|
|
137
|
+
},
|
|
125
138
|
};
|
|
126
139
|
}
|
package/package.json
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-mesh/plugin-newrelic",
|
|
3
|
-
"version": "0.94.
|
|
3
|
+
"version": "0.94.3-alpha-20230702153114-2df3e7ed6",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"@graphql-mesh/cross-helpers": "^0.4.0",
|
|
7
7
|
"@graphql-mesh/types": "^0.94.1",
|
|
8
8
|
"@graphql-mesh/utils": "^0.94.1",
|
|
9
9
|
"graphql": "*",
|
|
10
|
+
"graphql-yoga": "^4.0.3",
|
|
10
11
|
"newrelic": "^7 || ^8.0.0 || ^10.0.0",
|
|
11
12
|
"tslib": "^2.4.0"
|
|
12
13
|
},
|
|
13
14
|
"dependencies": {
|
|
14
15
|
"@envelop/core": "^4.0.0",
|
|
15
|
-
"@envelop/newrelic": "6.0.1",
|
|
16
|
-
"@graphql-mesh/string-interpolation": "0.5.0"
|
|
16
|
+
"@envelop/newrelic": "^6.0.1",
|
|
17
|
+
"@graphql-mesh/string-interpolation": "^0.5.0"
|
|
17
18
|
},
|
|
18
19
|
"repository": {
|
|
19
20
|
"type": "git",
|
package/typings/index.d.cts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
import { Plugin } from 'graphql-yoga';
|
|
1
2
|
import { MeshPlugin, MeshPluginOptions, YamlConfig } from '@graphql-mesh/types';
|
|
2
|
-
export default function useMeshNewrelic(options: MeshPluginOptions<YamlConfig.NewrelicConfig>): MeshPlugin<any>;
|
|
3
|
+
export default function useMeshNewrelic(options: MeshPluginOptions<YamlConfig.NewrelicConfig>): MeshPlugin<any> & Plugin<any>;
|
package/typings/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
import { Plugin } from 'graphql-yoga';
|
|
1
2
|
import { MeshPlugin, MeshPluginOptions, YamlConfig } from '@graphql-mesh/types';
|
|
2
|
-
export default function useMeshNewrelic(options: MeshPluginOptions<YamlConfig.NewrelicConfig>): MeshPlugin<any>;
|
|
3
|
+
export default function useMeshNewrelic(options: MeshPluginOptions<YamlConfig.NewrelicConfig>): MeshPlugin<any> & Plugin<any>;
|