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

docs: sentry-go serverless usage and integrations removal #1108

Merged
merged 3 commits into from
Jul 11, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions __tests__/__snapshots__/documentation.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ Array [
"platforms/go/martini/index.html",
"platforms/go/migration/index.html",
"platforms/go/negroni/index.html",
"platforms/go/serverless/index.html",
"platforms/go/transports/index.html",
"platforms/index.html",
"platforms/javascript/advance-settings/index.html",
Expand Down
23 changes: 23 additions & 0 deletions src/collections/_documentation/platforms/go/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,26 @@ if err != nil {

sentry.Init(sentryClientOptions)
```

### Removing Default Integrations

`sentry-go` SDK has few built-in integrations that enhance events with additional information, or manage them in one way or another.

If you want to read more about them, see the [source code](https://github.com/getsentry/sentry-go/blob/master/integrations.go) directly.

However, there are some cases where you may want to disable some of them. To do this, you can use `Integrations` configuration option and filter unwanted integrations. For example:
kamilogorek marked this conversation as resolved.
Show resolved Hide resolved

```go
sentry.Init(sentry.ClientOptions{
Integrations: func(integrations []sentry.Integration) []sentry.Integration {
var filteredIntegrations []sentry.Integration
for _, integration := range integrations {
if integration.Name() == "ContextifyFrames" {
continue
}
filteredIntegrations = append(filteredIntegrations, integration)
}
return filteredIntegrations
},
})
```
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Integrations
sidebar_order: 5
sidebar_order: 6
---

The sentry-go package currently comes with an integration for the native `net/http` package, `echo`, `gin`, `iris`, `martini` and `negroni` to make it easy to handle common scenarios.
Expand Down
49 changes: 49 additions & 0 deletions src/collections/_documentation/platforms/go/serverless.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
title: Serverless
sidebar_order: 5
---

### Source Context

`sentry-go` SDK comes with the support for serverless solutions out of the box.
However, in order to get the source contexts right, you need to bundle your source code with the binary itself.
kamilogorek marked this conversation as resolved.
Show resolved Hide resolved

For example, when using __AWS Lambda__ and given this tree structure:

```bash
.
├── 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 necessary source files with a command:
kamilogorek marked this conversation as resolved.
Show resolved Hide resolved

```bash
$ 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 the source code is actually located on the deployed machine. Everything else should be done automatically by the SDK.
kamilogorek marked this conversation as resolved.
Show resolved Hide resolved

### Events Delivery

Most (if not all) serverless solutions won't wait for network responses before closing the process.
Because of that, we need to make sure ourselves that the event is delivered to Sentrys severs.
kamilogorek marked this conversation as resolved.
Show resolved Hide resolved

It can be achieved twofold, using `sentry.Flush` method or by swapping the transport to `HTTPSyncTransport`.
kamilogorek marked this conversation as resolved.
Show resolved Hide resolved
Both ways are described in the [Usage]({%- link _documentation/platforms/go/index.md#usage -%}) section of this documentation.