mongo.tsx 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 {t, tct} from 'sentry/locale';
  10. type Params = DocsParams;
  11. const getSdkSetupSnippet = (params: Params) => `
  12. import sentry_sdk
  13. from sentry_sdk.integrations.pymongo import PyMongoIntegration
  14. sentry_sdk.init(
  15. dsn="${params.dsn}",
  16. integrations=[
  17. PyMongoIntegration(),
  18. ],
  19. # Set traces_sample_rate to 1.0 to capture 100%
  20. # of transactions for performance monitoring.
  21. # We recommend adjusting this value in production,
  22. traces_sample_rate=1.0,
  23. )`;
  24. const getInstallSnippet = () => `pip install --upgrade sentry-sdk[pymongo]`;
  25. const onboarding: OnboardingConfig = {
  26. introduction: () =>
  27. tct(
  28. 'The PyMongo integration adds support for [link:PyMongo], the official MongoDB driver. It adds breadcrumbs and performace traces for all queries.',
  29. {
  30. link: <ExternalLink href="https://www.mongodb.com/docs/drivers/pymongo/" />,
  31. }
  32. ),
  33. install: () => [
  34. {
  35. type: StepType.INSTALL,
  36. description: tct(
  37. 'Install [sentrySdkCode:sentry-sdk] from PyPI with the [pymongoCode:pymongo] extra:',
  38. {
  39. sentrySdkCode: <code />,
  40. pymongoCode: <code />,
  41. }
  42. ),
  43. configurations: [
  44. {
  45. language: 'bash',
  46. code: getInstallSnippet(),
  47. },
  48. ],
  49. },
  50. ],
  51. configure: (params: Params) => [
  52. {
  53. type: StepType.CONFIGURE,
  54. description: t(
  55. "To configure the SDK, initialize it before creating any of PyMongo's MongoClient instances:"
  56. ),
  57. configurations: [
  58. {
  59. language: 'python',
  60. code: getSdkSetupSnippet(params),
  61. },
  62. ],
  63. additionalInfo: tct(
  64. '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.',
  65. {code: <code />}
  66. ),
  67. },
  68. ],
  69. verify: () => [],
  70. };
  71. const docs: Docs = {
  72. onboarding,
  73. customMetricsOnboarding: getPythonMetricsOnboarding({
  74. installSnippet: getInstallSnippet(),
  75. }),
  76. };
  77. export default docs;