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.
What does this PR do?
Add support for Golang! (#128)
Motivation
I have some Golang lambdas managed with AWS SAM and would like to use the DD macro with them ;)
Testing Guidelines
I added tests for the relevant language-specific functions (mainly
layer.ts
). Most functionality is language agnostic (and current tests mainly use python), so I added no go-specific tests here.I also found some tests (but no matching implementation) for the
go1.10
runtime. Using that runtime is deprecated, so I skipped implementation for that.Additional Notes
It is a bit weird to detect that a lambda function is using go, as there is nothing inherent in the SAM template that identifies a lambda as "written in Go", due to it being a compiled language.
It is not possible to use the
Runtime
configuration, as it's currently being done for the other languages.Runtime
is now always supposed to be set toprovided.al*
for go, which is also used for other compiled runtimes (e.g. Rust).My approach:
Metadata.BuildMethod
(which is often set togo1.x
for go lambdas) is also not reliable, as this may also be a language-agnosticmakefile
.In the end, I decided to add another
Metadata
field,Metadata.Runtime
, that will treat the lambda as a Golang lambda. It's backwards compatible, so all current configuration will continue to use theruntime
value if applicable, regardless ofMetadata.Runtime
.Funny thing is: There is nothing inherent to Go about all of this. There is no Golang tracing layer anyway, like it exists for the other languages. In the end, we just add the Datadog base layer and that's it. So it would have been possible to make this completely independent of go, and just add the Database base layer whenever we see a lambda with one of the
provided.al*
runtimes. That would make it work for other compiled languages as well (e.g. Rust). I decided against it, as language support should be specific in my opinion, but this is up to debate of course.In the end, there are two ways to proceed, and I think this is maintainer-level decision:
I set this PR to "draft", as documentation is missing. I will update this PR with documentation when the decision about the question above (and possible rework) is done.
Types of changes
Check all that apply