mongo.tsx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. import ExternalLink from 'sentry/components/links/externalLink';
  2. import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
  3. import {
  4. type Docs,
  5. DocsPageLocation,
  6. type DocsParams,
  7. type OnboardingConfig,
  8. } from 'sentry/components/onboarding/gettingStartedDoc/types';
  9. import {getPythonMetricsOnboarding} from 'sentry/components/onboarding/gettingStartedDoc/utils/metricsOnboarding';
  10. import {crashReportOnboardingPython} from 'sentry/gettingStartedDocs/python/python';
  11. import {t, tct} from 'sentry/locale';
  12. type Params = DocsParams;
  13. const getSdkSetupSnippet = (params: Params) => `
  14. import sentry_sdk
  15. from sentry_sdk.integrations.pymongo import PyMongoIntegration
  16. sentry_sdk.init(
  17. dsn="${params.dsn.public}",
  18. integrations=[
  19. PyMongoIntegration(),
  20. ],
  21. # Set traces_sample_rate to 1.0 to capture 100%
  22. # of transactions for tracing.
  23. # We recommend adjusting this value in production,
  24. traces_sample_rate=1.0,
  25. )`;
  26. const getInstallSnippet = () => `pip install --upgrade 'sentry-sdk[pymongo]'`;
  27. const onboarding: OnboardingConfig = {
  28. introduction: () =>
  29. tct(
  30. 'The PyMongo integration adds support for [link:PyMongo], the official MongoDB driver. It adds breadcrumbs and performace traces for all queries.',
  31. {
  32. link: <ExternalLink href="https://www.mongodb.com/docs/drivers/pymongo/" />,
  33. }
  34. ),
  35. install: (params: Params) => [
  36. {
  37. type: StepType.INSTALL,
  38. description: tct(
  39. 'Install [code:sentry-sdk] from PyPI with the [code:pymongo] extra:',
  40. {
  41. code: <code />,
  42. }
  43. ),
  44. configurations: [
  45. {
  46. description:
  47. params.docsLocation === DocsPageLocation.PROFILING_PAGE
  48. ? tct(
  49. 'You need a minimum version [code:1.18.0] of the [code:sentry-python] SDK for the profiling feature.',
  50. {
  51. code: <code />,
  52. }
  53. )
  54. : undefined,
  55. language: 'bash',
  56. code: getInstallSnippet(),
  57. },
  58. ],
  59. },
  60. ],
  61. configure: (params: Params) => [
  62. {
  63. type: StepType.CONFIGURE,
  64. description: t(
  65. "To configure the SDK, initialize it before creating any of PyMongo's MongoClient instances:"
  66. ),
  67. configurations: [
  68. {
  69. language: 'python',
  70. code: getSdkSetupSnippet(params),
  71. },
  72. ],
  73. additionalInfo: tct(
  74. 'The above configuration captures both breadcrumbs and performance data. To reduce the volume of performance data captured, change [code:traces_sample_rate] to a value between 0 and 1.',
  75. {code: <code />}
  76. ),
  77. },
  78. ],
  79. verify: () => [],
  80. };
  81. const docs: Docs = {
  82. onboarding,
  83. customMetricsOnboarding: getPythonMetricsOnboarding({
  84. installSnippet: getInstallSnippet(),
  85. }),
  86. crashReportOnboarding: crashReportOnboardingPython,
  87. };
  88. export default docs;