celery.tsx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 {ProductSolution} from 'sentry/components/onboarding/productSelection';
  7. import {t, tct} from 'sentry/locale';
  8. // Configuration Start
  9. const profilingConfiguration = ` # Set profiles_sample_rate to 1.0 to profile 100%
  10. # of sampled transactions.
  11. # We recommend adjusting this value in production.
  12. profiles_sample_rate=1.0,`;
  13. const performanceConfiguration = ` # Set traces_sample_rate to 1.0 to capture 100%
  14. # of transactions for performance monitoring.
  15. # We recommend adjusting this value in production.
  16. traces_sample_rate=1.0,`;
  17. const introduction = (
  18. <p>
  19. {tct('The celery integration adds support for the [link:Celery Task Queue System].', {
  20. link: <ExternalLink href="https://docs.celeryq.dev/en/stable/" />,
  21. })}
  22. </p>
  23. );
  24. export const steps = ({
  25. sentryInitContent,
  26. }: {
  27. sentryInitContent: string;
  28. }): LayoutProps['steps'] => [
  29. {
  30. type: StepType.CONFIGURE,
  31. description: (
  32. <p>
  33. {tct(
  34. 'Just add [celeryIntegrationCode:CeleryIntegration()] to your [integrationsCode:integrations] list:',
  35. {
  36. celeryIntegrationCode: <code />,
  37. integrationsCode: <code />,
  38. }
  39. )}
  40. </p>
  41. ),
  42. configurations: [
  43. {
  44. language: 'python',
  45. code: `
  46. import sentry_sdk
  47. from sentry_sdk.integrations.celery import CeleryIntegration
  48. sentry_sdk.init(
  49. ${sentryInitContent}
  50. )
  51. `,
  52. },
  53. ],
  54. additionalInfo: (
  55. <Fragment>
  56. {t(
  57. 'Additionally, the Sentry Python SDK will set the transaction on the event to the task name, and it will improve the grouping for global Celery errors such as timeouts.'
  58. )}
  59. <p>
  60. {t('The integration will automatically report errors from all celery jobs.')}
  61. </p>
  62. </Fragment>
  63. ),
  64. },
  65. ];
  66. // Configuration End
  67. export function GettingStartedWithCelery({
  68. dsn,
  69. activeProductSelection = [],
  70. ...props
  71. }: ModuleProps) {
  72. const otherConfigs: string[] = [];
  73. let sentryInitContent: string[] = [
  74. ` dsn="${dsn}",`,
  75. ` integrations=[CeleryIntegration()],`,
  76. ];
  77. if (activeProductSelection.includes(ProductSolution.PERFORMANCE_MONITORING)) {
  78. otherConfigs.push(performanceConfiguration);
  79. }
  80. if (activeProductSelection.includes(ProductSolution.PROFILING)) {
  81. otherConfigs.push(profilingConfiguration);
  82. }
  83. sentryInitContent = sentryInitContent.concat(otherConfigs);
  84. return (
  85. <Layout
  86. introduction={introduction}
  87. steps={steps({
  88. sentryInitContent: sentryInitContent.join('\n'),
  89. })}
  90. {...props}
  91. />
  92. );
  93. }
  94. export default GettingStartedWithCelery;