@graphql-mesh/plugin-newrelic 0.94.3 → 0.94.4-alpha-20230704122717-69fb4cba4
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 -12
- package/esm/index.js +5 -12
- package/package.json +1 -1
- package/typings/index.d.cts +1 -1
- package/typings/index.d.ts +1 -1
package/cjs/index.js
CHANGED
|
@@ -10,8 +10,7 @@ const cross_helpers_1 = require("@graphql-mesh/cross-helpers");
|
|
|
10
10
|
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
|
-
function useMeshNewrelic(options) {
|
|
14
|
-
const instrumentationApi = newrelic_1.default?.shim;
|
|
13
|
+
function useMeshNewrelic(options, { instrumentationApi = newrelic_1.default?.shim, agentApi = newrelic_1.default }) {
|
|
15
14
|
if (!instrumentationApi?.agent) {
|
|
16
15
|
options.logger.debug('Agent unavailable. Please check your New Relic Agent configuration and ensure New Relic is enabled.');
|
|
17
16
|
return {};
|
|
@@ -21,11 +20,11 @@ function useMeshNewrelic(options) {
|
|
|
21
20
|
.incrementCallCount();
|
|
22
21
|
const logger = instrumentationApi.logger.child({ component: EnvelopAttributeName });
|
|
23
22
|
const segmentByRequestContext = new WeakMap();
|
|
24
|
-
const transactionCallback = new WeakMap();
|
|
25
23
|
return {
|
|
26
24
|
onPluginInit({ addPlugin }) {
|
|
27
25
|
addPlugin((0, newrelic_2.useNewRelic)({
|
|
28
26
|
...options,
|
|
27
|
+
shim: instrumentationApi,
|
|
29
28
|
extractOperationName: options.extractOperationName
|
|
30
29
|
? context => string_interpolation_1.stringInterpolator.parse(options.extractOperationName, {
|
|
31
30
|
context,
|
|
@@ -34,10 +33,10 @@ function useMeshNewrelic(options) {
|
|
|
34
33
|
: undefined,
|
|
35
34
|
}));
|
|
36
35
|
},
|
|
37
|
-
onRequest({
|
|
38
|
-
const currentTransaction = instrumentationApi.getTransaction();
|
|
36
|
+
onRequest({ url, requestHandler, setRequestHandler }) {
|
|
37
|
+
const currentTransaction = instrumentationApi.agent.tracer.getTransaction();
|
|
39
38
|
if (!currentTransaction) {
|
|
40
|
-
|
|
39
|
+
setRequestHandler((...args) => agentApi.startWebTransaction(url.pathname, () => requestHandler(...args)));
|
|
41
40
|
}
|
|
42
41
|
},
|
|
43
42
|
onExecute({ args: { contextValue } }) {
|
|
@@ -132,12 +131,6 @@ function useMeshNewrelic(options) {
|
|
|
132
131
|
httpDetailSegment.end();
|
|
133
132
|
};
|
|
134
133
|
},
|
|
135
|
-
onResponse({ request }) {
|
|
136
|
-
const callback = transactionCallback.get(request);
|
|
137
|
-
if (callback) {
|
|
138
|
-
callback();
|
|
139
|
-
}
|
|
140
|
-
},
|
|
141
134
|
};
|
|
142
135
|
}
|
|
143
136
|
exports.default = useMeshNewrelic;
|
package/esm/index.js
CHANGED
|
@@ -7,8 +7,7 @@ import { process } from '@graphql-mesh/cross-helpers';
|
|
|
7
7
|
import { stringInterpolator } from '@graphql-mesh/string-interpolation';
|
|
8
8
|
import { getHeadersObj } from '@graphql-mesh/utils';
|
|
9
9
|
const EnvelopAttributeName = 'Envelop_NewRelic_Plugin';
|
|
10
|
-
export default function useMeshNewrelic(options) {
|
|
11
|
-
const instrumentationApi = newRelic?.shim;
|
|
10
|
+
export default function useMeshNewrelic(options, { instrumentationApi = newRelic?.shim, agentApi = newRelic }) {
|
|
12
11
|
if (!instrumentationApi?.agent) {
|
|
13
12
|
options.logger.debug('Agent unavailable. Please check your New Relic Agent configuration and ensure New Relic is enabled.');
|
|
14
13
|
return {};
|
|
@@ -18,11 +17,11 @@ export default function useMeshNewrelic(options) {
|
|
|
18
17
|
.incrementCallCount();
|
|
19
18
|
const logger = instrumentationApi.logger.child({ component: EnvelopAttributeName });
|
|
20
19
|
const segmentByRequestContext = new WeakMap();
|
|
21
|
-
const transactionCallback = new WeakMap();
|
|
22
20
|
return {
|
|
23
21
|
onPluginInit({ addPlugin }) {
|
|
24
22
|
addPlugin(useNewRelic({
|
|
25
23
|
...options,
|
|
24
|
+
shim: instrumentationApi,
|
|
26
25
|
extractOperationName: options.extractOperationName
|
|
27
26
|
? context => stringInterpolator.parse(options.extractOperationName, {
|
|
28
27
|
context,
|
|
@@ -31,10 +30,10 @@ export default function useMeshNewrelic(options) {
|
|
|
31
30
|
: undefined,
|
|
32
31
|
}));
|
|
33
32
|
},
|
|
34
|
-
onRequest({
|
|
35
|
-
const currentTransaction = instrumentationApi.getTransaction();
|
|
33
|
+
onRequest({ url, requestHandler, setRequestHandler }) {
|
|
34
|
+
const currentTransaction = instrumentationApi.agent.tracer.getTransaction();
|
|
36
35
|
if (!currentTransaction) {
|
|
37
|
-
|
|
36
|
+
setRequestHandler((...args) => agentApi.startWebTransaction(url.pathname, () => requestHandler(...args)));
|
|
38
37
|
}
|
|
39
38
|
},
|
|
40
39
|
onExecute({ args: { contextValue } }) {
|
|
@@ -129,11 +128,5 @@ export default function useMeshNewrelic(options) {
|
|
|
129
128
|
httpDetailSegment.end();
|
|
130
129
|
};
|
|
131
130
|
},
|
|
132
|
-
onResponse({ request }) {
|
|
133
|
-
const callback = transactionCallback.get(request);
|
|
134
|
-
if (callback) {
|
|
135
|
-
callback();
|
|
136
|
-
}
|
|
137
|
-
},
|
|
138
131
|
};
|
|
139
132
|
}
|
package/package.json
CHANGED
package/typings/index.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Plugin } from 'graphql-yoga';
|
|
2
2
|
import { MeshPlugin, MeshPluginOptions, YamlConfig } from '@graphql-mesh/types';
|
|
3
|
-
export default function useMeshNewrelic(options: MeshPluginOptions<YamlConfig.NewrelicConfig
|
|
3
|
+
export default function useMeshNewrelic(options: MeshPluginOptions<YamlConfig.NewrelicConfig>, { instrumentationApi, agentApi }: any): MeshPlugin<any> & Plugin<any>;
|
package/typings/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Plugin } from 'graphql-yoga';
|
|
2
2
|
import { MeshPlugin, MeshPluginOptions, YamlConfig } from '@graphql-mesh/types';
|
|
3
|
-
export default function useMeshNewrelic(options: MeshPluginOptions<YamlConfig.NewrelicConfig
|
|
3
|
+
export default function useMeshNewrelic(options: MeshPluginOptions<YamlConfig.NewrelicConfig>, { instrumentationApi, agentApi }: any): MeshPlugin<any> & Plugin<any>;
|