serverless.tsx 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. }: Partial<Pick<ModuleProps, 'dsn'>> = {}): LayoutProps['steps'] => [
  13. {
  14. type: StepType.INSTALL,
  15. description: (
  16. <Fragment>
  17. <p>
  18. {tct(
  19. '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.',
  20. {
  21. link: (
  22. <ExternalLink href="https://docs.sentry.io/platforms/python/#serverless" />
  23. ),
  24. }
  25. )}
  26. </p>
  27. {t(
  28. 'If you use a serverless provider not directly supported by the SDK, you can use this generic integration.'
  29. )}
  30. </Fragment>
  31. ),
  32. configurations: [
  33. {
  34. language: 'python',
  35. description: (
  36. <p>
  37. {tct(
  38. 'Apply the [code:serverless_function] decorator to each function that might throw errors:',
  39. {code: <code />}
  40. )}
  41. </p>
  42. ),
  43. code: `
  44. import sentry_sdk
  45. from sentry_sdk.integrations.serverless import serverless_function
  46. sentry_sdk.init(
  47. dsn="${dsn}",
  48. # Set traces_sample_rate to 1.0 to capture 100%
  49. # of transactions for performance monitoring.
  50. # We recommend adjusting this value in production,
  51. traces_sample_rate=1.0,
  52. )
  53. @serverless_function
  54. def my_function(...): ...
  55. `,
  56. },
  57. ],
  58. },
  59. ];
  60. // Configuration End
  61. export function GettingStartedWithServerless({dsn, ...props}: ModuleProps) {
  62. return <Layout steps={steps({dsn})} {...props} />;
  63. }
  64. export default GettingStartedWithServerless;