From 7d38b1492ed371c22ae5febb92a608e83c95b1bd Mon Sep 17 00:00:00 2001 From: Caroline Evans Date: Wed, 15 Jul 2020 12:52:55 -0700 Subject: [PATCH] chore: rename plugin to instrumentation --- .../.eslintignore | 0 .../.eslintrc.js | 0 .../.npmignore | 0 .../LICENSE | 0 .../README.md | 22 ++++++++----------- .../package.json | 7 +++--- .../src/index.ts | 0 .../src/koa.ts | 12 +++++----- .../src/types.ts | 0 .../src/utils.ts | 0 .../src/version.ts | 0 .../test/koa-router.test.ts | 8 +++---- .../test/koa.test.ts | 10 ++++----- .../tsconfig.json | 1 - 14 files changed, 27 insertions(+), 33 deletions(-) rename plugins/node/{opentelemetry-plugin-koa => opentelemetry-koa-instrumentation}/.eslintignore (100%) rename plugins/node/{opentelemetry-plugin-koa => opentelemetry-koa-instrumentation}/.eslintrc.js (100%) rename plugins/node/{opentelemetry-plugin-koa => opentelemetry-koa-instrumentation}/.npmignore (100%) rename plugins/node/{opentelemetry-plugin-koa => opentelemetry-koa-instrumentation}/LICENSE (100%) rename plugins/node/{opentelemetry-plugin-koa => opentelemetry-koa-instrumentation}/README.md (76%) rename plugins/node/{opentelemetry-plugin-koa => opentelemetry-koa-instrumentation}/package.json (95%) rename plugins/node/{opentelemetry-plugin-koa => opentelemetry-koa-instrumentation}/src/index.ts (100%) rename plugins/node/{opentelemetry-plugin-koa => opentelemetry-koa-instrumentation}/src/koa.ts (90%) rename plugins/node/{opentelemetry-plugin-koa => opentelemetry-koa-instrumentation}/src/types.ts (100%) rename plugins/node/{opentelemetry-plugin-koa => opentelemetry-koa-instrumentation}/src/utils.ts (100%) rename plugins/node/{opentelemetry-plugin-koa => opentelemetry-koa-instrumentation}/src/version.ts (100%) rename plugins/node/{opentelemetry-plugin-koa => opentelemetry-koa-instrumentation}/test/koa-router.test.ts (96%) rename plugins/node/{opentelemetry-plugin-koa => opentelemetry-koa-instrumentation}/test/koa.test.ts (96%) rename plugins/node/{opentelemetry-plugin-koa => opentelemetry-koa-instrumentation}/tsconfig.json (98%) diff --git a/plugins/node/opentelemetry-plugin-koa/.eslintignore b/plugins/node/opentelemetry-koa-instrumentation/.eslintignore similarity index 100% rename from plugins/node/opentelemetry-plugin-koa/.eslintignore rename to plugins/node/opentelemetry-koa-instrumentation/.eslintignore diff --git a/plugins/node/opentelemetry-plugin-koa/.eslintrc.js b/plugins/node/opentelemetry-koa-instrumentation/.eslintrc.js similarity index 100% rename from plugins/node/opentelemetry-plugin-koa/.eslintrc.js rename to plugins/node/opentelemetry-koa-instrumentation/.eslintrc.js diff --git a/plugins/node/opentelemetry-plugin-koa/.npmignore b/plugins/node/opentelemetry-koa-instrumentation/.npmignore similarity index 100% rename from plugins/node/opentelemetry-plugin-koa/.npmignore rename to plugins/node/opentelemetry-koa-instrumentation/.npmignore diff --git a/plugins/node/opentelemetry-plugin-koa/LICENSE b/plugins/node/opentelemetry-koa-instrumentation/LICENSE similarity index 100% rename from plugins/node/opentelemetry-plugin-koa/LICENSE rename to plugins/node/opentelemetry-koa-instrumentation/LICENSE diff --git a/plugins/node/opentelemetry-plugin-koa/README.md b/plugins/node/opentelemetry-koa-instrumentation/README.md similarity index 76% rename from plugins/node/opentelemetry-plugin-koa/README.md rename to plugins/node/opentelemetry-koa-instrumentation/README.md index 5b1fe6cf5e..e1f17a9acb 100644 --- a/plugins/node/opentelemetry-plugin-koa/README.md +++ b/plugins/node/opentelemetry-koa-instrumentation/README.md @@ -12,16 +12,16 @@ For automatic instrumentation see the ## Installation ```bash -npm install --save @opentelemetry/plugin-koa +npm install --save @opentelemetry/koa-instrumentation ``` ### Supported Versions - - `^2.0.0` + - Koa `^2.0.0` ## Usage OpenTelemetry Koa Instrumentation allows the user to automatically collect trace data and export them to their backend of choice, to give observability to distributed systems. -To load a specific plugin (Koa in this case), specify it in the Node Tracer's configuration. +To load a specific instrumentation (Koa in this case), specify it in the Node Tracer's configuration. ```js const { NodeTracerProvider } = require('@opentelemetry/node'); @@ -30,13 +30,13 @@ const provider = new NodeTracerProvider({ koa: { enabled: true, // You may use a package name or absolute path to the file. - path: '@opentelemetry/plugin-koa', + path: '@opentelemetry/koa-instrumentation', } } }); ``` -To load all of the [supported plugins](https://github.com/open-telemetry/opentelemetry-js#plugins), use below approach. Each plugin is only loaded when the module that it patches is loaded; in other words, there is no computational overhead for listing plugins for unused modules. +To load all of the [supported instrumentations](https://github.com/open-telemetry/opentelemetry-js#plugins), use below approach. Each instrumentation is only loaded when the module that it patches is loaded; in other words, there is no computational overhead for listing instrumentations for unused modules. ```js const { NodeTracerProvider } = require('@opentelemetry/node'); @@ -62,11 +62,7 @@ Apache 2.0 - See [LICENSE][license-url] for more information. [gitter-url]: https://gitter.im/open-telemetry/opentelemetry-node?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge [license-url]: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/master/LICENSE [license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat -[dependencies-image]: https://david-dm.org/open-telemetry/opentelemetry-js-contrib/status.svg?path=plugins/node/opentelemetry-plugin-koa - -[dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js-contrib?path=plugins/node/opentelemetry-plugin-koa - -[devDependencies-image]: https://david-dm.org/open-telemetry/opentelemetry-js-contrib/dev-status.svg?path=plugins/node/opentelemetry-plugin-koa - -[devDependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js-contrib?path=plugins/node/opentelemetry-plugin-koa&type=dev - +[dependencies-image]: https://david-dm.org/open-telemetry/opentelemetry-js-contrib/status.svg?path=plugins/node/opentelemetry-koa-instrumentation +[dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js-contrib?path=plugins/node/opentelemetry-koa-instrumentation +[devDependencies-image]: https://david-dm.org/open-telemetry/opentelemetry-js-contrib/dev-status.svg?path=plugins/node/opentelemetry-koa-instrumentation +[devDependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js-contrib?path=plugins/node/opentelemetry-koa-instrumentation&type=dev diff --git a/plugins/node/opentelemetry-plugin-koa/package.json b/plugins/node/opentelemetry-koa-instrumentation/package.json similarity index 95% rename from plugins/node/opentelemetry-plugin-koa/package.json rename to plugins/node/opentelemetry-koa-instrumentation/package.json index 829953d3be..4cc4491815 100644 --- a/plugins/node/opentelemetry-plugin-koa/package.json +++ b/plugins/node/opentelemetry-koa-instrumentation/package.json @@ -1,5 +1,5 @@ { - "name": "@opentelemetry/plugin-koa", + "name": "@opentelemetry/koa-instrumentation", "version": "0.8.0", "description": "OpenTelemetry Koa automatic instrumentation package.", "main": "build/src/index.js", @@ -23,7 +23,8 @@ "nodejs", "tracing", "profiling", - "plugin" + "plugin", + "instrumentation" ], "author": "OpenTelemetry Authors", "license": "Apache-2.0", @@ -51,6 +52,7 @@ "@types/node": "12.12.47", "@types/shimmer": "1.0.1", "codecov": "3.7.0", + "eslint": "^7.4.0", "gts": "2.0.2", "koa": "^2.13.0", "mocha": "7.2.0", @@ -65,7 +67,6 @@ "dependencies": { "@opentelemetry/api": "^0.9.0", "@opentelemetry/core": "^0.9.0", - "eslint": "^7.4.0", "shimmer": "^1.2.1" } } diff --git a/plugins/node/opentelemetry-plugin-koa/src/index.ts b/plugins/node/opentelemetry-koa-instrumentation/src/index.ts similarity index 100% rename from plugins/node/opentelemetry-plugin-koa/src/index.ts rename to plugins/node/opentelemetry-koa-instrumentation/src/index.ts diff --git a/plugins/node/opentelemetry-plugin-koa/src/koa.ts b/plugins/node/opentelemetry-koa-instrumentation/src/koa.ts similarity index 90% rename from plugins/node/opentelemetry-plugin-koa/src/koa.ts rename to plugins/node/opentelemetry-koa-instrumentation/src/koa.ts index 175cdcf1e7..04b83a713c 100644 --- a/plugins/node/opentelemetry-plugin-koa/src/koa.ts +++ b/plugins/node/opentelemetry-koa-instrumentation/src/koa.ts @@ -33,12 +33,12 @@ import Router = require('@koa/router'); */ export const kLayerPatched: unique symbol = Symbol('koa-layer-patched'); -/** Koa instrumentation plugin for OpenTelemetry */ -export class KoaPlugin extends BasePlugin { +/** Koa instrumentation for OpenTelemetry */ +export class KoaInstrumentation extends BasePlugin { static readonly component = KoaComponentName; constructor(readonly moduleName: string) { - super('@opentelemetry/plugin-koa', VERSION); + super('@opentelemetry/koa-instrumentation', VERSION); } protected patch(): typeof koa { @@ -71,9 +71,9 @@ export class KoaPlugin extends BasePlugin { ) { let patchedFunction; if (middlewareFunction.router) { - patchedFunction = plugin._patchRouterDispatch(middlewareFunction); + patchedFunction = koaInstrumentation._patchRouterDispatch(middlewareFunction); } else { - patchedFunction = plugin._patchLayer(middlewareFunction, false); + patchedFunction = koaInstrumentation._patchLayer(middlewareFunction, false); } args[0] = patchedFunction; @@ -138,4 +138,4 @@ export class KoaPlugin extends BasePlugin { } } -export const plugin = new KoaPlugin(KoaPlugin.component); +export const koaInstrumentation = new KoaInstrumentation(KoaComponentName); diff --git a/plugins/node/opentelemetry-plugin-koa/src/types.ts b/plugins/node/opentelemetry-koa-instrumentation/src/types.ts similarity index 100% rename from plugins/node/opentelemetry-plugin-koa/src/types.ts rename to plugins/node/opentelemetry-koa-instrumentation/src/types.ts diff --git a/plugins/node/opentelemetry-plugin-koa/src/utils.ts b/plugins/node/opentelemetry-koa-instrumentation/src/utils.ts similarity index 100% rename from plugins/node/opentelemetry-plugin-koa/src/utils.ts rename to plugins/node/opentelemetry-koa-instrumentation/src/utils.ts diff --git a/plugins/node/opentelemetry-plugin-koa/src/version.ts b/plugins/node/opentelemetry-koa-instrumentation/src/version.ts similarity index 100% rename from plugins/node/opentelemetry-plugin-koa/src/version.ts rename to plugins/node/opentelemetry-koa-instrumentation/src/version.ts diff --git a/plugins/node/opentelemetry-plugin-koa/test/koa-router.test.ts b/plugins/node/opentelemetry-koa-instrumentation/test/koa-router.test.ts similarity index 96% rename from plugins/node/opentelemetry-plugin-koa/test/koa-router.test.ts rename to plugins/node/opentelemetry-koa-instrumentation/test/koa-router.test.ts index 2823110952..367ca83943 100644 --- a/plugins/node/opentelemetry-plugin-koa/test/koa-router.test.ts +++ b/plugins/node/opentelemetry-koa-instrumentation/test/koa-router.test.ts @@ -25,11 +25,9 @@ import { import * as assert from 'assert'; import * as koa from 'koa'; import * as KoaRouter from '@koa/router'; -// const router = require('@koa/router')(); - import * as http from 'http'; import { AddressInfo } from 'net'; -import { plugin } from '../src'; +import { koaInstrumentation } from '../src'; import { AttributeNames, KoaLayerType, KoaComponentName } from '../src/types'; const httpRequest = { @@ -51,7 +49,7 @@ const httpRequest = { }, }; -describe('Koa Plugin - Router Tests', () => { +describe('Koa Instrumentation - Router Tests', () => { const logger = new NoopLogger(); const provider = new NodeTracerProvider(); const memoryExporter = new InMemorySpanExporter(); @@ -61,7 +59,7 @@ describe('Koa Plugin - Router Tests', () => { let contextManager: AsyncHooksContextManager; before(() => { - plugin.enable(koa, provider, logger); + koaInstrumentation.enable(koa, provider, logger); }); beforeEach(() => { diff --git a/plugins/node/opentelemetry-plugin-koa/test/koa.test.ts b/plugins/node/opentelemetry-koa-instrumentation/test/koa.test.ts similarity index 96% rename from plugins/node/opentelemetry-plugin-koa/test/koa.test.ts rename to plugins/node/opentelemetry-koa-instrumentation/test/koa.test.ts index ef15767339..72af40886a 100644 --- a/plugins/node/opentelemetry-plugin-koa/test/koa.test.ts +++ b/plugins/node/opentelemetry-koa-instrumentation/test/koa.test.ts @@ -26,7 +26,7 @@ import * as assert from 'assert'; import * as koa from 'koa'; import * as http from 'http'; import { AddressInfo } from 'net'; -import { plugin } from '../src'; +import { koaInstrumentation } from '../src'; import { AttributeNames, KoaLayerType, KoaComponentName } from '../src/types'; const httpRequest = { @@ -48,7 +48,7 @@ const httpRequest = { }, }; -describe('Koa Plugin - Core Tests', () => { +describe('Koa Instrumentation - Core Tests', () => { const logger = new NoopLogger(); const provider = new NodeTracerProvider(); const memoryExporter = new InMemorySpanExporter(); @@ -58,7 +58,7 @@ describe('Koa Plugin - Core Tests', () => { let contextManager: AsyncHooksContextManager; before(() => { - plugin.enable(koa, provider, logger); + koaInstrumentation.enable(koa, provider, logger); }); beforeEach(() => { @@ -195,9 +195,9 @@ describe('Koa Plugin - Core Tests', () => { }); }); - describe('Disabling plugin', () => { + describe('Disabling koa instrumentation', () => { it('should not create new spans', async () => { - plugin.disable(); + koaInstrumentation.disable(); const rootSpan = tracer.startSpan('rootSpan'); const app = new koa(); app.use(customMiddleware); diff --git a/plugins/node/opentelemetry-plugin-koa/tsconfig.json b/plugins/node/opentelemetry-koa-instrumentation/tsconfig.json similarity index 98% rename from plugins/node/opentelemetry-plugin-koa/tsconfig.json rename to plugins/node/opentelemetry-koa-instrumentation/tsconfig.json index 505b67a248..ec22e03b9e 100644 --- a/plugins/node/opentelemetry-plugin-koa/tsconfig.json +++ b/plugins/node/opentelemetry-koa-instrumentation/tsconfig.json @@ -9,4 +9,3 @@ "test/**/*.ts" ] } - \ No newline at end of file