rq.tsx 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. import ExternalLink from 'sentry/components/links/externalLink';
  2. import {Layout, LayoutProps} from 'sentry/components/onboarding/gettingStartedDoc/layout';
  3. import {ModuleProps} from 'sentry/components/onboarding/gettingStartedDoc/sdkDocumentation';
  4. import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
  5. import {ProductSolution} from 'sentry/components/onboarding/productSelection';
  6. import {t, tct} from 'sentry/locale';
  7. // Configuration Start
  8. const profilingConfiguration = ` # Set profiles_sample_rate to 1.0 to profile 100%
  9. # of sampled transactions.
  10. # We recommend adjusting this value in production.
  11. profiles_sample_rate=1.0,`;
  12. const performanceConfiguration = ` # Set traces_sample_rate to 1.0 to capture 100%
  13. # of transactions for performance monitoring.
  14. # We recommend adjusting this value in production.
  15. traces_sample_rate=1.0,`;
  16. const introduction = (
  17. <p>
  18. {tct('The RQ integration adds support for the [link:RQ Job Queue System].', {
  19. link: <ExternalLink href="https://python-rq.org/" />,
  20. })}
  21. </p>
  22. );
  23. export const steps = ({
  24. sentryInitContent,
  25. }: {
  26. sentryInitContent: string;
  27. }): LayoutProps['steps'] => [
  28. {
  29. type: StepType.CONFIGURE,
  30. description: (
  31. <p>
  32. {tct('Create a file called [code:mysettings.py] with the following content:', {
  33. code: <code />,
  34. })}
  35. </p>
  36. ),
  37. configurations: [
  38. {
  39. language: 'python',
  40. code: `
  41. import sentry_sdk
  42. from sentry_sdk.integrations.rq import RqIntegration
  43. sentry_sdk.init(
  44. ${sentryInitContent}
  45. )
  46. `,
  47. },
  48. {
  49. description: t('Start your worker with:'),
  50. language: 'shell',
  51. code: `
  52. rq worker \
  53. -c mysettings \ # module name of mysettings.py
  54. --sentry-dsn="" # only necessary for RQ < 1.0
  55. `,
  56. },
  57. ],
  58. },
  59. ];
  60. // Configuration End
  61. export function GettingStartedWithRq({
  62. dsn,
  63. activeProductSelection = [],
  64. ...props
  65. }: ModuleProps) {
  66. const otherConfigs: string[] = [];
  67. let sentryInitContent: string[] = [
  68. ` dsn="${dsn}",`,
  69. ` integrations=[RqIntegration()],`,
  70. ];
  71. if (activeProductSelection.includes(ProductSolution.PERFORMANCE_MONITORING)) {
  72. otherConfigs.push(performanceConfiguration);
  73. }
  74. if (activeProductSelection.includes(ProductSolution.PROFILING)) {
  75. otherConfigs.push(profilingConfiguration);
  76. }
  77. sentryInitContent = sentryInitContent.concat(otherConfigs);
  78. return (
  79. <Layout
  80. introduction={introduction}
  81. steps={steps({
  82. sentryInitContent: sentryInitContent.join('\n'),
  83. })}
  84. {...props}
  85. />
  86. );
  87. }
  88. export default GettingStartedWithRq;