Skip to content

Commit

Permalink
chore: address more PR reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
vmarchaud committed Feb 13, 2020
1 parent 5ac0053 commit fe66b6f
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ OpenTelemetry can collect tracing data automatically using plugins. Vendors/User
- [@opentelemetry/plugin-redis][otel-plugin-redis]
- [@opentelemetry/plugin-ioredis][otel-plugin-ioredis]
- [@opentelemetry/plugin-dns][otel-plugin-dns] - By default, this plugin is not loaded [#612](https://github.com/open-telemetry/opentelemetry-js/issues/612)
- [@opentelemetry/plugin-express][otel-plugin-express]
- [@opentelemetry/plugin-express][otel-plugin-express] - By default, this plugin is not loaded

#### Web Plugins
- [@opentelemetry/plugin-document-load][otel-plugin-document-load]
Expand Down
8 changes: 4 additions & 4 deletions packages/opentelemetry-plugin-express/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ OpenTelemetry Express Instrumentation allows the user to automatically collect t

To load a specific plugin (express in this case), specify it in the Node Tracer's configuration.
```js
const { NodeTracerRegistry } = require('@opentelemetry/node');
const { NodeTracerProvider } = require('@opentelemetry/node');

const registry = new NodeTracerRegistry({
const provider = new NodeTracerProvider({
plugins: {
express: {
enabled: true,
Expand All @@ -38,9 +38,9 @@ const registry = new NodeTracerRegistry({

To load all 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.
```js
const { NodeTracerRegistry } = require('@opentelemetry/node');
const { NodeTracerProvider } = require('@opentelemetry/node');

const registry = new NodeTracerRegistry();
const provider = new NodeTracerProvider();
```

See [examples/express](https://github.com/open-telemetry/opentelemetry-js/tree/master/examples/express) for a short example.
Expand Down
8 changes: 4 additions & 4 deletions packages/opentelemetry-plugin-express/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
"access": "public"
},
"devDependencies": {
"@opentelemetry/node": "^0.3.2",
"@opentelemetry/tracing": "^0.3.2",
"@opentelemetry/node": "^0.4.0",
"@opentelemetry/tracing": "^0.4.0",
"@types/express": "^4.17.2",
"@types/mocha": "^5.2.7",
"@types/node": "^12.7.2",
Expand All @@ -60,8 +60,8 @@
"typescript": "3.7.2"
},
"dependencies": {
"@opentelemetry/core": "^0.3.2",
"@opentelemetry/types": "^0.3.2",
"@opentelemetry/core": "^0.4.0",
"@opentelemetry/api": "^0.4.0",
"shimmer": "^1.2.1"
}
}
10 changes: 5 additions & 5 deletions packages/opentelemetry-plugin-express/src/express.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2019, OpenTelemetry Authors
* Copyright 2020, OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,7 +15,7 @@
*/

import { BasePlugin } from '@opentelemetry/core';
import { Attributes } from '@opentelemetry/types';
import { Attributes } from '@opentelemetry/api';
import * as express from 'express';
import * as core from 'express-serve-static-core';
import * as shimmer from 'shimmer';
Expand Down Expand Up @@ -46,7 +46,7 @@ export const kLayerPatched: unique symbol = Symbol('express-layer-patched');

/** Express instrumentation plugin for OpenTelemetry */
export class ExpressPlugin extends BasePlugin<typeof express> {
readonly _COMPONENT = 'express';
static readonly component = 'express';
readonly supportedVersions = ['^4.0.0'];
protected _config!: ExpressPluginConfig;

Expand Down Expand Up @@ -176,7 +176,7 @@ export class ExpressPlugin extends BasePlugin<typeof express> {
storeLayerPath(req, layerPath);
const route = (req[_LAYERS_STORE_PROPERTY] as string[]).join('');
const attributes: Attributes = {
[AttributeNames.COMPONENT]: plugin._COMPONENT,
[AttributeNames.COMPONENT]: ExpressPlugin.component,
[AttributeNames.HTTP_ROUTE]: route.length > 0 ? route : undefined,
};
const metadata = getLayerMetadata(layer, layerPath);
Expand Down Expand Up @@ -217,4 +217,4 @@ export class ExpressPlugin extends BasePlugin<typeof express> {
}
}

export const plugin = new ExpressPlugin('express');
export const plugin = new ExpressPlugin(ExpressPlugin.component);
2 changes: 1 addition & 1 deletion packages/opentelemetry-plugin-express/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2019, OpenTelemetry Authors
* Copyright 2020, OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions packages/opentelemetry-plugin-express/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2019, OpenTelemetry Authors
* Copyright 2020, OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,7 +16,7 @@

import { kLayerPatched } from './express';
import { Request } from 'express';
import { PluginConfig, Attributes } from '@opentelemetry/types';
import { PluginConfig, Attributes } from '@opentelemetry/api';

/**
* This const define where on the `request` object the plugin will mount the
Expand Down
4 changes: 2 additions & 2 deletions packages/opentelemetry-plugin-express/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2019, OpenTelemetry Authors
* Copyright 2020, OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { CanonicalCode, Span, Attributes } from '@opentelemetry/types';
import { CanonicalCode, Span, Attributes } from '@opentelemetry/api';
import {
ExpressLayer,
AttributeNames,
Expand Down
14 changes: 7 additions & 7 deletions packages/opentelemetry-plugin-express/test/express.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2019, OpenTelemetry Authors
* Copyright 2020, OpenTelemetry Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { NodeTracerRegistry } from '@opentelemetry/node';
import { NodeTracerProvider } from '@opentelemetry/node';
import * as assert from 'assert';
import * as express from 'express';
import * as http from 'http';
Expand Down Expand Up @@ -52,14 +52,14 @@ const httpRequest = {

describe('Express Plugin', () => {
const logger = new NoopLogger();
const registry = new NodeTracerRegistry();
const provider = new NodeTracerProvider();
const memoryExporter = new InMemorySpanExporter();
const spanProcessor = new SimpleSpanProcessor(memoryExporter);
registry.addSpanProcessor(spanProcessor);
const tracer = registry.getTracer('default');
provider.addSpanProcessor(spanProcessor);
const tracer = provider.getTracer('default');

before(() => {
plugin.enable(express, registry, logger);
plugin.enable(express, provider, logger);
});

afterEach(() => {
Expand Down Expand Up @@ -138,7 +138,7 @@ describe('Express Plugin', () => {
const config: ExpressPluginConfig = {
ignoreLayersType: [ExpressLayerType.MIDDLEWARE],
};
plugin.enable(express, registry, logger, config);
plugin.enable(express, provider, logger, config);
const rootSpan = tracer.startSpan('rootSpan');
const app = express();
app.use(express.json());
Expand Down

0 comments on commit fe66b6f

Please sign in to comment.