Skip to content

Commit

Permalink
refactor: plugin.enable has logger param
Browse files Browse the repository at this point in the history
Signed-off-by: Olivier Albertini <[email protected]>
  • Loading branch information
OlivierAlbertini committed Aug 30, 2019
1 parent f3c1805 commit d612642
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 19 deletions.
16 changes: 2 additions & 14 deletions packages/opentelemetry-plugin-http/src/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,8 @@
* limitations under the License.
*/

import { BasePlugin, NoopLogger, isValid } from '@opentelemetry/core';
import {
Span,
SpanKind,
SpanOptions,
Logger,
Tracer,
Attributes,
} from '@opentelemetry/types';
import { BasePlugin, isValid } from '@opentelemetry/core';
import { Span, SpanKind, SpanOptions, Attributes } from '@opentelemetry/types';
import {
ClientRequest,
IncomingMessage,
Expand Down Expand Up @@ -51,14 +44,9 @@ import { Utils } from './utils';
export class HttpPlugin extends BasePlugin<Http> {
static readonly component = 'http';
options!: HttpPluginConfig;
protected _logger!: Logger;
protected readonly _tracer!: Tracer;

constructor(readonly moduleName: string, readonly version: string) {
super();
// TODO: remove this once a logger will be passed
// https://github.com/open-telemetry/opentelemetry-js/issues/193
this._logger = new NoopLogger();
// TODO: remove this once options will be passed
// see https://github.com/open-telemetry/opentelemetry-js/issues/210
this.options = {};
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-plugin-http/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ export * from './http';
export * from './types';
export * from './utils';
export * from './enums/attributeNames';
export * from './enums/format';
export * from './enums/format';
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('HttpPlugin', () => {
nock.cleanAll();
nock.enableNetConnect();

plugin.enable(http, tracer);
plugin.enable(http, tracer, tracer.logger);
server = http.createServer((request, response) => {
response.end('Test Server Response');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe('HttpPlugin', () => {
});

before(() => {
plugin.enable(http, tracer);
plugin.enable(http, tracer, tracer.logger);
const ignoreConfig = [
`http://${hostname}:${serverPort}/ignored/string`,
/\/ignored\/regexp$/i,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('Packages', () => {
});

before(() => {
plugin.enable(http, tracer);
plugin.enable(http, tracer, tracer.logger);
});

after(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe('HttpPlugin Integration tests', () => {

before(() => {
plugin.disable();
plugin.enable(http, tracer);
plugin.enable(http, tracer, tracer.logger);
const ignoreConfig = [
`http://${hostname}:${serverPort}/ignored/string`,
/\/ignored\/regexp$/i,
Expand Down

0 comments on commit d612642

Please sign in to comment.