python.tsx 2.1 KB

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