mongo.tsx 2.3 KB

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