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

.NET 8 AOT-compiled Lambda function tracing AWS SDKs System.ArgumentException #296

Open
tmschlot opened this issue Apr 30, 2024 · 2 comments

Comments

@tmschlot
Copy link

We want to use X-Ray to trace AWS SDK calls we have in a natively-compiled .NET Lambda function. In our function's Main method, we're calling AWSSDKHandler.RegisterXRayForAllServices();. When we actually use an SDK for the first time -- still in the Main method -- we get the following error/stack trace:

Unhandled Exception: System.ArgumentException: The value "JsonData object" is not of type "Amazon.XRay.Recorder.Handlers.AwsSdk.Entities.AWSServiceHandler" and cannot be used in this generic collection. (Parameter 'value')
   at System.ThrowHelper.ThrowWrongValueTypeArgumentException[T](T, Type) + 0x17
   at System.Collections.Generic.Dictionary`2.System.Collections.IDictionary.Add(Object, Object) + 0xbb
   at ThirdParty.LitJson.JsonMapper.ReadValue(Type inst_type, JsonReader reader) + 0x5f0
   at ThirdParty.LitJson.JsonMapper.ReadValue(Type inst_type, JsonReader reader) + 0x55e
   at ThirdParty.LitJson.JsonMapper.ToObject[T](TextReader reader) + 0x5f
   at Amazon.XRay.Recorder.Handlers.AwsSdk.Internal.XRayPipelineHandler.GetAWSServiceHandlerManifest(Stream stream) + 0x6d
   at Amazon.XRay.Recorder.Handlers.AwsSdk.Internal.XRayPipelineHandler.GetDefaultAWSWhitelist() + 0x47
   at Amazon.XRay.Recorder.Handlers.AwsSdk.Internal.XRayPipelineHandler..ctor() + 0x1e
   at Amazon.XRay.Recorder.Handlers.AwsSdk.Internal.XRayPipelineCustomizer.Customize(Type serviceClientType, RuntimePipeline pipeline) + 0x77
   at Amazon.Runtime.Internal.RuntimePipelineCustomizerRegistry.ApplyCustomizations(Type type, RuntimePipeline pipeline) + 0xad
   at LambdaFunction.<Main>d__14.MoveNext() + 0x97

We've removed X-Ray to verify that the function works without it, and we've also deployed it without native AOT-compilation, and that works, also. In addition, I tried to copy the DefaultAWSWhitelist.json and register the manifest manually, but that yielded the same result as letting it happen from within the library.

Because this works without the trimming that occurs when publishing as a native executable, I'm assuming there's something being trimmed that we need to keep around by "rooting" the assembly. I haven't figured out what assembly that is or if there is some other problem at play. Any ideas?

This may be related to #295.

Thanks.

@burciugi
Copy link

I have the same problem! Looking forward.

@dguisinger
Copy link

Same issue here... Is the X-Ray SDK for .NET even maintained anymore? I don't see any activity for the past 4 months and they do reference Open Telemetry. With the push AWS has made for using AOT on Lambda, I am perplexed that this has been sitting out here so long....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants