1 | /**
|
2 | * Copyright 2018, OpenCensus Authors
|
3 | *
|
4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | * you may not use this file except in compliance with the License.
|
6 | * You may obtain a copy of the License at
|
7 | *
|
8 | * http://www.apache.org/licenses/LICENSE-2.0
|
9 | *
|
10 | * Unless required by applicable law or agreed to in writing, software
|
11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 | * See the License for the specific language governing permissions and
|
14 | * limitations under the License.
|
15 | */
|
16 | import { Stats } from '../../stats/types';
|
17 | import { Span, TracerBase } from '../model/types';
|
18 | /** Interface Plugin to apply patch. */
|
19 | export interface Plugin {
|
20 | /**
|
21 | * Method that enables the instrumentation patch.
|
22 | *
|
23 | * @param moduleExports nodejs module exports from the module to patch
|
24 | * @param tracer a tracer instance
|
25 | * @param version version of the current instaled module to patch
|
26 | * @param options plugin options
|
27 | * @param basedir an optional module absolute path
|
28 | * @param stats an optional stats instance
|
29 | */
|
30 | enable<T>(moduleExports: T, tracer: TracerBase, version: string, options: PluginConfig, basedir?: string, stats?: Stats): T;
|
31 | /** Method to disable the instrumentation */
|
32 | disable(): void;
|
33 | }
|
34 | /**
|
35 | * Function that can be provided to plugin in order to add custom
|
36 | * attributes to spans
|
37 | */
|
38 | export interface CustomAttributeFunction {
|
39 | (span: Span, ...rest: any[]): void;
|
40 | }
|
41 | export interface PluginConfig {
|
42 | [key: string]: any;
|
43 | applyCustomAttributesOnSpan?: CustomAttributeFunction;
|
44 | }
|
45 | export interface NamedPluginConfig {
|
46 | module: string;
|
47 | config: PluginConfig;
|
48 | }
|
49 | /**
|
50 | * Type PluginNames: each key should be the name of the module to trace,
|
51 | * and its value should be the name of the package which has the
|
52 | * plugin implementation.
|
53 | */
|
54 | export interface PluginNames {
|
55 | [pluginName: string]: string | NamedPluginConfig;
|
56 | }
|
57 | export interface PluginInternalFilesVersion {
|
58 | [pluginName: string]: string;
|
59 | }
|
60 | /**
|
61 | * Each key should be the name of the module to trace, and its value
|
62 | * a mapping of a property name to a internal plugin file name.
|
63 | */
|
64 | export interface PluginInternalFiles {
|
65 | [versions: string]: PluginInternalFilesVersion;
|
66 | }
|