serverless.tsx 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import {Fragment} from 'react';
  2. import ExternalLink from 'sentry/components/links/externalLink';
  3. import {Layout, LayoutProps} from 'sentry/components/onboarding/gettingStartedDoc/layout';
  4. import {ModuleProps} from 'sentry/components/onboarding/gettingStartedDoc/sdkDocumentation';
  5. import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
  6. import {t, tct} from 'sentry/locale';
  7. // Configuration Start
  8. // It is recommended to use an integration for your particular serverless environment if available, as those are easier to use and capture more useful information.
  9. // If you use a serverless provider not directly supported by the SDK, you can use this generic integration.
  10. export const steps = ({
  11. dsn,
  12. }: {
  13. dsn?: string;
  14. } = {}): LayoutProps['steps'] => [
  15. {
  16. type: StepType.INSTALL,
  17. description: (
  18. <Fragment>
  19. <p>
  20. {tct(
  21. 'It is recommended to use an [link:integration for your particular serverless environment if available], as those are easier to use and capture more useful information.',
  22. {
  23. link: (
  24. <ExternalLink href="https://docs.sentry.io/platforms/python/#serverless" />
  25. ),
  26. }
  27. )}
  28. </p>
  29. {t(
  30. 'If you use a serverless provider not directly supported by the SDK, you can use this generic integration.'
  31. )}
  32. </Fragment>
  33. ),
  34. configurations: [
  35. {
  36. language: 'python',
  37. description: (
  38. <p>
  39. {tct(
  40. 'Apply the [code:serverless_function] decorator to each function that might throw errors:',
  41. {code: <code />}
  42. )}
  43. </p>
  44. ),
  45. code: `
  46. import sentry_sdk
  47. from sentry_sdk.integrations.serverless import serverless_function
  48. sentry_sdk.init(
  49. dsn="${dsn}",
  50. # Set traces_sample_rate to 1.0 to capture 100%
  51. # of transactions for performance monitoring.
  52. # We recommend adjusting this value in production,
  53. traces_sample_rate=1.0,
  54. )
  55. @serverless_function
  56. def my_function(...): ...
  57. `,
  58. },
  59. ],
  60. },
  61. ];
  62. // Configuration End
  63. export function GettingStartedWithServerless({dsn, ...props}: ModuleProps) {
  64. return <Layout steps={steps({dsn})} {...props} />;
  65. }
  66. export default GettingStartedWithServerless;