diff --git a/examples/connect/.eslintrc.js b/examples/connect/.eslintrc.js new file mode 100644 index 0000000000..53452072e2 --- /dev/null +++ b/examples/connect/.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/connect/.npmrc b/examples/connect/.npmrc new file mode 100644 index 0000000000..43c97e719a --- /dev/null +++ b/examples/connect/.npmrc @@ -0,0 +1 @@ +package-lock=false diff --git a/examples/connect/client.js b/examples/connect/client.js index 265710d3b1..ea0fb965e9 100644 --- a/examples/connect/client.js +++ b/examples/connect/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'; // eslint-disable-next-line import/order diff --git a/examples/connect/package.json b/examples/connect/package.json index 55d36afffb..2464566f48 100644 --- a/examples/connect/package.json +++ b/examples/connect/package.json @@ -5,6 +5,8 @@ "description": "Example of Connect integration with OpenTelemetry", "main": "index.js", "scripts": { + "lint": "eslint . --ext=ts,js,mjs", + "lint:fix": "eslint . --ext=ts,js,mjs --fix", "client": "node ./client.js", "docker:start": "cd ./docker && docker-compose down && docker-compose up", "docker:stop": "cd ./docker && docker-compose down", diff --git a/examples/connect/server.js b/examples/connect/server.js index 0c70584891..2f19b0b771 100644 --- a/examples/connect/server.js +++ b/examples/connect/server.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'; // eslint-disable-next-line @@ -21,7 +37,9 @@ app.use((req, res, next) => { }); app.use('/run_test', async (req, res) => { - const result = await axios.get('https://raw.githubusercontent.com/open-telemetry/opentelemetry-js/main/package.json'); + const result = await axios.get( + 'https://raw.githubusercontent.com/open-telemetry/opentelemetry-js/main/package.json' + ); tracing.log('sending response'); res.end(`OK ${result.data.version}`); diff --git a/examples/connect/tracing.js b/examples/connect/tracing.js index ab9aded9c5..56490623c6 100644 --- a/examples/connect/tracing.js +++ b/examples/connect/tracing.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 opentelemetry = require('@opentelemetry/api'); @@ -12,7 +28,9 @@ const { NodeTracerProvider } = require('@opentelemetry/sdk-trace-node'); const { SimpleSpanProcessor } = require('@opentelemetry/sdk-trace-base'); const { CollectorTraceExporter } = require('@opentelemetry/exporter-collector'); -const { ConnectInstrumentation } = require('@opentelemetry/instrumentation-connect'); +const { + ConnectInstrumentation, +} = require('@opentelemetry/instrumentation-connect'); const { HttpInstrumentation } = require('@opentelemetry/instrumentation-http'); function log() { @@ -21,15 +39,13 @@ function log() { console.log.apply(this, args); } -module.exports = (serviceName) => { +module.exports = serviceName => { const exporter = new CollectorTraceExporter(); const provider = new NodeTracerProvider({ resource: new Resource({ [ATTR_SERVICE_NAME]: serviceName, }), - spanProcessors: [ - new SimpleSpanProcessor(exporter), - ], + spanProcessors: [new SimpleSpanProcessor(exporter)], }); const connectInstrumentation = new ConnectInstrumentation(); registerInstrumentations({