Browse Source

chore(onboarding): Update ruby onboarding to include profiling (#68133)

Ruby supports profiling since 5.9.0. Include this in the onboarding
along with the product selection.
Tony Xiao 11 months ago
parent
commit
9980b1268b

+ 3 - 0
static/app/components/onboarding/productSelection.tsx

@@ -152,6 +152,9 @@ export const platformProductAvailability = {
   'python-starlette': [ProductSolution.PERFORMANCE_MONITORING, ProductSolution.PROFILING],
   'python-wsgi': [ProductSolution.PERFORMANCE_MONITORING, ProductSolution.PROFILING],
   'react-native': [ProductSolution.PERFORMANCE_MONITORING, ProductSolution.PROFILING],
+  ruby: [ProductSolution.PERFORMANCE_MONITORING, ProductSolution.PROFILING],
+  'ruby-rack': [ProductSolution.PERFORMANCE_MONITORING, ProductSolution.PROFILING],
+  'ruby-rails': [ProductSolution.PERFORMANCE_MONITORING, ProductSolution.PROFILING],
 } as Record<PlatformKey, ProductSolution[]>;
 
 type ProductProps = {

+ 35 - 1
static/app/gettingStartedDocs/ruby/rack.spec.tsx

@@ -1,14 +1,48 @@
 import {renderWithOnboardingLayout} from 'sentry-test/onboarding/renderWithOnboardingLayout';
 import {screen} from 'sentry-test/reactTestingLibrary';
+import {textWithMarkupMatcher} from 'sentry-test/utils';
+
+import {ProductSolution} from 'sentry/components/onboarding/productSelection';
 
 import docs from './rack';
 
 describe('GettingStartedWithSpring', function () {
-  it('renders docs correctly', function () {
+  it('renders errors onboarding docs correctly', function () {
     renderWithOnboardingLayout(docs);
 
     // Renders main headings
     expect(screen.getByRole('heading', {name: 'Install'})).toBeInTheDocument();
     expect(screen.getByRole('heading', {name: 'Configure SDK'})).toBeInTheDocument();
   });
+
+  it('renders performance onboarding docs correctly', async function () {
+    renderWithOnboardingLayout(docs, {
+      selectedProducts: [ProductSolution.PERFORMANCE_MONITORING],
+    });
+
+    expect(
+      await screen.findByText(textWithMarkupMatcher(/config.traces_sample_rate/))
+    ).toBeInTheDocument();
+  });
+
+  it('renders profiling onboarding docs correctly', async function () {
+    renderWithOnboardingLayout(docs, {
+      selectedProducts: [
+        ProductSolution.PERFORMANCE_MONITORING,
+        ProductSolution.PROFILING,
+      ],
+    });
+
+    expect(
+      await screen.findByText(textWithMarkupMatcher(/config.profiles_sample_rate/))
+    ).toBeInTheDocument();
+    expect(
+      await screen.findByText(textWithMarkupMatcher(/Ruby Profiling beta is available/))
+    ).toBeInTheDocument();
+    expect(
+      await screen.findByText(
+        textWithMarkupMatcher(/Make sure stackprof is loaded before sentry-ruby/)
+      )
+    ).toBeInTheDocument();
+  });
 });

+ 32 - 4
static/app/gettingStartedDocs/ruby/rack.tsx

@@ -1,3 +1,4 @@
+import ExternalLink from 'sentry/components/links/externalLink';
 import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
 import type {
   Docs,
@@ -10,11 +11,16 @@ import {tct} from 'sentry/locale';
 
 type Params = DocsParams;
 
+const getInstallSnippet = (params: Params) =>
+  `${params.isProfilingSelected ? 'gem "stackprof"\n' : ''}gem "sentry-ruby"`;
+
 const getConfigureSnippet = (params: Params) => `
 require 'sentry-ruby'
 
 Sentry.init do |config|
-  config.dsn = '${params.dsn}'
+  config.dsn = '${params.dsn}'${
+    params.isPerformanceSelected
+      ? `
 
   # Set traces_sample_rate to 1.0 to capture 100%
   # of transactions for performance monitoring.
@@ -23,13 +29,23 @@ Sentry.init do |config|
   # or
   config.traces_sampler = lambda do |context|
     true
-  end
+  end`
+      : ''
+  }${
+    params.isProfilingSelected
+      ? `
+  # Set profiles_sample_rate to profile 100%
+  # of sampled transactions.
+  # We recommend adjusting this value in production.
+  config.profiles_sample_rate = 1.0`
+      : ''
+  }
 end
 
 use Sentry::Rack::CaptureExceptions`;
 
 const onboarding: OnboardingConfig = {
-  install: () => [
+  install: params => [
     {
       type: StepType.INSTALL,
       description: tct(
@@ -40,8 +56,20 @@ const onboarding: OnboardingConfig = {
       ),
       configurations: [
         {
+          description: params.isProfilingSelected
+            ? tct(
+                'Ruby Profiling beta is available since SDK version 5.9.0. We use the [stackprofLink:stackprof gem] to collect profiles for Ruby. Make sure [stackprofCode:stackprof] is loaded before [sentryRubyCode:sentry-ruby].',
+                {
+                  stackprofLink: (
+                    <ExternalLink href="https://github.com/tmm1/stackprof" />
+                  ),
+                  stackprofCode: <code />,
+                  sentryRubyCode: <code />,
+                }
+              )
+            : undefined,
           language: 'ruby',
-          code: `gem "sentry-ruby"`,
+          code: getInstallSnippet(params),
         },
       ],
     },

+ 34 - 1
static/app/gettingStartedDocs/ruby/rails.spec.tsx

@@ -2,10 +2,12 @@ import {renderWithOnboardingLayout} from 'sentry-test/onboarding/renderWithOnboa
 import {screen} from 'sentry-test/reactTestingLibrary';
 import {textWithMarkupMatcher} from 'sentry-test/utils';
 
+import {ProductSolution} from 'sentry/components/onboarding/productSelection';
+
 import docs from './rails';
 
 describe('rails onboarding docs', function () {
-  it('renders doc correctly', function () {
+  it('renders errors onboarding doc correctly', function () {
     renderWithOnboardingLayout(docs);
 
     // Renders main headings
@@ -23,4 +25,35 @@ describe('rails onboarding docs', function () {
       screen.getByText(textWithMarkupMatcher(/gem \"sentry-ruby\"/))
     ).toBeInTheDocument();
   });
+
+  it('renders performance onboarding docs correctly', async function () {
+    renderWithOnboardingLayout(docs, {
+      selectedProducts: [ProductSolution.PERFORMANCE_MONITORING],
+    });
+
+    expect(
+      await screen.findByText(textWithMarkupMatcher(/config.traces_sample_rate/))
+    ).toBeInTheDocument();
+  });
+
+  it('renders profiling onboarding docs correctly', async function () {
+    renderWithOnboardingLayout(docs, {
+      selectedProducts: [
+        ProductSolution.PERFORMANCE_MONITORING,
+        ProductSolution.PROFILING,
+      ],
+    });
+
+    expect(
+      await screen.findByText(textWithMarkupMatcher(/config.profiles_sample_rate/))
+    ).toBeInTheDocument();
+    expect(
+      await screen.findByText(textWithMarkupMatcher(/Ruby Profiling beta is available/))
+    ).toBeInTheDocument();
+    expect(
+      await screen.findByText(
+        textWithMarkupMatcher(/Make sure stackprof is loaded before sentry-ruby/)
+      )
+    ).toBeInTheDocument();
+  });
 });

+ 31 - 6
static/app/gettingStartedDocs/ruby/rails.tsx

@@ -16,14 +16,17 @@ import {t, tct} from 'sentry/locale';
 
 type Params = DocsParams;
 
-const getInstallSnippet = () => `
-gem "sentry-ruby"
+const getInstallSnippet = (
+  params: Params
+) => `${params.isProfilingSelected ? 'gem "stackprof"\n' : ''}gem "sentry-ruby"
 gem "sentry-rails"`;
 
 const getConfigureSnippet = (params: Params) => `
 Sentry.init do |config|
   config.dsn = '${params.dsn}'
-  config.breadcrumbs_logger = [:active_support_logger, :http_logger]
+  config.breadcrumbs_logger = [:active_support_logger, :http_logger]${
+    params.isPerformanceSelected
+      ? `
 
   # Set traces_sample_rate to 1.0 to capture 100%
   # of transactions for performance monitoring.
@@ -32,7 +35,17 @@ Sentry.init do |config|
   # or
   config.traces_sampler = lambda do |context|
     true
-  end
+  end`
+      : ''
+  }${
+    params.isProfilingSelected
+      ? `
+  # Set profiles_sample_rate to profile 100%
+  # of sampled transactions.
+  # We recommend adjusting this value in production.
+  config.profiles_sample_rate = 1.0`
+      : ''
+  }
 end`;
 
 const onboarding: OnboardingConfig = {
@@ -40,7 +53,7 @@ const onboarding: OnboardingConfig = {
     t(
       'In Rails, all uncaught exceptions will be automatically reported. We support Rails 5 and newer.'
     ),
-  install: () => [
+  install: (params: Params) => [
     {
       type: StepType.INSTALL,
       description: tct(
@@ -53,8 +66,20 @@ const onboarding: OnboardingConfig = {
       ),
       configurations: [
         {
+          description: params.isProfilingSelected
+            ? tct(
+                'Ruby Profiling beta is available since SDK version 5.9.0. We use the [stackprofLink:stackprof gem] to collect profiles for Ruby. Make sure [stackprofCode:stackprof] is loaded before [sentryRubyCode:sentry-ruby].',
+                {
+                  stackprofLink: (
+                    <ExternalLink href="https://github.com/tmm1/stackprof" />
+                  ),
+                  stackprofCode: <code />,
+                  sentryRubyCode: <code />,
+                }
+              )
+            : undefined,
           language: 'ruby',
-          code: getInstallSnippet(),
+          code: getInstallSnippet(params),
         },
       ],
     },

+ 35 - 1
static/app/gettingStartedDocs/ruby/ruby.spec.tsx

@@ -1,10 +1,13 @@
 import {renderWithOnboardingLayout} from 'sentry-test/onboarding/renderWithOnboardingLayout';
 import {screen} from 'sentry-test/reactTestingLibrary';
+import {textWithMarkupMatcher} from 'sentry-test/utils';
+
+import {ProductSolution} from 'sentry/components/onboarding/productSelection';
 
 import docs from './ruby';
 
 describe('GettingStartedWithSpring', function () {
-  it('renders docs correctly', function () {
+  it('renders errors onboarding docs correctly', function () {
     renderWithOnboardingLayout(docs);
 
     // Renders main headings
@@ -12,4 +15,35 @@ describe('GettingStartedWithSpring', function () {
     expect(screen.getByRole('heading', {name: 'Configure SDK'})).toBeInTheDocument();
     expect(screen.getByRole('heading', {name: 'Verify'})).toBeInTheDocument();
   });
+
+  it('renders performance onboarding docs correctly', async function () {
+    renderWithOnboardingLayout(docs, {
+      selectedProducts: [ProductSolution.PERFORMANCE_MONITORING],
+    });
+
+    expect(
+      await screen.findByText(textWithMarkupMatcher(/config.traces_sample_rate/))
+    ).toBeInTheDocument();
+  });
+
+  it('renders profiling onboarding docs correctly', async function () {
+    renderWithOnboardingLayout(docs, {
+      selectedProducts: [
+        ProductSolution.PERFORMANCE_MONITORING,
+        ProductSolution.PROFILING,
+      ],
+    });
+
+    expect(
+      await screen.findByText(textWithMarkupMatcher(/config.profiles_sample_rate/))
+    ).toBeInTheDocument();
+    expect(
+      await screen.findByText(textWithMarkupMatcher(/Ruby Profiling beta is available/))
+    ).toBeInTheDocument();
+    expect(
+      await screen.findByText(
+        textWithMarkupMatcher(/Make sure stackprof is loaded before sentry-ruby/)
+      )
+    ).toBeInTheDocument();
+  });
 });

+ 35 - 5
static/app/gettingStartedDocs/ruby/ruby.tsx

@@ -1,3 +1,4 @@
+import ExternalLink from 'sentry/components/links/externalLink';
 import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
 import type {
   Docs,
@@ -10,9 +11,14 @@ import {t, tct} from 'sentry/locale';
 
 type Params = DocsParams;
 
+const getInstallSnippet = (params: Params) =>
+  `${params.isProfilingSelected ? 'gem "stackprof"\n' : ''}gem "sentry-ruby"`;
+
 const getConfigureSnippet = (params: Params) => `
 Sentry.init do |config|
-  config.dsn = '${params.dsn}'
+  config.dsn = '${params.dsn}'${
+    params.isPerformanceSelected
+      ? `
 
   # Set traces_sample_rate to 1.0 to capture 100%
   # of transactions for performance monitoring.
@@ -21,7 +27,17 @@ Sentry.init do |config|
   # or
   config.traces_sampler = lambda do |context|
     true
-  end
+  end`
+      : ''
+  }${
+    params.isProfilingSelected
+      ? `
+  # Set profiles_sample_rate to profile 100%
+  # of sampled transactions.
+  # We recommend adjusting this value in production.
+  config.profiles_sample_rate = 1.0`
+      : ''
+  }
 end`;
 
 const getVerifySnippet = () => `
@@ -34,17 +50,31 @@ end
 Sentry.capture_message("test message")`;
 
 const onboarding: OnboardingConfig = {
-  install: () => [
+  install: (params: Params) => [
     {
       type: StepType.INSTALL,
       description: tct(
         'Sentry Ruby comes as a gem and is straightforward to install. If you are using Bundler just add this to your [code:Gemfile]:',
-        {code: <code />}
+        {
+          code: <code />,
+        }
       ),
       configurations: [
         {
+          description: params.isProfilingSelected
+            ? tct(
+                'Ruby Profiling beta is available since SDK version 5.9.0. We use the [stackprofLink:stackprof gem] to collect profiles for Ruby. Make sure [stackprofCode:stackprof] is loaded before [sentryRubyCode:sentry-ruby].',
+                {
+                  stackprofLink: (
+                    <ExternalLink href="https://github.com/tmm1/stackprof" />
+                  ),
+                  stackprofCode: <code />,
+                  sentryRubyCode: <code />,
+                }
+              )
+            : undefined,
           language: 'ruby',
-          code: 'gem "sentry-ruby"',
+          code: getInstallSnippet(params),
         },
       ],
     },