Skip to content

Commit 83ad899

Browse files
committed
refactor(instrumentation-http): fix eslint warnings
``` /home/runner/work/opentelemetry-js/opentelemetry-js/experimental/packages/opentelemetry-instrumentation-http/src/http.ts 1051:15 warning Don't use `Function` as a type @typescript-eslint/ban-types ``` Be explict about what type of functions we are expecting here. Ref open-telemetry#5365
1 parent de724a6 commit 83ad899

File tree

1 file changed

+19
-4
lines changed
  • experimental/packages/opentelemetry-instrumentation-http/src

1 file changed

+19
-4
lines changed

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

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ import type * as http from 'http';
3939
import type * as https from 'https';
4040
import { Socket } from 'net';
4141
import * as url from 'url';
42-
import { HttpInstrumentationConfig } from './types';
42+
import {
43+
HttpInstrumentationConfig,
44+
StartOutgoingSpanCustomAttributeFunction,
45+
} from './types';
4346
import { VERSION } from './version';
4447
import {
4548
InstrumentationBase,
@@ -89,6 +92,7 @@ import {
8992
Https,
9093
SemconvStability,
9194
} from './internal-types';
95+
import { StartIncomingSpanCustomAttributeFunction } from './types';
9296

9397
/**
9498
* This is by no means general-purpose nor completely safe, but for the purpose
@@ -1064,13 +1068,24 @@ export class HttpInstrumentation extends InstrumentationBase<HttpInstrumentation
10641068
}
10651069
}
10661070

1071+
private _callStartSpanHook(
1072+
request: http.IncomingMessage,
1073+
hookFunc: StartIncomingSpanCustomAttributeFunction | undefined
1074+
): Attributes;
1075+
private _callStartSpanHook(
1076+
request: http.RequestOptions,
1077+
hookFunc: StartOutgoingSpanCustomAttributeFunction | undefined
1078+
): Attributes;
10671079
private _callStartSpanHook(
10681080
request: http.IncomingMessage | http.RequestOptions,
1069-
hookFunc: Function | undefined
1070-
) {
1081+
hookFunc:
1082+
| StartIncomingSpanCustomAttributeFunction
1083+
| StartOutgoingSpanCustomAttributeFunction
1084+
| undefined
1085+
): Attributes | void {
10711086
if (typeof hookFunc === 'function') {
10721087
return safeExecuteInTheMiddle(
1073-
() => hookFunc(request),
1088+
() => hookFunc(request as http.IncomingMessage & http.RequestOptions),
10741089
() => {},
10751090
true
10761091
);

0 commit comments

Comments
 (0)