Skip to content

Commit

Permalink
fix(plugin-https): typings
Browse files Browse the repository at this point in the history
Signed-off-by: Olivier Albertini <[email protected]>
  • Loading branch information
OlivierAlbertini committed Nov 16, 2019
1 parent cf5bed1 commit c4b33c1
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 9 deletions.
3 changes: 2 additions & 1 deletion packages/opentelemetry-plugin-http/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ export type HttpRequestArgs = Array<HttpCallbackOptional | RequestSignature>;

export type ParsedRequestOptions = (
| http.RequestOptions
| Omit<url.UrlWithParsedQuery, 'query'>) & {
| Omit<url.UrlWithParsedQuery, 'query'>
) & {
protocol?: string | null;
query?: string | ParsedUrlQuery | null;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const assertSpan = (
hostname: string;
pathname: string;
reqHeaders?: http.OutgoingHttpHeaders;
path?: string | null;
path?: string | null;
forceStatus?: Status;
component: string;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/opentelemetry-plugin-http/test/utils/httpRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ export const httpRequest = {
}> => {
const _options =
typeof options === 'string'
? Object.assign(url.parse(options), {
? (Object.assign(url.parse(options), {
headers: {
'user-agent': 'http-plugin-test',
},
}) as RequestOptions
}) as RequestOptions)
: options;
return new Promise((resolve, reject) => {
const req = http.get(_options, (resp: http.IncomingMessage) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { assertSpan } from '../utils/assertSpan';
import { DummyPropagation } from '../utils/DummyPropagation';
import { httpsRequest } from '../utils/httpsRequest';
import * as utils from '../utils/utils';
import { RequestOptions } from 'https';

const serverPort = 42345;
const hostname = 'localhost';
Expand Down Expand Up @@ -140,7 +141,7 @@ describe('HttpsPlugin Integration tests', () => {
const options = Object.assign(
{ headers: { Expect: '100-continue' } },
url.parse('https://google.fr/')
);
) as RequestOptions;

const result = await httpsRequest.get(options);
spans = memoryExporter.getFinishedSpans();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const assertSpan = (
hostname: string;
pathname: string;
reqHeaders?: http.OutgoingHttpHeaders;
path?: string;
path?: string | null;
component: string;
}
) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';

export const httpsRequest = {
get: (
options: string | RequestOptions
options: string | RequestOptions | url.URL
): Promise<{
data: string;
statusCode: number | undefined;
Expand All @@ -33,11 +33,11 @@ export const httpsRequest = {
}> => {
const _options =
typeof options === 'string'
? Object.assign(url.parse(options), {
? (Object.assign(url.parse(options), {
headers: {
'user-agent': 'https-plugin-test',
},
})
}) as RequestOptions)
: options;
return new Promise((resolve, reject) => {
const req = https.get(_options, (resp: http.IncomingMessage) => {
Expand Down

0 comments on commit c4b33c1

Please sign in to comment.