pyramid.tsx 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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 Pyramid integration adds support for the [link:Pyramid Web Framework]. It requires Pyramid 1.6 or later.',
  20. {
  21. link: <ExternalLink href="https://trypyramid.com/" />,
  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: <p>{tct('Install [code:sentry-sdk] from PyPI:', {code: <code />})}</p>,
  34. configurations: [
  35. {
  36. language: 'bash',
  37. code: '$ pip install --upgrade sentry-sdk',
  38. },
  39. ],
  40. },
  41. {
  42. type: StepType.CONFIGURE,
  43. description: t(
  44. 'To configure the SDK, initialize it with the integration before or after your app has been created:'
  45. ),
  46. configurations: [
  47. {
  48. language: 'python',
  49. code: `
  50. from pyramid.config import Configurator
  51. from wsgiref.simple_server import make_server
  52. import sentry_sdk
  53. from sentry_sdk.integrations.pyramid import PyramidIntegration
  54. sentry_sdk.init(
  55. ${sentryInitContent}
  56. )
  57. def sentry_debug(request):
  58. division_by_zero = 1 / 0
  59. with Configurator() as config:
  60. config.add_route('sentry-debug', '/')
  61. config.add_view(sentry_debug, route_name='sentry-debug')
  62. app = config.make_wsgi_app()
  63. server = make_server('0.0.0.0', 6543, app)
  64. server.serve_forever()
  65. `,
  66. },
  67. ],
  68. },
  69. ];
  70. // Configuration End
  71. export function GettingStartedWithPyramid({
  72. dsn,
  73. activeProductSelection = [],
  74. ...props
  75. }: ModuleProps) {
  76. const otherConfigs: string[] = [];
  77. let sentryInitContent: string[] = [
  78. ` dsn="${dsn}",`,
  79. ` integrations=[PyramidIntegration()],`,
  80. ];
  81. if (activeProductSelection.includes(ProductSolution.PERFORMANCE_MONITORING)) {
  82. otherConfigs.push(performanceConfiguration);
  83. }
  84. if (activeProductSelection.includes(ProductSolution.PROFILING)) {
  85. otherConfigs.push(profilingConfiguration);
  86. }
  87. sentryInitContent = sentryInitContent.concat(otherConfigs);
  88. return (
  89. <Layout
  90. introduction={introduction}
  91. steps={steps({
  92. sentryInitContent: sentryInitContent.join('\n'),
  93. })}
  94. {...props}
  95. />
  96. );
  97. }
  98. export default GettingStartedWithPyramid;