Skip to content

Commit 2f11d74

Browse files
committed
feat(go): refactor initial guide pages
1 parent 9925023 commit 2f11d74

File tree

12 files changed

+511
-582
lines changed

12 files changed

+511
-582
lines changed

docs/platforms/go/common/index.mdx

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,6 @@ Check out the other SDKs we support in the left-hand dropdown.
1010

1111
* If you don't have an account and Sentry project established already, please head over to [Sentry](https://sentry.io/signup/), and then return to this page.
1212

13-
## Features
14-
15-
In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/).
16-
17-
Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below.
18-
19-
<OnboardingOptionButtons
20-
options={[
21-
'error-monitoring',
22-
'performance',
23-
'logs',
24-
]}
25-
/>
26-
2713
## Install
2814

2915
<PlatformContent includePath="getting-started-install" />

docs/platforms/go/guides/echo/index.mdx

Lines changed: 40 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -7,79 +7,25 @@ For a quick reference, there is a [complete example](https://github.com/getsentr
77

88
[Go Dev-style API documentation](https://pkg.go.dev/github.com/getsentry/sentry-go/echo) is also available.
99

10-
## Features
11-
12-
In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/).
13-
14-
Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below.
15-
1610
## Install
1711

18-
<OnboardingOptionButtons
19-
options={[
20-
'error-monitoring',
21-
'performance'
22-
]}
23-
/>
24-
2512
```bash
13+
go get github.com/getsentry/sentry-go
2614
go get github.com/getsentry/sentry-go/echo
2715
```
2816

2917
<Break />
3018

19+
## Configure
3120

32-
```go
33-
import (
34-
"fmt"
35-
"net/http"
36-
37-
"github.com/getsentry/sentry-go"
38-
sentryecho "github.com/getsentry/sentry-go/echo"
39-
"github.com/labstack/echo/v4"
40-
"github.com/labstack/echo/v4/middleware"
41-
)
42-
43-
// To initialize Sentry's handler, you need to initialize Sentry itself beforehand
44-
if err := sentry.Init(sentry.ClientOptions{
45-
Dsn: "___PUBLIC_DSN___",
46-
// ___PRODUCT_OPTION_START___ performance
47-
// Set TracesSampleRate to 1.0 to capture 100%
48-
// of transactions for tracing.
49-
// We recommend adjusting this value in production,
50-
TracesSampleRate: 1.0,
51-
// ___PRODUCT_OPTION_END___ performance
52-
// Adds request headers and IP for users,
53-
// visit: https://docs.sentry.io/platforms/go/data-management/data-collected/ for more info
54-
SendDefaultPII: true,
55-
}); err != nil {
56-
fmt.Printf("Sentry initialization failed: %v\n", err)
57-
}
58-
59-
// Then create your app
60-
app := echo.New()
61-
62-
app.Use(middleware.Logger())
63-
app.Use(middleware.Recover())
64-
65-
// Once it's done, you can attach the handler as one of your middleware
66-
app.Use(sentryecho.New(sentryecho.Options{}))
67-
68-
// Set up routes
69-
app.GET("/", func(ctx echo.Context) error {
70-
return ctx.String(http.StatusOK, "Hello, World!")
71-
})
21+
### Initialize the Sentry SDK
7222

73-
// And run it
74-
app.Logger.Fatal(app.Start(":3000"))
75-
```
23+
<PlatformContent includePath="getting-started-config" />
7624

77-
## Configure
25+
### Options
7826

7927
`sentryecho` accepts a struct of `Options` that allows you to configure how the handler will behave.
8028

81-
Currently it respects 3 options:
82-
8329
```go
8430
// Repanic configures whether Sentry should repanic after recovery, in most cases it should be set to true,
8531
// as echo includes its own Recover middleware that handles http responses.
@@ -92,6 +38,41 @@ WaitForDelivery bool
9238
Timeout time.Duration
9339
```
9440

41+
<Break />
42+
43+
```go
44+
app := echo.New()
45+
app.Use(sentryecho.New(sentryecho.Options{
46+
// you can modify these options
47+
Repanic: true,
48+
WaitForDelivery: false,
49+
Timeout: 5 * time.Second,
50+
}))
51+
```
52+
53+
## Verify
54+
55+
```go
56+
app := echo.New()
57+
app.Use(middleware.Logger())
58+
app.Use(middleware.Recover())
59+
60+
// Attach the sentryecho handler as one of your middlewares
61+
app.Use(sentryecho.New(sentryecho.Options{
62+
// specify options here...
63+
}))
64+
65+
// Set up routes
66+
app.GET("/", func(ctx echo.Context) error {
67+
// capturing an error intentionally to simulate usage
68+
sentry.CaptureMessage("It works!")
69+
70+
return ctx.String(http.StatusOK, "Hello, World!")
71+
})
72+
73+
app.Logger.Fatal(app.Start(":3000"))
74+
```
75+
9576
## Usage
9677

9778
`sentryecho` attaches an instance of `*sentry.Hub` (https://pkg.go.dev/github.com/getsentry/sentry-go#Hub) to the `echo.Context`, which makes it available throughout the rest of the request's lifetime.

docs/platforms/go/guides/fasthttp/index.mdx

Lines changed: 40 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -7,60 +7,62 @@ For a quick reference, there is a [complete example](https://github.com/getsentr
77

88
[Go Dev-style API documentation](https://pkg.go.dev/github.com/getsentry/sentry-go/fasthttp) is also available.
99

10-
## Features
11-
12-
In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/).
13-
14-
Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below.
15-
1610
## Install
1711

18-
<OnboardingOptionButtons
19-
options={[
20-
'error-monitoring',
21-
'performance'
22-
]}
23-
/>
24-
25-
```shell
12+
```bash
13+
go get github.com/getsentry/sentry-go
2614
go get github.com/getsentry/sentry-go/fasthttp
2715
```
2816

2917
<Break />
3018

19+
## Configure
20+
21+
### Initialize the Sentry SDK
22+
23+
<PlatformContent includePath="getting-started-config" />
24+
25+
### Options
26+
27+
`sentryfasthttp` accepts a struct of `Options` that allows you to configure how the handler will behave.
3128

3229
```go
33-
import (
34-
"fmt"
35-
"net/http"
30+
// Repanic configures whether Sentry should repanic after recovery, in most cases, it defaults to false,
31+
// as fasthttp doesn't include its own Recovery handler.
32+
Repanic bool
33+
// WaitForDelivery configures whether you want to block the request before moving forward with the response.
34+
// Because fasthttp doesn't include its own `Recovery` handler, it will restart the application,
35+
// and the event won't be delivered otherwise.
36+
WaitForDelivery bool
37+
// Timeout for the event delivery requests.
38+
Timeout time.Duration
39+
```
3640

37-
"github.com/getsentry/sentry-go"
38-
sentryfasthttp "github.com/getsentry/sentry-go/fasthttp"
39-
)
41+
<Break />
4042

41-
// To initialize Sentry's handler, you need to initialize Sentry itself beforehand
42-
if err := sentry.Init(sentry.ClientOptions{
43-
Dsn: "___PUBLIC_DSN___",
44-
// ___PRODUCT_OPTION_START___ performance
45-
EnableTracing: true,
46-
// Set TracesSampleRate to 1.0 to capture 100%
47-
// of transactions for tracing.
48-
// We recommend adjusting this value in production,
49-
TracesSampleRate: 1.0,
50-
// ___PRODUCT_OPTION_END___ performance
51-
// Adds request headers and IP for users,
52-
// visit: https://docs.sentry.io/platforms/go/data-management/data-collected/ for more info
53-
SendDefaultPII: true,
54-
}); err != nil {
55-
fmt.Printf("Sentry initialization failed: %v\n", err)
56-
}
43+
```go
44+
// Create an instance of sentryfasthttp
45+
sentryHandler := sentryfasthttp.New(sentryfasthttp.Options{
46+
Repanic: false,
47+
WaitForDelivery: true,
48+
Timeout: 5 * time.Second,
49+
})
50+
```
5751

52+
## Verify
53+
54+
```go
5855
// Create an instance of sentryfasthttp
59-
sentryHandler := sentryfasthttp.New(sentryfasthttp.Options{})
56+
sentryHandler := sentryfasthttp.New(sentryfasthttp.Options{
57+
// specify options here...
58+
})
6059

6160
// After creating the instance, you can attach the handler as one of your middleware
6261
fastHTTPHandler := sentryHandler.Handle(func(ctx *fasthttp.RequestCtx) {
63-
panic("y tho")
62+
// capturing an error intentionally to simulate usage
63+
sentry.CaptureMessage("It works!")
64+
65+
ctx.SetStatusCode(fasthttp.StatusOK)
6466
})
6567

6668
fmt.Println("Listening and serving HTTP on :3000")
@@ -71,24 +73,6 @@ if err := fasthttp.ListenAndServe(":3000", fastHTTPHandler); err != nil {
7173
}
7274
```
7375

74-
## Configure
75-
76-
`sentryfasthttp` accepts a struct of `Options` that allows you to configure how the handler will behave.
77-
78-
Currently, it respects three options:
79-
80-
```go
81-
// Repanic configures whether Sentry should repanic after recovery, in most cases, it defaults to false,
82-
// as fasthttp doesn't include its own Recovery handler.
83-
Repanic bool
84-
// WaitForDelivery configures whether you want to block the request before moving forward with the response.
85-
// Because fasthttp doesn't include its own `Recovery` handler, it will restart the application,
86-
// and the event won't be delivered otherwise.
87-
WaitForDelivery bool
88-
// Timeout for the event delivery requests.
89-
Timeout time.Duration
90-
```
91-
9276
## Usage
9377

9478
`sentryfasthttp` attaches an instance of `*sentry.Hub` (https://pkg.go.dev/github.com/getsentry/sentry-go#Hub) to the request's context, which makes it available throughout the rest of the request's lifetime.

0 commit comments

Comments
 (0)