aiohttp.tsx 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. from aiohttp import web
  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(
  36. 'The AIOHTTP integration adds support for the [link:AIOHTTP-Server Web Framework].',
  37. {
  38. link: <ExternalLink href="https://docs.aiohttp.org/en/stable/web.html" />,
  39. }
  40. ),
  41. install: () => [
  42. {
  43. type: StepType.INSTALL,
  44. description: tct('Install [code:sentry-sdk] from PyPI:', {
  45. code: <code />,
  46. }),
  47. configurations: [
  48. {
  49. language: 'bash',
  50. code: '$ pip install --upgrade sentry-sdk',
  51. },
  52. {
  53. description: tct(
  54. "If you're on Python 3.6, you also need the [code:aiocontextvars] package:",
  55. {
  56. code: <code />,
  57. }
  58. ),
  59. language: 'bash',
  60. code: '$ pip install --upgrade aiocontextvars',
  61. },
  62. ],
  63. },
  64. ],
  65. configure: (params: Params) => [
  66. {
  67. type: StepType.CONFIGURE,
  68. description: tct(
  69. 'If you have the [code:aiohttp] package in your dependencies, the AIOHTTO integration will be enabled automatically. There is nothing to do for you except initializing the Sentry SDK before initializing your application:',
  70. {
  71. code: <code />,
  72. }
  73. ),
  74. configurations: [
  75. {
  76. language: 'python',
  77. code: `
  78. ${getSdkSetupSnippet(params)}
  79. async def hello(request):
  80. return web.Response(text="Hello, world")
  81. app = web.Application()
  82. app.add_routes([web.get('/', hello)])
  83. web.run_app(app)
  84. `,
  85. },
  86. ],
  87. },
  88. ],
  89. verify: (params: Params) => [
  90. {
  91. type: StepType.VERIFY,
  92. description: t(
  93. 'You can easily verify your Sentry installation by creating a route that triggers an error:'
  94. ),
  95. configurations: [
  96. {
  97. language: 'python',
  98. code: `
  99. ${getSdkSetupSnippet(params)}
  100. async def hello(request):
  101. 1/0 # raises an error
  102. return web.Response(text="Hello, world")
  103. app = web.Application()
  104. app.add_routes([web.get('/', hello)])
  105. web.run_app(app)`,
  106. },
  107. ],
  108. additionalInfo: (
  109. <span>
  110. <p>
  111. {tct(
  112. `When you point your browser to [localhostLInk:http://localhost:8080/] a transaction in the Performance section of Sentry will be created.`,
  113. {
  114. localhostLInk: <ExternalLink href="http://localhost:8080/" />,
  115. }
  116. )}
  117. </p>
  118. <p>
  119. {t(
  120. 'Additionally, an error event will be sent to Sentry and will be connected to the transaction.'
  121. )}
  122. </p>
  123. <p>{t('It takes a couple of moments for the data to appear in Sentry.')}</p>
  124. </span>
  125. ),
  126. },
  127. ],
  128. nextSteps: () => [],
  129. };
  130. const docs: Docs = {
  131. onboarding,
  132. replayOnboardingJsLoader,
  133. };
  134. export default docs;