falcon.tsx 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. import ExternalLink from 'sentry/components/links/externalLink';
  2. import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
  3. import {
  4. Docs,
  5. DocsParams,
  6. OnboardingConfig,
  7. } from 'sentry/components/onboarding/gettingStartedDoc/types';
  8. import replayOnboardingJsLoader from 'sentry/gettingStartedDocs/javascript/jsLoader/jsLoader';
  9. import {t, tct} from 'sentry/locale';
  10. type Params = DocsParams;
  11. const getSdkSetupSnippet = (params: Params) => `
  12. import falcon
  13. import sentry_sdk
  14. sentry_sdk.init(
  15. dsn="${params.dsn}",${
  16. params.isPerformanceSelected
  17. ? `
  18. # Set traces_sample_rate to 1.0 to capture 100%
  19. # of transactions for performance monitoring.
  20. traces_sample_rate=1.0,`
  21. : ''
  22. }${
  23. params.isProfilingSelected
  24. ? `
  25. # Set profiles_sample_rate to 1.0 to profile 100%
  26. # of sampled transactions.
  27. # We recommend adjusting this value in production.
  28. profiles_sample_rate=1.0,`
  29. : ''
  30. }
  31. )
  32. `;
  33. const onboarding: OnboardingConfig = {
  34. introduction: () =>
  35. tct('The Falcon integration adds support for the [link:Falcon Web Framework].', {
  36. link: <ExternalLink href="https://falconframework.org/" />,
  37. }),
  38. install: () => [
  39. {
  40. type: StepType.INSTALL,
  41. description: tct(
  42. 'Install [sentrySdkCode:sentry-sdk] from PyPI with the [sentryFalconCode:falcon] extra:',
  43. {
  44. sentrySdkCode: <code />,
  45. sentryFalconCode: <code />,
  46. }
  47. ),
  48. configurations: [
  49. {
  50. language: 'bash',
  51. code: "$ pip install --upgrade 'sentry-sdk[falcon]'",
  52. },
  53. ],
  54. },
  55. ],
  56. configure: (params: Params) => [
  57. {
  58. type: StepType.CONFIGURE,
  59. description: tct(
  60. 'If you have the [codeFalcon:falcon] package in your dependencies, the Falcon integration will be enabled automatically when you initialize the Sentry SDK. Initialize the Sentry SDK before your app has been initialized:',
  61. {
  62. codeFalcon: <code />,
  63. }
  64. ),
  65. configurations: [
  66. {
  67. language: 'python',
  68. code: `
  69. ${getSdkSetupSnippet(params)}
  70. api = falcon.API()
  71. `,
  72. },
  73. ],
  74. },
  75. ],
  76. verify: (params: Params) => [
  77. {
  78. type: StepType.VERIFY,
  79. description: t(
  80. 'To verify that everything is working, trigger an error on purpose:'
  81. ),
  82. configurations: [
  83. {
  84. language: 'python',
  85. code: `
  86. ${getSdkSetupSnippet(params)}
  87. class HelloWorldResource:
  88. def on_get(self, req, resp):
  89. message = {
  90. 'hello': "world",
  91. }
  92. 1 / 0 # raises an error
  93. resp.media = message
  94. app = falcon.App()
  95. app.add_route('/', HelloWorldResource())
  96. `,
  97. },
  98. ],
  99. additionalInfo: (
  100. <div>
  101. <p>
  102. {tct(
  103. 'When you point your browser to [link:http://localhost:8000/] a transaction in the Performance section of Sentry will be created.',
  104. {
  105. link: <ExternalLink href="http://localhost:8000/" />,
  106. }
  107. )}
  108. </p>
  109. <p>
  110. {t(
  111. 'Additionally, an error event will be sent to Sentry and will be connected to the transaction.'
  112. )}
  113. </p>
  114. <p>{t('It takes a couple of moments for the data to appear in Sentry.')}</p>
  115. </div>
  116. ),
  117. },
  118. ],
  119. nextSteps: () => [],
  120. };
  121. const docs: Docs = {
  122. onboarding,
  123. replayOnboardingJsLoader,
  124. };
  125. export default docs;