Skip to content

Commit

Permalink
Updated type declaration of captureAWSv3Client to fix TS errors (#575)
Browse files Browse the repository at this point in the history
  • Loading branch information
carolabadeer authored Mar 9, 2023
1 parent 3abe727 commit 7e92f33
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 1 addition & 2 deletions packages/core/lib/patchers/aws3_p.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Client } from '@aws-sdk/types';
import { SegmentLike } from '../aws-xray';
/**
* Instruments AWS SDK V3 clients with X-Ray via middleware.
Expand All @@ -7,4 +6,4 @@ import { SegmentLike } from '../aws-xray';
* @param manualSegment - Parent segment or subsegment that is passed in for manual mode users
* @returns - the client with the X-Ray instrumentation middleware added to its middleware stack
*/
export declare function captureAWSClient<T extends Client<any, any, any>>(client: T, manualSegment?: SegmentLike): T
export declare function captureAWSClient<T extends { middlewareStack: { remove: any, use: any }, config: any }>(client: T, manualSegment?: SegmentLike): T
3 changes: 1 addition & 2 deletions packages/core/lib/patchers/aws3_p.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
Pluggable,
Client,
BuildMiddleware,
MiddlewareStack,
BuildHandlerOptions,
Expand Down Expand Up @@ -189,7 +188,7 @@ const getXRayPlugin = (config: RegionResolvedConfig, manualSegment?: SegmentLike
* @param manualSegment - Parent segment or subsegment that is passed in for manual mode users
* @returns - the client with the X-Ray instrumentation middleware added to its middleware stack
*/
export function captureAWSClient<T extends Client<any, any, any>>(client: T, manualSegment?: SegmentLike): T {
export function captureAWSClient<T extends { middlewareStack: { remove: any, use: any }, config: any }>(client: T, manualSegment?: SegmentLike): T {
// Remove existing middleware to ensure operation is idempotent
client.middlewareStack.remove(XRAY_PLUGIN_NAME);
client.middlewareStack.use(getXRayPlugin(client.config, manualSegment));
Expand Down

2 comments on commit 7e92f33

@camitz
Copy link

@camitz camitz commented on 7e92f33 Mar 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking forward to the release. :)

@hoomp3
Copy link

@hoomp3 hoomp3 commented on 7e92f33 Mar 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same 🙏

Please sign in to comment.