From 483992587df477a3bf8b86a6d24c1400a90d88f9 Mon Sep 17 00:00:00 2001 From: Ivan Dlugos <6349682+vaind@users.noreply.github.com> Date: Fri, 16 Jun 2023 12:18:48 +0200 Subject: [PATCH] feat: Go profiling (#7127) Co-authored-by: Shana Matthews Co-authored-by: vivianyentran <20403606+vivianyentran@users.noreply.github.com> Co-authored-by: Anton Ovchinnikov --- .../product/profiling/getting-started.mdx | 5 +- src/docs/product/profiling/index.mdx | 1 + src/platforms/common/profiling/index.mdx | 59 ++++++++++++++++++- .../go/profiling-onboarding/go/0.alert.md | 10 ++++ .../go/profiling-onboarding/go/1.install.md | 10 ++++ .../go/2.configure-performance.md | 19 ++++++ .../go/3.configure-profiling.md | 21 +++++++ 7 files changed, 122 insertions(+), 3 deletions(-) create mode 100644 src/wizard/go/profiling-onboarding/go/0.alert.md create mode 100644 src/wizard/go/profiling-onboarding/go/1.install.md create mode 100644 src/wizard/go/profiling-onboarding/go/2.configure-performance.md create mode 100644 src/wizard/go/profiling-onboarding/go/3.configure-profiling.md diff --git a/src/docs/product/profiling/getting-started.mdx b/src/docs/product/profiling/getting-started.mdx index 8b5df580c25c0b..729008583a1308 100644 --- a/src/docs/product/profiling/getting-started.mdx +++ b/src/docs/product/profiling/getting-started.mdx @@ -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] diff --git a/src/docs/product/profiling/index.mdx b/src/docs/product/profiling/index.mdx index 91c98caffa663c..332dfe82d77f9e 100644 --- a/src/docs/product/profiling/index.mdx +++ b/src/docs/product/profiling/index.mdx @@ -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] diff --git a/src/platforms/common/profiling/index.mdx b/src/platforms/common/profiling/index.mdx index 4b2bd99b780381..6259ffac88f17d 100644 --- a/src/platforms/common/profiling/index.mdx +++ b/src/platforms/common/profiling/index.mdx @@ -4,6 +4,7 @@ sidebar_order: 5000 supported: - android - apple + - go - python - rust - ruby @@ -19,7 +20,6 @@ notSupported: - java - java.spring-boot - java.spring - - go - javascript.cordova - native.breakpad - native.crashpad @@ -29,6 +29,16 @@ notSupported: description: "Learn how to enable profiling in your app if it is not already set up." --- + + + + +Go Profiling is currently in alpha. Alpha features are still in progress and may have bugs. We recognize the irony. + + + + + @@ -90,6 +100,19 @@ In `AndroidManifest.xml`: + + +```go +err := sentry.Init(sentry.ClientOptions{ + Dsn: "___PUBLIC_DSN___", + EnableTracing: true, + // We recommend adjusting this value in production: + TracesSampleRate: 1.0, +}) +``` + + + ```python @@ -251,6 +274,29 @@ sentry_sdk.init( + + + + +Go Profiling alpha is available since SDK version `0.22.0`. + + + +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, +}) +``` + + + @@ -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 custom instrumentation. - Enable debug mode in the SDK and check the logs. + + +### 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). + + + ### Limitations diff --git a/src/wizard/go/profiling-onboarding/go/0.alert.md b/src/wizard/go/profiling-onboarding/go/0.alert.md new file mode 100644 index 00000000000000..cd26fd8cec8246 --- /dev/null +++ b/src/wizard/go/profiling-onboarding/go/0.alert.md @@ -0,0 +1,10 @@ +--- +name: Go +doc_link: https://docs.sentry.io/platforms/go/profiling/ +support_level: alpha +type: language +--- + +
+Profiling in Go is currently in alpha, and there may be some bugs. We recognize the irony. +
diff --git a/src/wizard/go/profiling-onboarding/go/1.install.md b/src/wizard/go/profiling-onboarding/go/1.install.md new file mode 100644 index 00000000000000..cc61bf3b87bad9 --- /dev/null +++ b/src/wizard/go/profiling-onboarding/go/1.install.md @@ -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). diff --git a/src/wizard/go/profiling-onboarding/go/2.configure-performance.md b/src/wizard/go/profiling-onboarding/go/2.configure-performance.md new file mode 100644 index 00000000000000..36b7308aab523d --- /dev/null +++ b/src/wizard/go/profiling-onboarding/go/2.configure-performance.md @@ -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, +}) +``` diff --git a/src/wizard/go/profiling-onboarding/go/3.configure-profiling.md b/src/wizard/go/profiling-onboarding/go/3.configure-profiling.md new file mode 100644 index 00000000000000..aaf4ef500cfedb --- /dev/null +++ b/src/wizard/go/profiling-onboarding/go/3.configure-profiling.md @@ -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, +}) +```