chalice.tsx 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import {Layout, LayoutProps} from 'sentry/components/onboarding/gettingStartedDoc/layout';
  2. import {ModuleProps} from 'sentry/components/onboarding/gettingStartedDoc/sdkDocumentation';
  3. import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
  4. import {ProductSolution} from 'sentry/components/onboarding/productSelection';
  5. import {tct} from 'sentry/locale';
  6. // Configuration Start
  7. const profilingConfiguration = ` # Set profiles_sample_rate to 1.0 to profile 100%
  8. # of sampled transactions.
  9. # We recommend adjusting this value in production.
  10. profiles_sample_rate=1.0,`;
  11. const performanceConfiguration = ` # Set traces_sample_rate to 1.0 to capture 100%
  12. # of transactions for performance monitoring.
  13. # We recommend adjusting this value in production.
  14. traces_sample_rate=1.0,`;
  15. export const steps = ({
  16. sentryInitContent,
  17. }: {
  18. sentryInitContent: string;
  19. }): LayoutProps['steps'] => [
  20. {
  21. type: StepType.INSTALL,
  22. description: (
  23. <p>
  24. {tct('Install [code:sentry-sdk] from PyPI:', {
  25. code: <code />,
  26. })}
  27. </p>
  28. ),
  29. configurations: [
  30. {
  31. language: 'bash',
  32. code: 'pip install --upgrade sentry-sdk[chalice]',
  33. },
  34. ],
  35. },
  36. {
  37. type: StepType.CONFIGURE,
  38. configurations: [
  39. {
  40. language: 'python',
  41. code: `
  42. import sentry_sdk
  43. from chalice import Chalice
  44. from sentry_sdk.integrations.chalice import ChaliceIntegration
  45. sentry_sdk.init(
  46. ${sentryInitContent}
  47. )
  48. app = Chalice(app_name="appname")
  49. `,
  50. },
  51. ],
  52. },
  53. ];
  54. // Configuration End
  55. export function GettingStartedWithChalice({
  56. dsn,
  57. activeProductSelection = [],
  58. ...props
  59. }: ModuleProps) {
  60. const otherConfigs: string[] = [];
  61. let sentryInitContent: string[] = [
  62. ` dsn="${dsn}",`,
  63. ` integrations=[ChaliceIntegration()],`,
  64. ];
  65. if (activeProductSelection.includes(ProductSolution.PERFORMANCE_MONITORING)) {
  66. otherConfigs.push(performanceConfiguration);
  67. }
  68. if (activeProductSelection.includes(ProductSolution.PROFILING)) {
  69. otherConfigs.push(profilingConfiguration);
  70. }
  71. sentryInitContent = sentryInitContent.concat(otherConfigs);
  72. return (
  73. <Layout
  74. steps={steps({
  75. sentryInitContent: sentryInitContent.join('\n'),
  76. })}
  77. {...props}
  78. />
  79. );
  80. }
  81. export default GettingStartedWithChalice;