bottle.tsx 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 {ProductSolution} from 'sentry/components/onboarding/productSelection';
  6. import {t, tct} from 'sentry/locale';
  7. // Configuration Start
  8. const profilingConfiguration = ` # Set profiles_sample_rate to 1.0 to profile 100%
  9. # of sampled transactions.
  10. # We recommend adjusting this value in production.
  11. profiles_sample_rate=1.0,`;
  12. const performanceConfiguration = ` # Set traces_sample_rate to 1.0 to capture 100%
  13. # of transactions for performance monitoring.
  14. # We recommend adjusting this value in production.
  15. traces_sample_rate=1.0,`;
  16. const introduction = (
  17. <p>
  18. {tct(
  19. "The Bottle integration adds support for the Bottle Web Framework. Currently it works well with the stable version of Bottle (0.12). However the integration with the development version (0.13) doesn't work properly.",
  20. {
  21. link: <ExternalLink href="https://bottlepy.org/docs/dev/" />,
  22. }
  23. )}
  24. </p>
  25. );
  26. export const steps = ({
  27. sentryInitContent,
  28. }: {
  29. sentryInitContent: string;
  30. }): LayoutProps['steps'] => [
  31. {
  32. type: StepType.INSTALL,
  33. description: (
  34. <p>
  35. {tct(
  36. 'Install [sentrySdkCode:sentry-sdk] from PyPI with the [sentryBotteCode:bottle] extra:',
  37. {
  38. sentrySdkCode: <code />,
  39. sentryBotteCode: <code />,
  40. }
  41. )}
  42. </p>
  43. ),
  44. configurations: [
  45. {
  46. language: 'bash',
  47. code: 'pip install --upgrade sentry-sdk[chalice]',
  48. },
  49. ],
  50. },
  51. {
  52. type: StepType.CONFIGURE,
  53. description: t(
  54. 'To configure the SDK, initialize it with the integration before your app has been initialized:'
  55. ),
  56. configurations: [
  57. {
  58. language: 'python',
  59. code: `
  60. import sentry_sdk
  61. from bottle import Bottle, run
  62. from sentry_sdk.integrations.bottle import BottleIntegration
  63. sentry_sdk.init(
  64. ${sentryInitContent}
  65. )
  66. app = Bottle()
  67. `,
  68. },
  69. ],
  70. },
  71. ];
  72. // Configuration End
  73. export function GettingStartedWithBottle({
  74. dsn,
  75. activeProductSelection = [],
  76. ...props
  77. }: ModuleProps) {
  78. const otherConfigs: string[] = [];
  79. let sentryInitContent: string[] = [
  80. ` dsn="${dsn}",`,
  81. ` integrations=[BottleIntegration()],`,
  82. ];
  83. if (activeProductSelection.includes(ProductSolution.PERFORMANCE_MONITORING)) {
  84. otherConfigs.push(performanceConfiguration);
  85. }
  86. if (activeProductSelection.includes(ProductSolution.PROFILING)) {
  87. otherConfigs.push(profilingConfiguration);
  88. }
  89. sentryInitContent = sentryInitContent.concat(otherConfigs);
  90. return (
  91. <Layout
  92. introduction={introduction}
  93. steps={steps({
  94. sentryInitContent: sentryInitContent.join('\n'),
  95. })}
  96. {...props}
  97. />
  98. );
  99. }
  100. export default GettingStartedWithBottle;