Skip to content

Commit 3d10620

Browse files
authored
chore(examples): lint examples/ioredis using shared top-level eslint config (#2902)
Refs: #2891
1 parent 212fc05 commit 3d10620

File tree

5 files changed

+72
-9
lines changed

5 files changed

+72
-9
lines changed

examples/ioredis/.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/ioredis/.npmrc

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

examples/ioredis/index.js

Lines changed: 22 additions & 2 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
// Require tracer before any other modules
@@ -16,8 +32,12 @@ async function main() {
1632
// The process must live for at least the interval past any traces that
1733
// must be exported, or some risk being lost if they are recorded after the
1834
// last export.
19-
console.log('Sleeping 5 seconds before shutdown to ensure all records are flushed.');
20-
setTimeout(() => { console.log('Completed.'); }, 5000);
35+
console.log(
36+
'Sleeping 5 seconds before shutdown to ensure all records are flushed.'
37+
);
38+
setTimeout(() => {
39+
console.log('Completed.');
40+
}, 5000);
2141
}
2242

2343
main();

examples/ioredis/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
"description": "Example of HTTP 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
"docker:start": "docker run -d -p 6379:6379 --name otjsredis redis:alpine",
911
"docker:stop": "docker stop otjsredis && docker rm otjsredis",
1012
"start": "node index.js"

examples/ioredis/tracer.js

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,41 @@
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');
420
const { NodeTracerProvider } = require('@opentelemetry/sdk-trace-node');
521
const { SimpleSpanProcessor } = require('@opentelemetry/sdk-trace-base');
622
const { JaegerExporter } = require('@opentelemetry/exporter-jaeger');
7-
const { IORedisInstrumentation } = require('@opentelemetry/instrumentation-ioredis');
23+
const {
24+
IORedisInstrumentation,
25+
} = require('@opentelemetry/instrumentation-ioredis');
826
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
927

1028
const exporter = new JaegerExporter({ serviceName: 'ioredis-example' });
1129

1230
const provider = new NodeTracerProvider({
13-
spanProcessors: [
14-
new SimpleSpanProcessor(exporter),
15-
],
31+
spanProcessors: [new SimpleSpanProcessor(exporter)],
1632
});
1733

1834
// Initialize the OpenTelemetry APIs to use the BasicTracer bindings
1935
provider.register();
2036

2137
registerInstrumentations({
22-
instrumentations: [
23-
new IORedisInstrumentation(),
24-
],
38+
instrumentations: [new IORedisInstrumentation()],
2539
tracerProvider: provider,
2640
});
2741

0 commit comments

Comments
 (0)