Skip to content

Commit 212fc05

Browse files
authored
chore(examples): lint examples/connect using shared top-level eslint config (#2897)
Refs: #2891
1 parent daa2261 commit 212fc05

File tree

6 files changed

+85
-6
lines changed

6 files changed

+85
-6
lines changed

examples/connect/.eslintrc.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
'use strict';
18+
19+
const baseConfig = require('../../eslint.config');
20+
21+
module.exports = {
22+
...baseConfig,
23+
env: {
24+
node: true,
25+
},
26+
};

examples/connect/.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=false

examples/connect/client.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
'use strict';
218

319
// eslint-disable-next-line import/order

examples/connect/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
"description": "Example of Connect integration with OpenTelemetry",
66
"main": "index.js",
77
"scripts": {
8+
"lint": "eslint . --ext=ts,js,mjs",
9+
"lint:fix": "eslint . --ext=ts,js,mjs --fix",
810
"client": "node ./client.js",
911
"docker:start": "cd ./docker && docker-compose down && docker-compose up",
1012
"docker:stop": "cd ./docker && docker-compose down",

examples/connect/server.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
'use strict';
218

319
// eslint-disable-next-line
@@ -21,7 +37,9 @@ app.use((req, res, next) => {
2137
});
2238

2339
app.use('/run_test', async (req, res) => {
24-
const result = await axios.get('https://raw.githubusercontent.com/open-telemetry/opentelemetry-js/main/package.json');
40+
const result = await axios.get(
41+
'https://raw.githubusercontent.com/open-telemetry/opentelemetry-js/main/package.json'
42+
);
2543
tracing.log('sending response');
2644
res.end(`OK ${result.data.version}`);
2745

examples/connect/tracing.js

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright The OpenTelemetry Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
'use strict';
218

319
const opentelemetry = require('@opentelemetry/api');
@@ -12,7 +28,9 @@ const { NodeTracerProvider } = require('@opentelemetry/sdk-trace-node');
1228
const { SimpleSpanProcessor } = require('@opentelemetry/sdk-trace-base');
1329
const { CollectorTraceExporter } = require('@opentelemetry/exporter-collector');
1430

15-
const { ConnectInstrumentation } = require('@opentelemetry/instrumentation-connect');
31+
const {
32+
ConnectInstrumentation,
33+
} = require('@opentelemetry/instrumentation-connect');
1634
const { HttpInstrumentation } = require('@opentelemetry/instrumentation-http');
1735

1836
function log() {
@@ -21,15 +39,13 @@ function log() {
2139
console.log.apply(this, args);
2240
}
2341

24-
module.exports = (serviceName) => {
42+
module.exports = serviceName => {
2543
const exporter = new CollectorTraceExporter();
2644
const provider = new NodeTracerProvider({
2745
resource: new Resource({
2846
[ATTR_SERVICE_NAME]: serviceName,
2947
}),
30-
spanProcessors: [
31-
new SimpleSpanProcessor(exporter),
32-
],
48+
spanProcessors: [new SimpleSpanProcessor(exporter)],
3349
});
3450
const connectInstrumentation = new ConnectInstrumentation();
3551
registerInstrumentations({

0 commit comments

Comments
 (0)