Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Plugin loader #126

Merged
merged 15 commits into from
Aug 5, 2019
Merged
Prev Previous commit
Next Next commit
fix: move the any to the Plugin type
  • Loading branch information
mayurkale22 committed Aug 5, 2019
commit cd8a6a37456d223f2ff181a0b06a0fe6c9f0cdc5
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,13 @@ interface PluginConfig {
[pluginName: string]: boolean;
}

// tslint:disable-next-line:no-any
export type PluginType = Array<Plugin<any>>;

/**
* The PluginLoader class can load instrumentation plugins that
* use a patch mechanism to enable automatic tracing for
* specific target modules.
* The PluginLoader class can load instrumentation plugins that use a patch
* mechanism to enable automatic tracing for specific target modules.
*/
export class PluginLoader {
/** A list of loaded plugins. */
private _plugins: PluginType = [];
private _plugins: Plugin[] = [];
/**
* A field that tracks whether the require-in-the-middle hook has been loaded
* for the first time, as well as whether the hook body is activated or not.
Expand Down Expand Up @@ -104,8 +100,7 @@ export class PluginLoader {

// Expecting a plugin from module;
try {
// tslint:disable-next-line:no-any
const plugin: Plugin<any> = require(moduleName).plugin;
const plugin: Plugin = require(moduleName).plugin;
this._plugins.push(plugin);
// Enable each supported plugin.
return plugin.enable(exports, this.tracer);
mayurkale22 marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
import { Tracer } from '../tracer';

/** Interface Plugin to apply patch. */
export interface Plugin<T> {
// tslint:disable-next-line:no-any
export interface Plugin<T = any> {
/**
* Method that enables the instrumentation patch.
* @param moduleExports The value of the `module.exports` property that would
Expand Down