-
Notifications
You must be signed in to change notification settings - Fork 156
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
captureAWSv3Client does not support SQS or SSM clients #439
Comments
Hi @thesuavehog, Thanks for raising this. This is definitely not the expected behavior, and you should not try to use For now, you can guarantee a workaround with: import { SSMClient } from '@aws-sdk/client-ssm';
import { captureAWSv3Client } from 'aws-xray-sdk';
let ssm: SSMClient = new SSMClient({});
ssm = captureAWSv3Client(ssm as any); |
@willarmiros Thanks. I will use that workaround for now. I agree that it's an inconsistency in the AWS SDK's typing for their clients, however in the vein of "try and make things clearer even if it's an issue in our dependencies", it would be great to update the documentation on that Currently the 3 different capture functions for client ( Anyway, thanks for the workaround! |
Totally fair! I'll include the workaround in our README for now and also kick off a documentation update for our public docs to include the v3 instrumentation. |
Hello, See those PRs for the similar change: |
@m-radzikowski thanks for that insight! Makes sense since it seemed like the incompatibility issue stemmed from different versions of the AWS SDK between what we vs. the customer uses. I'll get a PR out to address this. |
No problem, did the same mistake in my lib and was helped with that, so I'm sharing it further :D |
@m-radzikowski Please see my latest comment on #449. I believe I cannot apply the same fix because there are users of this X-Ray SDK which do not also consume the AWS SDK V3, unlike your library (which is specifically intended for AWS SDK v3 users). Therefore, I do not think I can safely move |
Would it be an acceptable change to allow for import { Client as __Client } from '@aws-sdk/smithy-client';
...
type AWSClientV3 = Client<any, any, any> | __Client<any, any, any, any>;
export function captureAWSClient<T extends AWSClientV3>(client: T, manualSegment?: SegmentLike): T {
... This does not add another dependency because I'm not sure if there is yet another v3 client pattern that is required but at least those two cover off most I think. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs in next 7 days. Thank you for your contributions. |
note: I did a quick test in the code and my suggestion of a quick type alias to encapsulate the two Client type formats does not work as there is a type incompatibility in the middleware stacks of the clients (see below). I could probably If someone else see a "oh, just do this..." change I can make it and submit the PR but guess I'll live with const getXRayPlugin: (config: RegionResolvedConfig, manualSegment?: SegmentLike | undefined) => Pluggable<any, any>
Argument of type 'Pluggable<any, any>' is not assignable to parameter of type 'Pluggable<any, any> & Pluggable<any, any>'.
Type 'import("C:/Repos/github/thesuavehog/aws-xray-sdk-node/packages/core/node_modules/@aws-sdk/types/types/middleware").Pluggable<any, any>' is not assignable to type 'import("C:/Repos/github/thesuavehog/aws-xray-sdk-node/node_modules/@aws-sdk/smithy-client/node_modules/@aws-sdk/types/dist/types/middleware").Pluggable<any, any>'.
Types of property 'applyToStack' are incompatible.
Type '(stack: import("C:/Repos/github/thesuavehog/aws-xray-sdk-node/packages/core/node_modules/@aws-sdk/types/types/middleware").MiddlewareStack<any, any>) => void' is not assignable to type '(stack: import("C:/Repos/github/thesuavehog/aws-xray-sdk-node/node_modules/@aws-sdk/smithy-client/node_modules/@aws-sdk/types/dist/types/middleware").MiddlewareStack<any, any>) => void'.
Types of parameters 'stack' and 'stack' are incompatible.
Type 'import("C:/Repos/github/thesuavehog/aws-xray-sdk-node/node_modules/@aws-sdk/smithy-client/node_modules/@aws-sdk/types/dist/types/middleware").MiddlewareStack<any, any>' is not assignable to type 'import("C:/Repos/github/thesuavehog/aws-xray-sdk-node/packages/core/node_modules/@aws-sdk/types/types/middleware").MiddlewareStack<any, any>'.
Types of property 'concat' are incompatible.
Type '<InputType extends any, OutputType extends any>(from: import("C:/Repos/github/thesuavehog/aws-xray-sdk-node/node_modules/@aws-sdk/smithy-client/node_modules/@aws-sdk/types/dist/types/middleware").MiddlewareStack<InputType, OutputType>) => import("C:/Repos/github/thesuavehog/aws-xray-sdk-node/node_modules/@aws-sdk/sm...' is not assignable to type '<InputType extends any, OutputType extends any>(from: import("C:/Repos/github/thesuavehog/aws-xray-sdk-node/packages/core/node_modules/@aws-sdk/types/types/middleware").MiddlewareStack<InputType, OutputType>) => import("C:/Repos/github/thesuavehog/aws-xray-sdk-node/packages/core/node_modules/@aws-sdk/types/types/mid...'.
Types of parameters 'from' and 'from' are incompatible.
Type 'MiddlewareStack<InputType, OutputType>' is not assignable to type 'MiddlewareStack<InputType, OutputType | undefined>'.
Types of property 'addRelativeTo' are incompatible.
Type '(middleware: MiddlewareType<InputType, OutputType>, options: RelativeMiddlewareOptions) => void' is not assignable to type '(middleware: MiddlewareType<InputType, OutputType | undefined>, options: RelativeMiddlewareOptions) => void'.
Types of parameters 'middleware' and 'middleware' are incompatible.
Type 'MiddlewareType<InputType, OutputType | undefined>' is not assignable to type 'MiddlewareType<InputType, OutputType>'.
Type 'InitializeMiddleware<InputType, OutputType | undefined>' is not assignable to type 'MiddlewareType<InputType, OutputType>'.
Type 'InitializeMiddleware<InputType, OutputType | undefined>' is not assignable to type 'InitializeMiddleware<InputType, OutputType>'.
Call signature return types 'InitializeHandler<InputType, OutputType | undefined>' and 'InitializeHandler<InputType, OutputType>' are incompatible.
Type 'Promise<InitializeHandlerOutput<OutputType | undefined>>' is not assignable to type 'Promise<InitializeHandlerOutput<OutputType>>'.
Type 'InitializeHandlerOutput<OutputType | undefined>' is not assignable to type 'InitializeHandlerOutput<OutputType>'.
Types of property 'output' are incompatible.
Type 'OutputType | undefined' is not assignable to type 'OutputType'.
'OutputType | undefined' is assignable to the constraint of type 'OutputType', but 'OutputType' could be instantiated with a different subtype of constraint 'any'.
Type 'undefined' is not assignable to type 'OutputType'.
'undefined' is assignable to the constraint of type 'OutputType', but 'OutputType' could be instantiated with a different subtype of constraint 'any'.ts(2345) |
I'm having the same issue with the SNS client using @aws-sdk/client-sns (v3.49.0) and aws-xray-sdk-core (v3.3.4) Example: import { SNS } from '@aws-sdk/client-sns'
import AWSXRay from 'aws-xray-sdk-core'
AWSXRay.captureAWSv3Client(new SNS({})) |
Same issue with @aws-sdk/client-lambda v3.51.0+ Please can you fix this, rather than us needing to use the workaround? client-dynamodb works fine. |
You need to use |
Any plans to fix this issue soon? |
Hi folks - no ETA on a fix for this, we continue to recommend the workaround of using |
AWS Distro for OpenTelemetry JS comes with a significant performance penalty and is not at all ready for prime-time. This should be an entirely solvable problem, though it may require collaboration between the XRay team and the JS SDK team to agree on interface adjustments. Telling people to cast to |
I only came across this Issue by chance, but this seems to be working perfectly fine for me:
"aws-xray-sdk-core": "^3.5.1" Was this shadow fixed or something? Or am I missing something (and inadvertantly hurting myself by using this)? |
The
captureAWSv3Client
documentation states:However if you try and use SSMClient or SQSClient in a TypeScript context you will get an error:
Presumably this applies to any AWS v3 Client which extends
Client<HandlerOptions, ClientInput extends object, ClientOutput extends MetadataBearer, ResolvedClientConfiguration extends SmithyResolvedConfiguration<HandlerOptions>>
(in
@aws-sdk/smithy-client/dist/types/client.d.ts
).If
captureAWSClient
should be used for these type of clients, then the documentation is very confusing sinceclient-ssm
andclient-sqs
are explicitly v3 clients andcaptureAWSv3Client
does not define any specific subset of v3 clients that it supports, nor does it indicate the user should fallback tocaptureAWSClient
(I'm not sure if that's actually what should be done, just saying it doesn't state to do so therefore the assumption for a reader of the documentation should be that you cannot fallback due to the explicit documentation oncaptureAWSv3Client
that it is for v3 clients).(I'm not sure if this a code bug, a documentation bug, or if someone is going to reply "you didn't read...")
The text was updated successfully, but these errors were encountered: