Skip to content

Commit 8a048b9

Browse files
committed
Prettier and lint
1 parent d3ecee3 commit 8a048b9

File tree

4 files changed

+44
-27
lines changed

4 files changed

+44
-27
lines changed

packages/plugins/newrelic/package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,13 @@
5656
"tslib": "^2.5.0"
5757
},
5858
"devDependencies": {
59-
"@types/newrelic": "9.14.0",
6059
"@envelop/core": "^4.0.0",
60+
"@graphql-tools/schema": "^10.0.0",
61+
"@newrelic/test-utilities": "6.5.5",
62+
"@types/newrelic": "9.14.0",
6163
"graphql": "16.6.0",
6264
"newrelic": "9.8.1",
63-
"typescript": "4.8.4",
64-
"@newrelic/test-utilities": "6.5.5"
65+
"typescript": "4.8.4"
6566
},
6667
"publishConfig": {
6768
"directory": "dist",

packages/plugins/newrelic/src/index.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ export const useNewRelic = (rawOptions?: UseNewRelicOptions): Plugin => {
8383
const transaction = instrumentationApi.agent.tracer.getTransaction();
8484
if (!transaction) {
8585
logger.trace('No transaction found. Not recording resolver.');
86-
return () => { };
86+
return () => {};
8787
}
8888
const transactionNameState = transaction.nameState;
8989
if (!transactionNameState) {
9090
logger.trace('No transaction name state found. Not recording resolver.');
91-
return () => { };
91+
return () => {};
9292
}
9393
const delimiter = transactionNameState.delimiter;
9494

@@ -100,7 +100,7 @@ export const useNewRelic = (rawOptions?: UseNewRelicOptions): Plugin => {
100100
'No active segment found at resolver call. Not recording resolver (%s).',
101101
formattedPath,
102102
);
103-
return () => { };
103+
return () => {};
104104
}
105105

106106
const resolverSegment = instrumentationApi.createSegment(
@@ -110,7 +110,7 @@ export const useNewRelic = (rawOptions?: UseNewRelicOptions): Plugin => {
110110
);
111111
if (!resolverSegment) {
112112
logger.trace('Resolver segment was not created (%s).', formattedPath);
113-
return () => { };
113+
return () => {};
114114
}
115115
resolverSegment.start();
116116
resolverSegment.addAttribute(AttributeName.RESOLVER_FIELD_PATH, formattedPath);
@@ -169,9 +169,9 @@ export const useNewRelic = (rawOptions?: UseNewRelicOptions): Plugin => {
169169
transactionNameState.verb,
170170
delimiter,
171171
operationType +
172-
delimiter +
173-
operationName +
174-
(rootFields ? delimiter + rootFields.join('&') : ''),
172+
delimiter +
173+
operationName +
174+
(rootFields ? delimiter + rootFields.join('&') : ''),
175175
);
176176
}
177177

packages/plugins/newrelic/tests/newrelic.spec.ts

+30-17
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { AttributeName, useNewRelic } from '../src';
21
import { createTestkit } from '@envelop/testing';
32
import { makeExecutableSchema } from '@graphql-tools/schema';
43
import { TestAgent } from '@newrelic/test-utilities';
4+
import { AttributeName, useNewRelic } from '../src';
55

66
describe('New Relic', () => {
77
const schema = makeExecutableSchema({
@@ -42,7 +42,7 @@ describe('New Relic', () => {
4242
shim: helper.getShim(),
4343
}),
4444
],
45-
schema
45+
schema,
4646
);
4747
// Do some testing logic...
4848

@@ -60,10 +60,14 @@ describe('New Relic', () => {
6060
AttributeName.EXECUTION_OPERATION_TYPE,
6161
]);
6262
expect(
63-
tx.trace.root._spanContext.customAttributes.attributes.get(AttributeName.EXECUTION_OPERATION_NAME).value
63+
tx.trace.root._spanContext.customAttributes.attributes.get(
64+
AttributeName.EXECUTION_OPERATION_NAME,
65+
).value,
6466
).toBe(`Greetings`);
6567
expect(
66-
tx.trace.root._spanContext.customAttributes.attributes.get(AttributeName.EXECUTION_OPERATION_TYPE).value
68+
tx.trace.root._spanContext.customAttributes.attributes.get(
69+
AttributeName.EXECUTION_OPERATION_TYPE,
70+
).value,
6771
).toBe(`query`);
6872

6973
// Many metrics are not created until the transaction ends, if you're
@@ -73,7 +77,9 @@ describe('New Relic', () => {
7377
// This will check that the metrics given have been created. Extra metrics
7478
// are allowed.
7579
expect(
76-
helper.agent.metrics.getMetric(`Supportability/ExternalModules/${AttributeName.COMPONENT_NAME}`)
80+
helper.agent.metrics.getMetric(
81+
`Supportability/ExternalModules/${AttributeName.COMPONENT_NAME}`,
82+
),
7783
).toBeTruthy();
7884
});
7985
});
@@ -88,13 +94,17 @@ describe('New Relic', () => {
8894
shim: helper.getShim(),
8995
}),
9096
],
91-
schema
97+
schema,
9298
);
9399

94-
await testKit.execute(`query Greetings($name: String!) { hello(name: $name) }`, { name: 'Laurin' });
100+
await testKit.execute(`query Greetings($name: String!) { hello(name: $name) }`, {
101+
name: 'Laurin',
102+
});
95103

96104
expect(
97-
tx.trace.root._spanContext.customAttributes.attributes.get(AttributeName.EXECUTION_VARIABLES).value
105+
tx.trace.root._spanContext.customAttributes.attributes.get(
106+
AttributeName.EXECUTION_VARIABLES,
107+
).value,
98108
).toBe(`{"name":"Laurin"}`);
99109

100110
// Many metrics are not created until the transaction ends, if you're
@@ -112,7 +122,7 @@ describe('New Relic', () => {
112122
shim: helper.getShim(),
113123
}),
114124
],
115-
schema
125+
schema,
116126
);
117127

118128
await testKit.execute(
@@ -124,11 +134,13 @@ describe('New Relic', () => {
124134
{
125135
verb: 'Hi',
126136
name: 'Dotan',
127-
}
137+
},
128138
);
129139

130140
expect(
131-
tx.trace.root._spanContext.customAttributes.attributes.get(AttributeName.EXECUTION_VARIABLES).value
141+
tx.trace.root._spanContext.customAttributes.attributes.get(
142+
AttributeName.EXECUTION_VARIABLES,
143+
).value,
132144
).toBe(`{"verb":"Hi"}`);
133145

134146
// Many metrics are not created until the transaction ends, if you're
@@ -147,14 +159,15 @@ describe('New Relic', () => {
147159
shim: helper.getShim(),
148160
}),
149161
],
150-
schema
162+
schema,
151163
);
152164
// Do some testing logic...
153165
await testKit.execute(`query Greetings { hello }`);
154166

155-
expect(tx.trace.root._spanContext.customAttributes.attributes.get(AttributeName.EXECUTION_RESULT).value).toBe(
156-
`{"data":{"hello":"Hello world!"}}`
157-
);
167+
expect(
168+
tx.trace.root._spanContext.customAttributes.attributes.get(AttributeName.EXECUTION_RESULT)
169+
.value,
170+
).toBe(`{"data":{"hello":"Hello world!"}}`);
158171

159172
// Many metrics are not created until the transaction ends, if you're
160173
// missing metrics in your instrumentation tests, this may help.
@@ -171,7 +184,7 @@ describe('New Relic', () => {
171184
shim: helper.getShim(),
172185
}),
173186
],
174-
schema
187+
schema,
175188
);
176189
// Do some testing logic...
177190

@@ -193,7 +206,7 @@ describe('New Relic', () => {
193206
shim: helper.getShim(),
194207
}),
195208
],
196-
schema
209+
schema,
197210
);
198211
// Do some testing logic...
199212

pnpm-lock.yaml

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)