From fd343ad7becb06c36aef2bae89c9ce3d8f4faf15 Mon Sep 17 00:00:00 2001 From: Trent Mick Date: Thu, 26 Jun 2025 10:59:23 -0700 Subject: [PATCH] chore(examples): lint examples/ioredis using shared top-level eslint config Refs: https://github.com/open-telemetry/opentelemetry-js-contrib/issues/2891 --- examples/ioredis/.eslintrc.js | 26 ++++++++++++++++++++++++++ examples/ioredis/.npmrc | 1 + examples/ioredis/index.js | 24 ++++++++++++++++++++++-- examples/ioredis/package.json | 2 ++ examples/ioredis/tracer.js | 28 +++++++++++++++++++++------- 5 files changed, 72 insertions(+), 9 deletions(-) create mode 100644 examples/ioredis/.eslintrc.js create mode 100644 examples/ioredis/.npmrc diff --git a/examples/ioredis/.eslintrc.js b/examples/ioredis/.eslintrc.js new file mode 100644 index 0000000000..53452072e2 --- /dev/null +++ b/examples/ioredis/.eslintrc.js @@ -0,0 +1,26 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +'use strict'; + +const baseConfig = require('../../eslint.config'); + +module.exports = { + ...baseConfig, + env: { + node: true, + }, +}; diff --git a/examples/ioredis/.npmrc b/examples/ioredis/.npmrc new file mode 100644 index 0000000000..43c97e719a --- /dev/null +++ b/examples/ioredis/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/examples/ioredis/index.js b/examples/ioredis/index.js index a3cea532fc..72fc79e879 100644 --- a/examples/ioredis/index.js +++ b/examples/ioredis/index.js @@ -1,3 +1,19 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + 'use strict'; // Require tracer before any other modules @@ -16,8 +32,12 @@ async function main() { // The process must live for at least the interval past any traces that // must be exported, or some risk being lost if they are recorded after the // last export. - console.log('Sleeping 5 seconds before shutdown to ensure all records are flushed.'); - setTimeout(() => { console.log('Completed.'); }, 5000); + console.log( + 'Sleeping 5 seconds before shutdown to ensure all records are flushed.' + ); + setTimeout(() => { + console.log('Completed.'); + }, 5000); } main(); diff --git a/examples/ioredis/package.json b/examples/ioredis/package.json index 478114f645..4c69631713 100644 --- a/examples/ioredis/package.json +++ b/examples/ioredis/package.json @@ -5,6 +5,8 @@ "description": "Example of HTTP integration with OpenTelemetry", "main": "index.js", "scripts": { + "lint": "eslint . --ext=ts,js,mjs", + "lint:fix": "eslint . --ext=ts,js,mjs --fix", "docker:start": "docker run -d -p 6379:6379 --name otjsredis redis:alpine", "docker:stop": "docker stop otjsredis && docker rm otjsredis", "start": "node index.js" diff --git a/examples/ioredis/tracer.js b/examples/ioredis/tracer.js index 1b0701cd76..17cac01d06 100644 --- a/examples/ioredis/tracer.js +++ b/examples/ioredis/tracer.js @@ -1,27 +1,41 @@ +/* + * Copyright The OpenTelemetry Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + 'use strict'; const opentelemetry = require('@opentelemetry/api'); const { NodeTracerProvider } = require('@opentelemetry/sdk-trace-node'); const { SimpleSpanProcessor } = require('@opentelemetry/sdk-trace-base'); const { JaegerExporter } = require('@opentelemetry/exporter-jaeger'); -const { IORedisInstrumentation } = require('@opentelemetry/instrumentation-ioredis'); +const { + IORedisInstrumentation, +} = require('@opentelemetry/instrumentation-ioredis'); const { registerInstrumentations } = require('@opentelemetry/instrumentation'); const exporter = new JaegerExporter({ serviceName: 'ioredis-example' }); const provider = new NodeTracerProvider({ - spanProcessors: [ - new SimpleSpanProcessor(exporter), - ], + spanProcessors: [new SimpleSpanProcessor(exporter)], }); // Initialize the OpenTelemetry APIs to use the BasicTracer bindings provider.register(); registerInstrumentations({ - instrumentations: [ - new IORedisInstrumentation(), - ], + instrumentations: [new IORedisInstrumentation()], tracerProvider: provider, });