mongo.tsx 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. }: Partial<Pick<ModuleProps, 'dsn'>> = {}): LayoutProps['steps'] => [
  20. {
  21. type: StepType.INSTALL,
  22. description: (
  23. <p>
  24. {tct(
  25. 'Install [sentrySdkCode:sentry-sdk] from PyPI with the [pymongoCode:pymongo] extra:',
  26. {
  27. sentrySdkCode: <code />,
  28. pymongoCode: <code />,
  29. }
  30. )}
  31. </p>
  32. ),
  33. configurations: [
  34. {
  35. language: 'bash',
  36. code: `pip install --upgrade 'sentry-sdk[pymongo]'`,
  37. },
  38. ],
  39. },
  40. {
  41. type: StepType.CONFIGURE,
  42. description: t(
  43. "To configure the SDK, initialize it before creating any of PyMongo's MongoClient instances:"
  44. ),
  45. configurations: [
  46. {
  47. language: 'python',
  48. code: `
  49. import sentry_sdk
  50. from sentry_sdk.integrations.pymongo import PyMongoIntegration
  51. sentry_sdk.init(
  52. dsn="${dsn}",
  53. integrations=[
  54. PyMongoIntegration(),
  55. ],
  56. # Set traces_sample_rate to 1.0 to capture 100%
  57. # of transactions for performance monitoring.
  58. # We recommend adjusting this value in production,
  59. traces_sample_rate=1.0,
  60. )
  61. `,
  62. },
  63. ],
  64. additionalInfo: (
  65. <p>
  66. {tct(
  67. '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.',
  68. {code: <code />}
  69. )}
  70. </p>
  71. ),
  72. },
  73. ];
  74. // Configuration End
  75. export function GettingStartedWithMongo({dsn, ...props}: ModuleProps) {
  76. return <Layout steps={steps({dsn})} introduction={introduction} {...props} />;
  77. }
  78. export default GettingStartedWithMongo;