Serverless
sentry-go
SDK comes with the support for serverless solutions out of the box. However, to get the source contexts right, you need to bundle your source code with the binary itself.
For example, when using AWS Lambda and given this tree structure:
.
├── bin
│ └── upload-image
│ └── process-image
│ └── create-thumbnails
├── functions
│ └── upload-image
│ └── main.go
│ └── process-image
│ └── main.go
│ └── create-thumbnails
│ └── main.go
├── helper
│ ├── foo.go
│ └── bar.go
├── util
│ ├── baz.go
│ └── qux.go
You can build one of the binaries and bundle them with the necessary source files with this command:
GOOS=linux go build -o bin/upload-image functions/upload-image/main.go && zip -r handler.zip bin/upload-image functions/upload-image/ helper/ util/
The only requirement is that you locate the source code on the deployed machine. Everything else should be done automatically by the SDK.
Most (if not all) serverless solutions won't wait for network responses before closing the process. Because of that, we need to make sure that the event is delivered to Sentry's servers.
It can be achieved twofold, using the sentry.Flush
method or by swapping the transport to HTTPSyncTransport
.
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").
- Package:
- github:getsentry/sentry-go
- Version:
- 0.27.0
- Repository:
- https://github.com/getsentry/sentry-go/
- API Documentation:
- https://pkg.go.dev/github.com/getsentry/sentry-go