You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add support for Golang to make the awesome powertools ecosystem available to Go developers.
Motivation
As Go developers, we currently cannot benefit from the powertools, thus needing to re-implement the same functionality over and over. I have an internal implementation already setup but would like to contribute it to the wider community.
Proposal
This is the bulk of the RFC.
Explain the design in enough detail for somebody familiar with Powertools to understand it, and for somebody familiar with the implementation to implement it.
If this feature should be available in other runtimes (e.g. Java), how would this look like to ensure consistency?
User Experience
How would customers use it?
First, install the dependency via
go get github.com/awslabs/aws-lambda-powertools-go
Next step would be to have a Lambda handler wrapper (similar to the @Logging/@Metrics annotations for Java or the context managers for Python) to run some preprocessing / setup based on the POWERTOOLS_ environment variables.
package main
import (
"github.com/aws/aws-lambda-go/pkg/powertools""github.com/awslabs/aws-lambda-powertools-go"
)
typeinputstruct{}
typeoutputstruct{}
funchandleRequest(ctx context.Context, eventinput) (output, error) {
res, err:=doSomething()
returnres, err
}
funcmain() {
// create a new wrapper accepting the actual Lambda handler as the first parameterhandler:=powertools.NewLambdaHandler(handleRequest)
lambda.Start(handler.HandleRequest)
}
The LambdaHandler definition could look something like this
typeLambdaHandlerstruct {
handlerFuncinterface{}
}
func (h*LambdaHandler) HandleRequest(ctx context.Context, eventinterface{}) (interface{}, error) {
// setup some internal settings....
// run middlewares....
// run the actual handlerres, err:=h.handlerFunc(ctx, event)
// do some post-processing like logging output etc....
returnres, err
}
Developers also want to use the Logger, Tracer and Metrics capabilities to enhance their experience.
Logger
The Logger capability will provide a standard logging facade with structured log support and leveled logging.
What other designs have been considered? Why not them?
The design for the UX needs to be fleshed out and check if it is ideomatic enough.
What is the impact of not doing this?
Unresolved questions
Optional, stash area for topics that need further development e.g. TBD
Package design: Multiple distinct Go packages (similar to AWS SDK, individually go gettable), one package powertools or multiple packages in one project (like powertools, powertoolsmetrics etc).
APIs for the core packages
The text was updated successfully, but these errors were encountered:
Key information
Summary
Add support for Golang to make the awesome powertools ecosystem available to Go developers.
Motivation
As Go developers, we currently cannot benefit from the powertools, thus needing to re-implement the same functionality over and over. I have an internal implementation already setup but would like to contribute it to the wider community.
Proposal
If this feature should be available in other runtimes (e.g. Java), how would this look like to ensure consistency?
User Experience
How would customers use it?
First, install the dependency via
Next step would be to have a Lambda handler wrapper (similar to the
@Logging
/@Metrics
annotations for Java or the context managers for Python) to run some preprocessing / setup based on thePOWERTOOLS_
environment variables.The
LambdaHandler
definition could look something like thisDevelopers also want to use the Logger, Tracer and Metrics capabilities to enhance their experience.
Logger
The Logger capability will provide a standard logging facade with structured log support and leveled logging.
The output will be the same as in Powertools Python.
Metrics
The Metrics capability provides standard EMF metrics (maybe based on prozz/aws-embedded-metrics-golang.
Tracer
Tracer will provide capabilities for using X-Ray (based on aws/aws-xray-sdk-go)
Also, the
LambdaHandler
will automatically setup tracing when the appropriatePOWERTOOLS_
environment variables are set.Any configuration or corner cases you'd expect?
Demonstration of before and after on how the experience will be better
Drawbacks
For the initial implementation (and maybe in general), we should use establishes libraries like
Rationale and alternatives
The design for the UX needs to be fleshed out and check if it is ideomatic enough.
Unresolved questions
go get
table), one packagepowertools
or multiple packages in one project (likepowertools
,powertoolsmetrics
etc).The text was updated successfully, but these errors were encountered: