Skip to content

Commit

Permalink
chore: rename plugin to instrumentation
Browse files Browse the repository at this point in the history
  • Loading branch information
carolinee21 committed Jul 15, 2020
1 parent befe3f6 commit 7d38b14
Show file tree
Hide file tree
Showing 14 changed files with 27 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand All @@ -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');

Expand All @@ -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
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -23,7 +23,8 @@
"nodejs",
"tracing",
"profiling",
"plugin"
"plugin",
"instrumentation"
],
"author": "OpenTelemetry Authors",
"license": "Apache-2.0",
Expand Down Expand Up @@ -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",
Expand All @@ -65,7 +67,6 @@
"dependencies": {
"@opentelemetry/api": "^0.9.0",
"@opentelemetry/core": "^0.9.0",
"eslint": "^7.4.0",
"shimmer": "^1.2.1"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof koa> {
/** Koa instrumentation for OpenTelemetry */
export class KoaInstrumentation extends BasePlugin<typeof koa> {
static readonly component = KoaComponentName;

constructor(readonly moduleName: string) {
super('@opentelemetry/plugin-koa', VERSION);
super('@opentelemetry/koa-instrumentation', VERSION);
}

protected patch(): typeof koa {
Expand Down Expand Up @@ -71,9 +71,9 @@ export class KoaPlugin extends BasePlugin<typeof koa> {
) {
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;
Expand Down Expand Up @@ -138,4 +138,4 @@ export class KoaPlugin extends BasePlugin<typeof koa> {
}
}

export const plugin = new KoaPlugin(KoaPlugin.component);
export const koaInstrumentation = new KoaInstrumentation(KoaComponentName);
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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();
Expand All @@ -61,7 +59,7 @@ describe('Koa Plugin - Router Tests', () => {
let contextManager: AsyncHooksContextManager;

before(() => {
plugin.enable(koa, provider, logger);
koaInstrumentation.enable(koa, provider, logger);
});

beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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();
Expand All @@ -58,7 +58,7 @@ describe('Koa Plugin - Core Tests', () => {
let contextManager: AsyncHooksContextManager;

before(() => {
plugin.enable(koa, provider, logger);
koaInstrumentation.enable(koa, provider, logger);
});

beforeEach(() => {
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@
"test/**/*.ts"
]
}

0 comments on commit 7d38b14

Please sign in to comment.