Skip to content

Commit fdab642

Browse files
authored
chore: Fix lint warnings in instrumentation package (#2404)
1 parent e8e787d commit fdab642

File tree

7 files changed

+17
-12
lines changed

7 files changed

+17
-12
lines changed

experimental/packages/opentelemetry-instrumentation/src/autoLoaderUtils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export function parseInstrumentationOptions(
2929
): AutoLoaderResult {
3030
let instrumentations: Instrumentation[] = [];
3131
for (let i = 0, j = options.length; i < j; i++) {
32+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
3233
const option = options[i] as any;
3334
if (Array.isArray(option)) {
3435
const results = parseInstrumentationOptions(option);
@@ -53,7 +54,7 @@ export function enableInstrumentations(
5354
instrumentations: Instrumentation[],
5455
tracerProvider?: TracerProvider,
5556
meterProvider?: MeterProvider
56-
) {
57+
): void {
5758
for (let i = 0, j = instrumentations.length; i < j; i++) {
5859
const instrumentation = instrumentations[i];
5960
if (tracerProvider) {
@@ -76,6 +77,6 @@ export function enableInstrumentations(
7677
* Disable instrumentations
7778
* @param instrumentations
7879
*/
79-
export function disableInstrumentations(instrumentations: Instrumentation[]) {
80+
export function disableInstrumentations(instrumentations: Instrumentation[]): void {
8081
instrumentations.forEach(instrumentation => instrumentation.disable());
8182
}

experimental/packages/opentelemetry-instrumentation/src/instrumentation.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,31 +74,31 @@ export abstract class InstrumentationAbstract<T = any>
7474
* Sets MeterProvider to this plugin
7575
* @param meterProvider
7676
*/
77-
public setMeterProvider(meterProvider: MeterProvider) {
77+
public setMeterProvider(meterProvider: MeterProvider): void {
7878
this._meter = meterProvider.getMeter(
7979
this.instrumentationName,
8080
this.instrumentationVersion
8181
);
8282
}
8383

8484
/* Returns InstrumentationConfig */
85-
public getConfig() {
85+
public getConfig(): types.InstrumentationConfig {
8686
return this._config;
8787
}
8888

8989
/**
9090
* Sets InstrumentationConfig to this plugin
9191
* @param InstrumentationConfig
9292
*/
93-
public setConfig(config: types.InstrumentationConfig = {}) {
93+
public setConfig(config: types.InstrumentationConfig = {}): void {
9494
this._config = Object.assign({}, config);
9595
}
9696

9797
/**
9898
* Sets TraceProvider to this plugin
9999
* @param tracerProvider
100100
*/
101-
public setTracerProvider(tracerProvider: TracerProvider) {
101+
public setTracerProvider(tracerProvider: TracerProvider): void {
102102
this._tracer = tracerProvider.getTracer(
103103
this.instrumentationName,
104104
this.instrumentationVersion

experimental/packages/opentelemetry-instrumentation/src/platform/node/instrumentation.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export abstract class InstrumentationBase<T = any>
102102
} else {
103103
// internal file
104104
const files = module.files ?? [];
105-
const file = files.find(file => file.name === name);
105+
const file = files.find(f => f.name === name);
106106
if (file && isSupported(file.supportedVersions, version, module.includePrerelease)) {
107107
file.moduleExports = exports;
108108
if (this._enabled) {
@@ -113,7 +113,7 @@ export abstract class InstrumentationBase<T = any>
113113
return exports;
114114
}
115115

116-
public enable() {
116+
public enable(): void {
117117
if (this._enabled) {
118118
return;
119119
}
@@ -154,7 +154,7 @@ export abstract class InstrumentationBase<T = any>
154154
}
155155
}
156156

157-
public disable() {
157+
public disable(): void {
158158
if (!this._enabled) {
159159
return;
160160
}
@@ -172,7 +172,7 @@ export abstract class InstrumentationBase<T = any>
172172
}
173173
}
174174

175-
public isEnabled() {
175+
public isEnabled(): boolean {
176176
return this._enabled;
177177
}
178178
}

experimental/packages/opentelemetry-instrumentation/src/platform/node/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export interface InstrumentationModuleDefinition<T> {
4545
supportedVersions: string[];
4646

4747
/** Module internal files to be patched */
48+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
4849
files: InstrumentationModuleFile<any>[];
4950

5051
/** If set to true, the includePrerelease check will be included when calling semver.satisfies */

experimental/packages/opentelemetry-instrumentation/src/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,10 @@ export interface InstrumentationConfig {
7777
* This interface defines the params that are be added to the wrapped function
7878
* using the "shimmer.wrap"
7979
*/
80-
export interface ShimWrapped {
80+
export interface ShimWrapped extends Function {
8181
__wrapped: boolean;
82+
// eslint-disable-next-line @typescript-eslint/ban-types
8283
__unwrap: Function;
84+
// eslint-disable-next-line @typescript-eslint/ban-types
8385
__original: Function;
8486
}

experimental/packages/opentelemetry-instrumentation/src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export async function safeExecuteInTheMiddleAsync<T>(
7373
* Checks if certain function has been already wrapped
7474
* @param func
7575
*/
76-
export function isWrapped(func: any) {
76+
export function isWrapped(func: unknown): func is ShimWrapped {
7777
return (
7878
typeof func === 'function' &&
7979
typeof (func as ShimWrapped).__original === 'function' &&

experimental/packages/opentelemetry-instrumentation/test/common/autoLoader.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class FooInstrumentation extends InstrumentationBase {
3434
}
3535

3636
describe('autoLoader', () => {
37+
// eslint-disable-next-line @typescript-eslint/ban-types
3738
let unload: Function | undefined;
3839

3940
afterEach(() => {

0 commit comments

Comments
 (0)