UNPKG

@opencensus/nodejs-base

Version:

OpenCensus is a toolkit for collecting application performance and behavior data.

78 lines (77 loc) 2.83 kB
/** * Copyright 2018, OpenCensus Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { Logger, Plugin, PluginNames, Stats, TracerBase } from '@opencensus/core'; /** * The PluginLoader class can load instrumentation plugins that * use a patch mechanism to enable automatic tracing for * specific target modules. */ export declare class PluginLoader { /** The tracer */ private tracer; /** logger */ private logger; /** The stats */ private stats?; /** A list of loaded plugins. */ plugins: Plugin[]; /** * A field that tracks whether the r-i-t-m hook has been loaded for the * first time, as well as whether the hook body is enabled or not. */ private hookState; /** * Constructs a new PluginLoader instance. * @param tracer The tracer. */ constructor(logger: Logger, tracer: TracerBase, stats?: Stats); /** * Gets the default package name for a target module. The default package * name uses the default scope and a default prefix. * @param moduleName The module name. * @returns The default name for that package. */ private static defaultPackageName; /** * Returns a PluginNames object, build from a string array of target modules * names, using the defaultPackageName. * @param modulesToPatch A list of modules to patch. * @returns Plugin names. */ static defaultPluginsFromArray(modulesToPatch: string[]): PluginNames; /** * Gets the package version. * @param name Name. * @param basedir The base directory. */ private getPackageVersion; /** * Loads a list of plugins (using a map of the target module name * and its instrumentation plugin package name). Each plugin module * should implement the core Plugin interface and export an instance * named as "plugin". This function will attach a hook to be called * the first time the module is loaded. * @param pluginList A list of plugins. */ loadPlugins(pluginList: PluginNames): void; /** Unloads plugins. */ unloadPlugins(): void; /** * Adds a search path for plugin modules. Intended for testing purposes only. * @param searchPath The path to add. */ static set searchPathForTest(searchPath: string); }