mongo.tsx 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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: () => [
  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. language: 'bash',
  47. code: getInstallSnippet(),
  48. },
  49. ],
  50. },
  51. ],
  52. configure: (params: Params) => [
  53. {
  54. type: StepType.CONFIGURE,
  55. description: t(
  56. "To configure the SDK, initialize it before creating any of PyMongo's MongoClient instances:"
  57. ),
  58. configurations: [
  59. {
  60. language: 'python',
  61. code: getSdkSetupSnippet(params),
  62. },
  63. ],
  64. additionalInfo: tct(
  65. '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.',
  66. {code: <code />}
  67. ),
  68. },
  69. ],
  70. verify: () => [],
  71. };
  72. const docs: Docs = {
  73. onboarding,
  74. customMetricsOnboarding: getPythonMetricsOnboarding({
  75. installSnippet: getInstallSnippet(),
  76. }),
  77. crashReportOnboarding: crashReportOnboardingPython,
  78. };
  79. export default docs;