From c4b33c12538039827f8e69d81e88ffbba9d20947 Mon Sep 17 00:00:00 2001 From: Olivier Albertini Date: Sat, 16 Nov 2019 15:40:54 -0500 Subject: [PATCH] fix(plugin-https): typings Signed-off-by: Olivier Albertini --- packages/opentelemetry-plugin-http/src/types.ts | 3 ++- packages/opentelemetry-plugin-http/test/utils/assertSpan.ts | 2 +- .../opentelemetry-plugin-http/test/utils/httpRequest.ts | 4 ++-- .../test/integrations/https-enable.test.ts | 3 ++- .../opentelemetry-plugin-https/test/utils/assertSpan.ts | 2 +- .../opentelemetry-plugin-https/test/utils/httpsRequest.ts | 6 +++--- 6 files changed, 11 insertions(+), 9 deletions(-) diff --git a/packages/opentelemetry-plugin-http/src/types.ts b/packages/opentelemetry-plugin-http/src/types.ts index 8412db26d7..acdfbc7508 100644 --- a/packages/opentelemetry-plugin-http/src/types.ts +++ b/packages/opentelemetry-plugin-http/src/types.ts @@ -41,7 +41,8 @@ export type HttpRequestArgs = Array; export type ParsedRequestOptions = ( | http.RequestOptions - | Omit) & { + | Omit +) & { protocol?: string | null; query?: string | ParsedUrlQuery | null; }; diff --git a/packages/opentelemetry-plugin-http/test/utils/assertSpan.ts b/packages/opentelemetry-plugin-http/test/utils/assertSpan.ts index 0c6fd899e5..eccf35bc7a 100644 --- a/packages/opentelemetry-plugin-http/test/utils/assertSpan.ts +++ b/packages/opentelemetry-plugin-http/test/utils/assertSpan.ts @@ -33,7 +33,7 @@ export const assertSpan = ( hostname: string; pathname: string; reqHeaders?: http.OutgoingHttpHeaders; - path?: string | null; + path?: string | null; forceStatus?: Status; component: string; } diff --git a/packages/opentelemetry-plugin-http/test/utils/httpRequest.ts b/packages/opentelemetry-plugin-http/test/utils/httpRequest.ts index dd20a4928f..8193cd13af 100644 --- a/packages/opentelemetry-plugin-http/test/utils/httpRequest.ts +++ b/packages/opentelemetry-plugin-http/test/utils/httpRequest.ts @@ -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) => { diff --git a/packages/opentelemetry-plugin-https/test/integrations/https-enable.test.ts b/packages/opentelemetry-plugin-https/test/integrations/https-enable.test.ts index a3ad0e487f..bf35940a2b 100644 --- a/packages/opentelemetry-plugin-https/test/integrations/https-enable.test.ts +++ b/packages/opentelemetry-plugin-https/test/integrations/https-enable.test.ts @@ -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'; @@ -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(); diff --git a/packages/opentelemetry-plugin-https/test/utils/assertSpan.ts b/packages/opentelemetry-plugin-https/test/utils/assertSpan.ts index f89aa5b5b6..639a16d989 100644 --- a/packages/opentelemetry-plugin-https/test/utils/assertSpan.ts +++ b/packages/opentelemetry-plugin-https/test/utils/assertSpan.ts @@ -35,7 +35,7 @@ export const assertSpan = ( hostname: string; pathname: string; reqHeaders?: http.OutgoingHttpHeaders; - path?: string; + path?: string | null; component: string; } ) => { diff --git a/packages/opentelemetry-plugin-https/test/utils/httpsRequest.ts b/packages/opentelemetry-plugin-https/test/utils/httpsRequest.ts index c5436be763..3a8c24c87e 100644 --- a/packages/opentelemetry-plugin-https/test/utils/httpsRequest.ts +++ b/packages/opentelemetry-plugin-https/test/utils/httpsRequest.ts @@ -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; @@ -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) => {