Skip to content

Commit

Permalink
feat: Go profiling (#7127)
Browse files Browse the repository at this point in the history

Co-authored-by: Shana Matthews <shana.l.matthews@gmail.com>
Co-authored-by: vivianyentran <20403606+vivianyentran@users.noreply.github.com>
Co-authored-by: Anton Ovchinnikov <anton@tonyo.info>
  • Loading branch information
4 people authored Jun 16, 2023
1 parent 858dedb commit 4839925
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/docs/product/profiling/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ Profiling depends on Sentry's performance monitoring product being enabled befor
- Mobile
- [Android](/platforms/android/profiling/)
- [iOS](/platforms/apple/guides/ios/profiling/)
- Server
- [Node.js](/platforms/node/profiling)
- Standalone and server apps
- [Node.js](/platforms/node/profiling/)
- [Python](/platforms/python/profiling/)
- [PHP](/platforms/php/profiling/)
- [Go](/platforms/go/profiling/) [experimental]
- [Ruby](/platforms/ruby/profiling/) [experimental]
- [Rust](/platforms/rust/profiling) [experimental]
1 change: 1 addition & 0 deletions src/docs/product/profiling/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ description: "Profiling offers a deeper level of visibility on top of traditiona
- Node.js
- Python
- PHP (including Laravel and Symfony)
- Go [experimental]
- Ruby [experimental]
- Rust [experimental]

Expand Down
59 changes: 58 additions & 1 deletion src/platforms/common/profiling/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ sidebar_order: 5000
supported:
- android
- apple
- go
- python
- rust
- ruby
Expand All @@ -19,7 +20,6 @@ notSupported:
- java
- java.spring-boot
- java.spring
- go
- javascript.cordova
- native.breakpad
- native.crashpad
Expand All @@ -29,6 +29,16 @@ notSupported:
description: "Learn how to enable profiling in your app if it is not already set up."
---

<PlatformSection supported={["go"]}>

<Note>

Go Profiling is currently in alpha. Alpha features are still in progress and may have bugs. We recognize the irony.

</Note>

</PlatformSection>

<PlatformSection supported={["ruby"]}>

<Note>
Expand Down Expand Up @@ -90,6 +100,19 @@ In `AndroidManifest.xml`:

</PlatformSection>

<PlatformSection supported={["go"]}>

```go
err := sentry.Init(sentry.ClientOptions{
Dsn: "___PUBLIC_DSN___",
EnableTracing: true,
// We recommend adjusting this value in production:
TracesSampleRate: 1.0,
})
```

</PlatformSection>

<PlatformSection supported={["python"]}>

```python
Expand Down Expand Up @@ -251,6 +274,29 @@ sentry_sdk.init(

</PlatformSection>

<PlatformSection supported={["go"]}>

<Note>

Go Profiling alpha is available since SDK version `0.22.0`.

</Note>

To enable profiling, set the `ProfilesSampleRate`:

```go
err := sentry.Init(sentry.ClientOptions{
Dsn: "___PUBLIC_DSN___",
EnableTracing: true,
// We recommend adjusting these values in production:
TracesSampleRate: 1.0,
// The sampling rate for profiling is relative to TracesSampleRate:
ProfilesSampleRate: 1.0,
})
```

</PlatformSection>

<PlatformSection supported={["ruby"]}>

<Note>
Expand Down Expand Up @@ -337,6 +383,17 @@ If you don't see any profiling data in [sentry.io](https://sentry.io), you can t
- If the automatic instrumentation is not sending performance data, try using <PlatformLink to="/performance/instrumentation/custom-instrumentation">custom instrumentation</PlatformLink>.
- Enable <PlatformLink to="/configuration/options/#debug">debug mode</PlatformLink> in the SDK and check the logs.

<PlatformSection supported={["go"]}>

### Limitations

Profile samples are collected periodically for each goroutine.
If your program uses a large number of concurrent goroutines, make sure to check whether the overhead is within the acceptable range for your use case.

As always, and especially with Profiling in Go being an alpha feature, feedback is welcome on [Discord](https://discord.com/channels/621778831602221064/621786587939864586) or [GitHub](https://github.com/getsentry/sentry-go/issues/630).

</PlatformSection>

<PlatformSection supported={["ruby"]}>

### Limitations
Expand Down
10 changes: 10 additions & 0 deletions src/wizard/go/profiling-onboarding/go/0.alert.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
name: Go
doc_link: https://docs.sentry.io/platforms/go/profiling/
support_level: alpha
type: language
---

<div class='alert warning'>
Profiling in Go is currently in alpha, and there may be some bugs. We recognize the irony.
</div>
10 changes: 10 additions & 0 deletions src/wizard/go/profiling-onboarding/go/1.install.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
name: Go
doc_link: https://docs.sentry.io/platforms/go/profiling/
support_level: alpha
type: language
---

#### Install

For the Profiling integration to work, you must have the Sentry Go SDK module (minimum version v0.22.0). Learn more about installation methods in our [full documentation](https://docs.sentry.io/platforms/go/#install).
19 changes: 19 additions & 0 deletions src/wizard/go/profiling-onboarding/go/2.configure-performance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
name: Go
doc_link: https://docs.sentry.io/platforms/go/profiling/
support_level: alpha
type: language
---

#### Configure Performance

Sentry’s performance monitoring product has to be enabled in order for Profiling to work. To enable performance monitoring in the SDK:

```go
err := sentry.Init(sentry.ClientOptions{
Dsn: "___PUBLIC_DSN___",
EnableTracing: true,
// We recommend adjusting this value in production:
TracesSampleRate: 1.0,
})
```
21 changes: 21 additions & 0 deletions src/wizard/go/profiling-onboarding/go/3.configure-profiling.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
name: Go
doc_link: https://docs.sentry.io/platforms/go/profiling/
support_level: alpha
type: language
---

#### Configure Profiling

Add the `ProfilesSampleRate` option to your SDK config.

```go
err := sentry.Init(sentry.ClientOptions{
Dsn: "___PUBLIC_DSN___",
EnableTracing: true,
// We recommend adjusting these values in production:
TracesSampleRate: 1.0,
// The sampling rate for profiling is relative to TracesSampleRate:
ProfilesSampleRate: 1.0,
})
```

1 comment on commit 4839925

@vercel
Copy link

@vercel vercel bot commented on 4839925 Jun 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

sentry-docs – ./

sentry-docs-git-master.sentry.dev
docs.sentry.io
sentry-docs.sentry.dev

Please sign in to comment.