mongo.tsx 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. import ExternalLink from 'sentry/components/links/externalLink';
  2. import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
  3. import type {
  4. Docs,
  5. DocsParams,
  6. OnboardingConfig,
  7. } from 'sentry/components/onboarding/gettingStartedDoc/types';
  8. import {getPythonMetricsOnboarding} from 'sentry/components/onboarding/gettingStartedDoc/utils/metricsOnboarding';
  9. import {crashReportOnboardingPython} from 'sentry/gettingStartedDocs/python/python';
  10. import {t, tct} from 'sentry/locale';
  11. type Params = DocsParams;
  12. const getSdkSetupSnippet = (params: Params) => `
  13. import sentry_sdk
  14. from sentry_sdk.integrations.pymongo import PyMongoIntegration
  15. sentry_sdk.init(
  16. dsn="${params.dsn}",
  17. integrations=[
  18. PyMongoIntegration(),
  19. ],
  20. # Set traces_sample_rate to 1.0 to capture 100%
  21. # of transactions for performance monitoring.
  22. # We recommend adjusting this value in production,
  23. traces_sample_rate=1.0,
  24. )`;
  25. const getInstallSnippet = () => `pip install --upgrade 'sentry-sdk[pymongo]'`;
  26. const onboarding: OnboardingConfig = {
  27. introduction: () =>
  28. tct(
  29. 'The PyMongo integration adds support for [link:PyMongo], the official MongoDB driver. It adds breadcrumbs and performace traces for all queries.',
  30. {
  31. link: <ExternalLink href="https://www.mongodb.com/docs/drivers/pymongo/" />,
  32. }
  33. ),
  34. install: (params: Params) => [
  35. {
  36. type: StepType.INSTALL,
  37. description: tct(
  38. 'Install [sentrySdkCode:sentry-sdk] from PyPI with the [pymongoCode:pymongo] extra:',
  39. {
  40. sentrySdkCode: <code />,
  41. pymongoCode: <code />,
  42. }
  43. ),
  44. configurations: [
  45. {
  46. description: params.isProfilingSelected
  47. ? tct(
  48. 'You need a minimum version [codeVersion:1.18.0] of the [codePackage:sentry-python] SDK for the profiling feature.',
  49. {
  50. codeVersion: <code />,
  51. codePackage: <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;