Skip to content

Commit 12d3aa6

Browse files
authored
chore(examples): lint examples/memcached using shared top-level eslint config (#2904)
Refs: #2891
1 parent 5f1b79e commit 12d3aa6

File tree

5 files changed

+78
-12
lines changed

5 files changed

+78
-12
lines changed

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

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

examples/memcached/index.js

Lines changed: 23 additions & 3 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')('example-resource');
@@ -9,12 +25,16 @@ const VALUE = `RAND:${Math.random().toFixed(4)}`;
925
const LT = 10;
1026
const client = new Memcached();
1127

12-
client.set(KEY, VALUE, LT, (err) => {
28+
client.set(KEY, VALUE, LT, err => {
1329
assert.strictEqual(err, undefined);
1430
client.get(KEY, (err, result) => {
1531
assert.strictEqual(err, undefined);
1632
assert.strictEqual(result, VALUE);
17-
console.log('Sleeping 5 seconds before shutdown to ensure all records are flushed.');
18-
setTimeout(() => { console.log('Completed.'); }, 5000);
33+
console.log(
34+
'Sleeping 5 seconds before shutdown to ensure all records are flushed.'
35+
);
36+
setTimeout(() => {
37+
console.log('Completed.');
38+
}, 5000);
1939
});
2040
});

examples/memcached/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
"description": "Example of Memcached client 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 --rm -d --name otel-memcached -p 11211:11211 memcached:1.6.9-alpine",
911
"docker:stop": "docker rm -f otel-memcached",
1012
"start": "node index.js"

examples/memcached/tracer.js

Lines changed: 26 additions & 9 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');
@@ -7,27 +23,28 @@ diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.VERBOSE);
723

824
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
925
const { NodeTracerProvider } = require('@opentelemetry/sdk-trace-node');
10-
const { SimpleSpanProcessor, ConsoleSpanExporter } = require('@opentelemetry/sdk-trace-base');
26+
const {
27+
SimpleSpanProcessor,
28+
ConsoleSpanExporter,
29+
} = require('@opentelemetry/sdk-trace-base');
1130
const { Resource } = require('@opentelemetry/resources');
1231
const { ATTR_SERVICE_NAME } = require('@opentelemetry/semantic-conventions');
1332

14-
const { MemcachedInstrumentation } = require('@opentelemetry/instrumentation-memcached');
33+
const {
34+
MemcachedInstrumentation,
35+
} = require('@opentelemetry/instrumentation-memcached');
1536

16-
module.exports = (serviceName) => {
37+
module.exports = serviceName => {
1738
const exporter = new ConsoleSpanExporter();
1839
const provider = new NodeTracerProvider({
1940
resource: new Resource({
2041
[ATTR_SERVICE_NAME]: serviceName,
2142
}),
22-
spanProcessors: [
23-
new SimpleSpanProcessor(exporter),
24-
],
43+
spanProcessors: [new SimpleSpanProcessor(exporter)],
2544
});
2645
registerInstrumentations({
2746
tracerProvider: provider,
28-
instrumentations: [
29-
new MemcachedInstrumentation(),
30-
],
47+
instrumentations: [new MemcachedInstrumentation()],
3148
});
3249

3350
// Initialize the OpenTelemetry APIs to use the NodeTracerProvider bindings

0 commit comments

Comments
 (0)