Browse Source

chore(onboarding): Update go onboarding (#68750)

This includes performance in the go onboarding.
Tony Xiao 11 months ago
parent
commit
ba67101aef

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

@@ -79,6 +79,14 @@ export const platformProductAvailability = {
   bun: [ProductSolution.PERFORMANCE_MONITORING],
   flutter: [ProductSolution.PERFORMANCE_MONITORING, ProductSolution.PROFILING],
   kotlin: [ProductSolution.PERFORMANCE_MONITORING],
+  go: [ProductSolution.PERFORMANCE_MONITORING],
+  'go-echo': [ProductSolution.PERFORMANCE_MONITORING],
+  'go-fasthttp': [ProductSolution.PERFORMANCE_MONITORING],
+  'go-gin': [ProductSolution.PERFORMANCE_MONITORING],
+  'go-http': [ProductSolution.PERFORMANCE_MONITORING],
+  'go-iris': [ProductSolution.PERFORMANCE_MONITORING],
+  'go-martini': [ProductSolution.PERFORMANCE_MONITORING],
+  'go-negroni': [ProductSolution.PERFORMANCE_MONITORING],
   java: [ProductSolution.PERFORMANCE_MONITORING],
   'java-spring-boot': [ProductSolution.PERFORMANCE_MONITORING],
   javascript: [ProductSolution.PERFORMANCE_MONITORING, ProductSolution.SESSION_REPLAY],

+ 17 - 1
static/app/gettingStartedDocs/go/echo.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 './echo';
 
 describe('echo onboarding docs', function () {
-  it('renders docs correctly', function () {
+  it('renders errors onboarding docs correctly', function () {
     renderWithOnboardingLayout(docs);
 
     // Renders main headings
@@ -12,4 +15,17 @@ describe('echo onboarding docs', function () {
     expect(screen.getByRole('heading', {name: 'Configure SDK'})).toBeInTheDocument();
     expect(screen.getByRole('heading', {name: 'Usage'})).toBeInTheDocument();
   });
+
+  it('renders performance onboarding docs correctly', async function () {
+    renderWithOnboardingLayout(docs, {
+      selectedProducts: [ProductSolution.PERFORMANCE_MONITORING],
+    });
+
+    const elements = await screen.findAllByText(
+      textWithMarkupMatcher(/TracesSampleRate/)
+    );
+    for (const element of elements) {
+      expect(element).toBeInTheDocument();
+    }
+  });
 });

+ 7 - 3
static/app/gettingStartedDocs/go/echo.tsx

@@ -32,13 +32,17 @@ import (
 
 // To initialize Sentry's handler, you need to initialize Sentry itself beforehand
 if err := sentry.Init(sentry.ClientOptions{
-  Dsn: "${params.dsn}",
+  Dsn: "${params.dsn}",${
+    params.isPerformanceSelected
+      ? `
   // Set TracesSampleRate to 1.0 to capture 100%
   // of transactions for performance monitoring.
   // We recommend adjusting this value in production,
-  TracesSampleRate: 1.0,
+  TracesSampleRate: 1.0,`
+      : ''
+  }
 }); err != nil {
-  fmt.Printf("Sentry initialization failed: %v\n", err)
+  fmt.Printf("Sentry initialization failed: %v\\n", err)
 }
 
 // Then create your app

+ 17 - 1
static/app/gettingStartedDocs/go/fasthttp.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 './fasthttp';
 
 describe('fasthttp onboarding docs', function () {
-  it('renders docs correctly', function () {
+  it('renders errors onboarding docs correctly', function () {
     renderWithOnboardingLayout(docs);
 
     // Renders main headings
@@ -12,4 +15,17 @@ describe('fasthttp onboarding docs', function () {
     expect(screen.getByRole('heading', {name: 'Configure SDK'})).toBeInTheDocument();
     expect(screen.getByRole('heading', {name: 'Usage'})).toBeInTheDocument();
   });
+
+  it('renders performance onboarding docs correctly', async function () {
+    renderWithOnboardingLayout(docs, {
+      selectedProducts: [ProductSolution.PERFORMANCE_MONITORING],
+    });
+
+    const elements = await screen.findAllByText(
+      textWithMarkupMatcher(/TracesSampleRate/)
+    );
+    for (const element of elements) {
+      expect(element).toBeInTheDocument();
+    }
+  });
 });

+ 7 - 3
static/app/gettingStartedDocs/go/fasthttp.tsx

@@ -30,14 +30,18 @@ import (
 
 // To initialize Sentry's handler, you need to initialize Sentry itself beforehand
 if err := sentry.Init(sentry.ClientOptions{
-  Dsn: "${params.dsn}",
+  Dsn: "${params.dsn}",${
+    params.isPerformanceSelected
+      ? `
   EnableTracing: true,
   // Set TracesSampleRate to 1.0 to capture 100%
   // of transactions for performance monitoring.
   // We recommend adjusting this value in production,
-  TracesSampleRate: 1.0,
+  TracesSampleRate: 1.0,`
+      : ''
+  }
 }); err != nil {
-  fmt.Printf("Sentry initialization failed: %v\n", err)
+  fmt.Printf("Sentry initialization failed: %v\\n", err)
 }
 
 // Create an instance of sentryfasthttp

+ 17 - 1
static/app/gettingStartedDocs/go/gin.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 './gin';
 
 describe('gin onboarding docs', function () {
-  it('renders docs correctly', function () {
+  it('renders errors onboarding docs correctly', function () {
     renderWithOnboardingLayout(docs);
 
     // Renders main headings
@@ -12,4 +15,17 @@ describe('gin onboarding docs', function () {
     expect(screen.getByRole('heading', {name: 'Configure SDK'})).toBeInTheDocument();
     expect(screen.getByRole('heading', {name: 'Usage'})).toBeInTheDocument();
   });
+
+  it('renders performance onboarding docs correctly', async function () {
+    renderWithOnboardingLayout(docs, {
+      selectedProducts: [ProductSolution.PERFORMANCE_MONITORING],
+    });
+
+    const elements = await screen.findAllByText(
+      textWithMarkupMatcher(/TracesSampleRate/)
+    );
+    for (const element of elements) {
+      expect(element).toBeInTheDocument();
+    }
+  });
 });

+ 7 - 3
static/app/gettingStartedDocs/go/gin.tsx

@@ -31,14 +31,18 @@ import (
 
 // To initialize Sentry's handler, you need to initialize Sentry itself beforehand
 if err := sentry.Init(sentry.ClientOptions{
-  Dsn: "${params.dsn}",
+  Dsn: "${params.dsn}",${
+    params.isPerformanceSelected
+      ? `
   EnableTracing: true,
   // Set TracesSampleRate to 1.0 to capture 100%
   // of transactions for performance monitoring.
   // We recommend adjusting this value in production,
-  TracesSampleRate: 1.0,
+  TracesSampleRate: 1.0,`
+      : ''
+  }
 }); err != nil {
-  fmt.Printf("Sentry initialization failed: %v\n", err)
+  fmt.Printf("Sentry initialization failed: %v\\n", err)
 }
 
 // Then create your app

+ 17 - 1
static/app/gettingStartedDocs/go/go.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 './go';
 
 describe('go onboarding docs', function () {
-  it('renders docs correctly', function () {
+  it('renders errors onboarding docs correctly', function () {
     renderWithOnboardingLayout(docs);
 
     // Renders main headings
@@ -12,4 +15,17 @@ describe('go onboarding docs', 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],
+    });
+
+    const elements = await screen.findAllByText(
+      textWithMarkupMatcher(/TracesSampleRate/)
+    );
+    for (const element of elements) {
+      expect(element).toBeInTheDocument();
+    }
+  });
 });

+ 15 - 7
static/app/gettingStartedDocs/go/go.tsx

@@ -25,18 +25,22 @@ import (
 
 func main() {
   err := sentry.Init(sentry.ClientOptions{
-    Dsn: "${params.dsn}",
+    Dsn: "${params.dsn}",${
+      params.isPerformanceSelected
+        ? `
     // Set TracesSampleRate to 1.0 to capture 100%
     // of transactions for performance monitoring.
     // We recommend adjusting this value in production,
-    TracesSampleRate: 1.0,
+    TracesSampleRate: 1.0,`
+        : ''
+    }
   })
   if err != nil {
     log.Fatalf("sentry.Init: %s", err)
   }
 }`;
 
-const getVerifySnippet = () => `
+const getVerifySnippet = (params: Params) => `
 package main
 
 import (
@@ -48,11 +52,15 @@ import (
 
 func main() {
   err := sentry.Init(sentry.ClientOptions{
-    Dsn: "___PUBLIC_DSN___",
+    Dsn: "___PUBLIC_DSN___",${
+      params.isPerformanceSelected
+        ? `
     // Set TracesSampleRate to 1.0 to capture 100%
     // of transactions for performance monitoring.
     // We recommend adjusting this value in production,
-    TracesSampleRate: 1.0,
+    TracesSampleRate: 1.0,`
+        : ''
+    }
   })
   if err != nil {
     log.Fatalf("sentry.Init: %s", err)
@@ -92,7 +100,7 @@ const onboarding: OnboardingConfig = {
       ],
     },
   ],
-  verify: () => [
+  verify: (params: Params) => [
     {
       type: StepType.VERIFY,
       description: t(
@@ -101,7 +109,7 @@ const onboarding: OnboardingConfig = {
       configurations: [
         {
           language: 'go',
-          code: getVerifySnippet(),
+          code: getVerifySnippet(params),
         },
       ],
     },

+ 17 - 1
static/app/gettingStartedDocs/go/http.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 './http';
 
 describe('http onboarding docs', function () {
-  it('renders docs correctly', function () {
+  it('renders errors onboarding docs correctly', function () {
     renderWithOnboardingLayout(docs);
 
     // Renders main headings
@@ -12,4 +15,17 @@ describe('http onboarding docs', function () {
     expect(screen.getByRole('heading', {name: 'Configure SDK'})).toBeInTheDocument();
     expect(screen.getByRole('heading', {name: 'Usage'})).toBeInTheDocument();
   });
+
+  it('renders performance onboarding docs correctly', async function () {
+    renderWithOnboardingLayout(docs, {
+      selectedProducts: [ProductSolution.PERFORMANCE_MONITORING],
+    });
+
+    const elements = await screen.findAllByText(
+      textWithMarkupMatcher(/TracesSampleRate/)
+    );
+    for (const element of elements) {
+      expect(element).toBeInTheDocument();
+    }
+  });
 });

Some files were not shown because too many files changed in this diff