quart.tsx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. <Fragment>
  19. <p>
  20. {tct(
  21. 'The Quart integration adds support for the Quart Web Framework. We support Quart versions 0.16.1 and higher.',
  22. {
  23. link: <ExternalLink href="https://gitlab.com/pgjones/quart" />,
  24. }
  25. )}
  26. </p>
  27. {t('A Python version of "3.7" or higher is also required.')}
  28. </Fragment>
  29. );
  30. export const steps = ({
  31. sentryInitContent,
  32. }: {
  33. sentryInitContent: string;
  34. }): LayoutProps['steps'] => [
  35. {
  36. type: StepType.INSTALL,
  37. description: <p>{tct('Install [code:sentry-sdk] from PyPI:', {code: <code />})}</p>,
  38. configurations: [
  39. {
  40. language: 'bash',
  41. code: '$ pip install --upgrade sentry-sdk',
  42. },
  43. ],
  44. },
  45. {
  46. type: StepType.CONFIGURE,
  47. description: t(
  48. 'To configure the SDK, initialize it with the integration before or after your app has been initialized:'
  49. ),
  50. configurations: [
  51. {
  52. language: 'python',
  53. code: `
  54. import sentry_sdk
  55. from sentry_sdk.integrations.quart import QuartIntegration
  56. from quart import Quart
  57. sentry_sdk.init(
  58. ${sentryInitContent}
  59. )
  60. app = Quart(__name__)
  61. `,
  62. },
  63. ],
  64. },
  65. ];
  66. // Configuration End
  67. export function GettingStartedWithQuart({
  68. dsn,
  69. activeProductSelection = [],
  70. ...props
  71. }: ModuleProps) {
  72. const otherConfigs: string[] = [];
  73. let sentryInitContent: string[] = [
  74. ` dsn="${dsn}",`,
  75. ` integrations=[QuartIntegration()],`,
  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 GettingStartedWithQuart;