python.tsx 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 {t, tct} from 'sentry/locale';
  5. // Configuration Start
  6. export const steps = ({
  7. dsn,
  8. }: Partial<Pick<ModuleProps, 'dsn'>> = {}): LayoutProps['steps'] => [
  9. {
  10. type: StepType.INSTALL,
  11. description: (
  12. <p>
  13. {tct('Install our Python SDK using [code:pip]:', {
  14. code: <code />,
  15. })}
  16. </p>
  17. ),
  18. configurations: [
  19. {
  20. language: 'bash',
  21. code: 'pip install --upgrade sentry-sdk',
  22. },
  23. ],
  24. },
  25. {
  26. type: StepType.CONFIGURE,
  27. description: t(
  28. "Import and initialize the Sentry SDK early in your application's setup:"
  29. ),
  30. configurations: [
  31. {
  32. language: 'python',
  33. code: `
  34. import sentry_sdk
  35. sentry_sdk.init(
  36. dsn="${dsn}",
  37. # Set traces_sample_rate to 1.0 to capture 100%
  38. # of transactions for performance monitoring.
  39. # We recommend adjusting this value in production.
  40. traces_sample_rate=1.0
  41. )
  42. `,
  43. },
  44. ],
  45. additionalInfo: (
  46. <p>
  47. {tct(
  48. 'The above configuration captures both error and performance data. To reduce the volume of performance data captured, change [code:traces_sample_rate] to a value between 0 and 1.',
  49. {code: <code />}
  50. )}
  51. </p>
  52. ),
  53. },
  54. {
  55. type: StepType.VERIFY,
  56. description: t(
  57. 'One way to verify your setup is by intentionally causing an error that breaks your application.'
  58. ),
  59. configurations: [
  60. {
  61. language: 'python',
  62. description: t(
  63. 'Raise an unhandled Python exception by inserting a divide by zero expression into your application:'
  64. ),
  65. code: 'division_by_zero = 1 / 0',
  66. },
  67. ],
  68. },
  69. ];
  70. // Configuration End
  71. export function GettingStartedWithPython({dsn, ...props}: ModuleProps) {
  72. return <Layout steps={steps({dsn})} {...props} />;
  73. }
  74. export default GettingStartedWithPython;