Skip to content
This repository was archived by the owner on Oct 31, 2024. It is now read-only.

Commit ff988d2

Browse files
author
Amir Blum
authored
chore: run prettier on entire codebase (#82)
1 parent fe3f4f7 commit ff988d2

File tree

20 files changed

+69
-93
lines changed

20 files changed

+69
-93
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ jobs:
3131
- name: Install Dependencies
3232
run: yarn
3333

34+
- name: Prettier check
35+
run: yarn prettier:check
36+
3437
- name: Build
3538
run: yarn build:ci
3639

package.json

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,20 @@
55
"test": "lerna run test",
66
"test:ci": "lerna run test:ci --since origin/master",
77
"build": "lerna run build",
8-
"build:ci": "lerna run build --since origin/master",
8+
"build:ci": "lerna run build",
99
"postinstall": "lerna bootstrap",
10-
"prettier": "prettier --config .prettierrc.yml --write \"**/*.{ts,tsx,js,jsx,json}\"",
10+
"prettier": "prettier --config .prettierrc.yml --write \"**/*.{ts,js,json}\"",
11+
"prettier:check": "prettier --config .prettierrc.yml --check \"**/*.{ts,js,json}\"",
1112
"version:update": "lerna run version:update",
1213
"version": "git add packages/**/version.ts",
1314
"publish:ci": "lerna publish --yes --allow-branch master --create-release github --conventionalCommits",
1415
"publish:ci:prerelease": "lerna publish --yes --canary"
1516
},
1617
"devDependencies": {
17-
"husky": "^4.3.6",
1818
"lerna": "^3.22.1",
19-
"lint-staged": "^10.5.3",
2019
"prettier": "^2.2.1"
2120
},
2221
"workspaces": [
2322
"packages/*"
24-
],
25-
"husky": {
26-
"hooks": {
27-
"pre-push": "yarn test",
28-
"pre-commit": "lint-staged"
29-
}
30-
},
31-
"lint-staged": {
32-
"*.{ts,js,json}": [
33-
"prettier --write"
34-
]
35-
}
23+
]
3624
}

packages/instrumentation-aws-sdk/src/aws-sdk.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,16 @@
88
no callback | 0 | 1
99
callback | 1 | 2
1010
*/
11-
import { Span, SpanAttributes, SpanKind, context, setSpan, suppressInstrumentation, Context, diag } from '@opentelemetry/api';
11+
import {
12+
Span,
13+
SpanAttributes,
14+
SpanKind,
15+
context,
16+
setSpan,
17+
suppressInstrumentation,
18+
Context,
19+
diag,
20+
} from '@opentelemetry/api';
1221
import AWS from 'aws-sdk';
1322
import { AttributeNames } from './enums';
1423
import { ServicesExtensions } from './services';
@@ -115,8 +124,7 @@ export class AwsInstrumentation extends InstrumentationBase<typeof AWS> {
115124
safeExecuteInTheMiddle(
116125
() => this._config.preRequestHook(span, request),
117126
(e: Error) => {
118-
if (e)
119-
diag.error(`${AwsInstrumentation.component} instrumentation: preRequestHook error`, e);
127+
if (e) diag.error(`${AwsInstrumentation.component} instrumentation: preRequestHook error`, e);
120128
},
121129
true
122130
);
@@ -216,9 +224,7 @@ export class AwsInstrumentation extends InstrumentationBase<typeof AWS> {
216224
return self._callOriginalFunction(() => original.call(awsRequest, arguments));
217225
});
218226

219-
return requestMetadata.isIncoming
220-
? self._bindPromise(origPromise, activeContextWithSpan)
221-
: origPromise;
227+
return requestMetadata.isIncoming ? self._bindPromise(origPromise, activeContextWithSpan) : origPromise;
222228
};
223229
}
224230

packages/instrumentation-aws-sdk/src/services/sqs.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,7 @@ class SqsContextGetter implements TextMapGetter<AWS.SQS.MessageBodyAttributeMap>
5959
const sqsContextGetter = new SqsContextGetter();
6060

6161
export class SqsServiceExtension implements ServiceExtension {
62-
constructor(
63-
private tracer: Tracer,
64-
private sqsProcessHook: AwsSdkSqsProcessCustomAttributeFunction
65-
) {}
62+
constructor(private tracer: Tracer, private sqsProcessHook: AwsSdkSqsProcessCustomAttributeFunction) {}
6663

6764
requestHook(request: AWS.Request<any, any>): RequestMetadata {
6865
const queueUrl = this.extractQueueUrl(request);

packages/instrumentation-aws-sdk/src/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ export interface AwsSdkInstrumentationConfig extends InstrumentationConfig {
3434
*/
3535
suppressInternalInstrumentation?: boolean;
3636

37-
/**
38-
* If passed, a span attribute will be added to all spans with key of the provided "moduleVersionAttributeName"
37+
/**
38+
* If passed, a span attribute will be added to all spans with key of the provided "moduleVersionAttributeName"
3939
* and value of the module version.
4040
*/
4141
moduleVersionAttributeName?: string;

packages/instrumentation-aws-sdk/test/aws-sdk.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ describe('instrumentation-aws-sdk', () => {
329329
mockAwsSend(responseMockSuccess, 'data returned from operation', true);
330330
const config = {
331331
moduleVersionAttributeName: 'module.version',
332-
suppressInternalInstrumentation: true
332+
suppressInternalInstrumentation: true,
333333
};
334334

335335
instrumentation.disable();

packages/instrumentation-kafkajs/src/kafkajs.ts

Lines changed: 19 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
import { SpanKind, Span, SpanStatusCode, Context, propagation, Link, getSpan, setSpan, context, diag } from '@opentelemetry/api';
1+
import {
2+
SpanKind,
3+
Span,
4+
SpanStatusCode,
5+
Context,
6+
propagation,
7+
Link,
8+
getSpan,
9+
setSpan,
10+
context,
11+
diag,
12+
} from '@opentelemetry/api';
213
import { ROOT_CONTEXT } from '@opentelemetry/context-base';
314
import { MessagingAttribute, MessagingOperationName } from '@opentelemetry/semantic-conventions';
415
import * as kafkaJs from 'kafkajs';
@@ -50,7 +61,7 @@ export class KafkaJsInstrumentation extends InstrumentationBase<typeof kafkaJs>
5061

5162
protected patch(moduleExports: typeof kafkaJs, moduleVersion: string) {
5263
diag.debug('kafkajs instrumentation: applying patch');
53-
this.moduleVersion = moduleVersion
64+
this.moduleVersion = moduleVersion;
5465

5566
this.unpatch(moduleExports);
5667
this._wrap(moduleExports?.Kafka?.prototype, 'producer', this._getProducerPatch.bind(this));
@@ -77,11 +88,7 @@ export class KafkaJsInstrumentation extends InstrumentationBase<typeof kafkaJs>
7788
if (isWrapped(newConsumer.run)) {
7889
self._unwrap(newConsumer, 'run');
7990
}
80-
self._wrap(
81-
newConsumer,
82-
'run',
83-
self._getConsumerRunPatch.bind(self)
84-
);
91+
self._wrap(newConsumer, 'run', self._getConsumerRunPatch.bind(self));
8592

8693
return newConsumer;
8794
};
@@ -95,20 +102,12 @@ export class KafkaJsInstrumentation extends InstrumentationBase<typeof kafkaJs>
95102
if (isWrapped(newProducer.sendBatch)) {
96103
self._unwrap(newProducer, 'sendBatch');
97104
}
98-
self._wrap(
99-
newProducer,
100-
'sendBatch',
101-
self._getProducerSendBatchPatch.bind(self)
102-
);
105+
self._wrap(newProducer, 'sendBatch', self._getProducerSendBatchPatch.bind(self));
103106

104107
if (isWrapped(newProducer.send)) {
105108
self._unwrap(newProducer, 'send');
106109
}
107-
self._wrap(
108-
newProducer,
109-
'send',
110-
self._getProducerSendPatch.bind(self)
111-
);
110+
self._wrap(newProducer, 'send', self._getProducerSendPatch.bind(self));
112111

113112
return newProducer;
114113
};
@@ -121,21 +120,13 @@ export class KafkaJsInstrumentation extends InstrumentationBase<typeof kafkaJs>
121120
if (isWrapped(config.eachMessage)) {
122121
self._unwrap(config, 'eachMessage');
123122
}
124-
self._wrap(
125-
config,
126-
'eachMessage',
127-
self._getConsumerEachMessagePatch.bind(self)
128-
);
123+
self._wrap(config, 'eachMessage', self._getConsumerEachMessagePatch.bind(self));
129124
}
130125
if (config?.eachBatch) {
131126
if (isWrapped(config.eachBatch)) {
132127
self._unwrap(config, 'eachBatch');
133128
}
134-
self._wrap(
135-
config,
136-
'eachBatch',
137-
self._getConsumerEachBatchPatch.bind(self)
138-
);
129+
self._wrap(config, 'eachBatch', self._getConsumerEachBatchPatch.bind(self));
139130
}
140131
return original.call(this, config);
141132
};
@@ -206,9 +197,7 @@ export class KafkaJsInstrumentation extends InstrumentationBase<typeof kafkaJs>
206197
const self = this;
207198
return function (batch: ProducerBatch): Promise<RecordMetadata[]> {
208199
const spans: Span[] = batch.topicMessages.flatMap((topicMessage) =>
209-
topicMessage.messages.map((message) =>
210-
self._startProducerSpan(topicMessage.topic, message)
211-
)
200+
topicMessage.messages.map((message) => self._startProducerSpan(topicMessage.topic, message))
212201
);
213202

214203
const origSendResult: Promise<RecordMetadata[]> = original.apply(this, arguments);

packages/instrumentation-kafkajs/src/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ export interface KafkaJsInstrumentationConfig extends InstrumentationConfig {
1717
/** hook for adding custom attributes before consumer message is processed */
1818
consumerHook?: KafkaConsumerCustomAttributeFunction;
1919

20-
/**
21-
* If passed, a span attribute will be added to all spans with key of the provided "moduleVersionAttributeName"
20+
/**
21+
* If passed, a span attribute will be added to all spans with key of the provided "moduleVersionAttributeName"
2222
* and value of the module version.
2323
*/
2424
moduleVersionAttributeName?: string;

packages/instrumentation-kafkajs/test/kafkajs.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -359,14 +359,14 @@ describe('instrumentation-kafkajs', () => {
359359
describe('moduleVersionAttributeName config', () => {
360360
beforeEach(async () => {
361361
const config: KafkaJsInstrumentationConfig = {
362-
moduleVersionAttributeName: 'module.version'
362+
moduleVersionAttributeName: 'module.version',
363363
};
364364
instrumentation.disable();
365365
instrumentation.setConfig(config);
366366
instrumentation.enable();
367367
producer = kafka.producer();
368368
});
369-
369+
370370
it('adds module version to producer span', async () => {
371371
await producer.send({
372372
topic: 'topic-name-1',
@@ -628,7 +628,7 @@ describe('instrumentation-kafkajs', () => {
628628
describe('moduleVersionAttributeName config', () => {
629629
beforeEach(async () => {
630630
const config: KafkaJsInstrumentationConfig = {
631-
moduleVersionAttributeName: 'module.version'
631+
moduleVersionAttributeName: 'module.version',
632632
};
633633
instrumentation.disable();
634634
instrumentation.setConfig(config);
@@ -640,11 +640,11 @@ describe('instrumentation-kafkajs', () => {
640640
eachMessage: async (payload: EachMessagePayload): Promise<void> => {},
641641
});
642642
});
643-
643+
644644
it('adds module version to consumer span', async () => {
645645
const payload: EachMessagePayload = createEachMessagePayload();
646646
await runConfig.eachMessage(payload);
647-
647+
648648
const spans = memoryExporter.getFinishedSpans();
649649
expect(spans.length).toBe(1);
650650
const span = spans[0];
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
export * from './mongoose';
2-
export * from './types';
2+
export * from './types';

0 commit comments

Comments
 (0)