feat(resource-detector-aws): allow synchronous lambda detection #1274
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Which problem is this PR solving?
See #1273
When using asynchronous SDK init, the lambda might have executed before the SDK has terminated its init (as no top-level await is possible for any of the AWS node runtimes)
Our kubernetes services are usually long-lived, so if we miss a few traces at startup, it's not a problem. For lambdas it's a bit of a different story. I need to find a way to ensure that the init is synchronous.
As it turns out, the detector is actually synchronous, but just returns a Promise. If we can bypass that by exposing a synchronous method (and ditching the detectResources method at the same time at the application level), then everything becomes peachy :)
Short description of the changes
Added a synchronous method for lambda resource detection.
(PS: Sorry for the quote replacement, maybe we could add a .prettierrc somewhere)