Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update .d.ts files to reflect 'downstreamXRayEnabled' is optional #357

Merged
merged 1 commit into from
Nov 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/core/lib/patchers/http_p.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ import { Subsegment } from '../aws-xray';

type httpSubsegmentCallback = (subsegment: Subsegment, req: http.ClientRequest, res: http.IncomingMessage | null, error: Error) => void

export function captureHTTPs<T extends typeof http | typeof https>(mod: T, downstreamXRayEnabled: boolean, subsegmentCallback?: httpSubsegmentCallback): T;
export function captureHTTPs<T extends typeof http | typeof https>(mod: T, downstreamXRayEnabled?: boolean, subsegmentCallback?: httpSubsegmentCallback): T;

export function captureHTTPsGlobal(mod: typeof https | typeof http, downstreamXRayEnabled: boolean, subsegmentCallback?: httpSubsegmentCallback): void;
export function captureHTTPsGlobal(mod: typeof https | typeof http, downstreamXRayEnabled?: boolean, subsegmentCallback?: httpSubsegmentCallback): void;
2 changes: 1 addition & 1 deletion packages/core/lib/segments/attributes/subsegment.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ declare class Subsegment {

addError(err: Error | string, remote?: boolean): void;

addRemoteRequestData(req: http.ClientRequest, res: http.IncomingMessage, downstreamXRayEnabled: boolean): void;
addRemoteRequestData(req: http.ClientRequest, res: http.IncomingMessage, downstreamXRayEnabled?: boolean): void;

addFaultFlag(): void;

Expand Down
5 changes: 5 additions & 0 deletions packages/core/test-d/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,15 @@ function httpSubsegmentCallback(subsegment: AWSXRay.Subsegment, req: http.Client
console.log({ subsegment, req, res, error })
}

expectType<typeof http>(AWSXRay.captureHTTPs(http));
expectType<typeof https>(AWSXRay.captureHTTPs(https));
expectType<typeof http>(AWSXRay.captureHTTPs(http, true));
expectType<typeof https>(AWSXRay.captureHTTPs(https, true));
expectType<typeof http>(AWSXRay.captureHTTPs(http, true, httpSubsegmentCallback));
expectType<typeof https>(AWSXRay.captureHTTPs(https, true, httpSubsegmentCallback));

expectType<void>(AWSXRay.captureHTTPsGlobal(http));
expectType<void>(AWSXRay.captureHTTPsGlobal(https));
expectType<void>(AWSXRay.captureHTTPsGlobal(http, true));
expectType<void>(AWSXRay.captureHTTPsGlobal(https, true));
expectType<void>(AWSXRay.captureHTTPsGlobal(http, true, httpSubsegmentCallback));
Expand Down Expand Up @@ -207,6 +211,7 @@ expectType<void>(subsegment.addAttribute('name', 'value'));
expectType<void>(subsegment.addPrecursorId('id'));
expectType<void>(subsegment.addSqlData({}));
const clientRequest = new http.ClientRequest('http://localhost');
expectType<void>(subsegment.addRemoteRequestData(clientRequest, incomingMessage));
expectType<void>(subsegment.addRemoteRequestData(clientRequest, incomingMessage, true));
expectType<true | undefined>(subsegment.streamSubsegments());
expectType<{ [key: string]: any }>(subsegment.toJSON());
Expand Down