diff --git a/examples/network/.eslintrc.js b/examples/network/.eslintrc.js new file mode 100644 index 0000000000..53452072e2 --- /dev/null +++ b/examples/network/.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/network/.npmrc b/examples/network/.npmrc new file mode 100644 index 0000000000..43c97e719a --- /dev/null +++ b/examples/network/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/examples/network/client.js b/examples/network/client.js index 8aad8eb04e..49e7071ebc 100644 --- a/examples/network/client.js +++ b/examples/network/client.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'; const { diag, DiagConsoleLogger, DiagLogLevel } = require('@opentelemetry/api'); @@ -6,14 +22,19 @@ const { HttpInstrumentation } = require('@opentelemetry/instrumentation-http'); const { NetInstrumentation } = require('@opentelemetry/instrumentation-net'); const { DnsInstrumentation } = require('@opentelemetry/instrumentation-dns'); const { registerInstrumentations } = require('@opentelemetry/instrumentation'); -const { SimpleSpanProcessor, ConsoleSpanExporter } = require('@opentelemetry/sdk-trace-base'); +const { + SimpleSpanProcessor, + ConsoleSpanExporter, +} = require('@opentelemetry/sdk-trace-base'); const { JaegerExporter } = require('@opentelemetry/exporter-jaeger'); const provider = new NodeTracerProvider({ spanProcessors: [ - new SimpleSpanProcessor(new JaegerExporter({ - serviceName: 'http-client', - })), + new SimpleSpanProcessor( + new JaegerExporter({ + serviceName: 'http-client', + }) + ), new SimpleSpanProcessor(new ConsoleSpanExporter()), ], }); @@ -39,14 +60,20 @@ require('dns'); const https = require('https'); const http = require('http'); -http.get('http://opentelemetry.io/', () => {}).on('error', (e) => { - console.error(e); -}); +http + .get('http://opentelemetry.io/', () => {}) + .on('error', e => { + console.error(e); + }); -https.get('https://opentelemetry.io/', () => {}).on('error', (e) => { - console.error(e); -}); +https + .get('https://opentelemetry.io/', () => {}) + .on('error', e => { + console.error(e); + }); -https.get('https://opentelemetry.io/', { ca: [] }, () => {}).on('error', (e) => { - console.error(e); -}); +https + .get('https://opentelemetry.io/', { ca: [] }, () => {}) + .on('error', e => { + console.error(e); + }); diff --git a/examples/network/package.json b/examples/network/package.json index 476a81cb57..28a2d4f9df 100644 --- a/examples/network/package.json +++ b/examples/network/package.json @@ -5,6 +5,8 @@ "description": "Example of NET & TLS integration with OpenTelemetry", "main": "index.js", "scripts": { + "lint": "eslint . --ext=ts,js,mjs", + "lint:fix": "eslint . --ext=ts,js,mjs --fix", "zipkin:client": "cross-env EXPORTER=zipkin node ./client.js", "jaeger:client": "cross-env EXPORTER=jaeger node ./client.js" },