pyramid.tsx 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 Pyramid integration adds support for the [link:Pyramid Web Framework]. It requires Pyramid 1.6 or later.',
  11. {
  12. link: <ExternalLink href="https://trypyramid.com/" />,
  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: <p>{tct('Install [code:sentry-sdk] from PyPI:', {code: <code />})}</p>,
  25. configurations: [
  26. {
  27. language: 'bash',
  28. code: '$ pip install --upgrade sentry-sdk',
  29. },
  30. ],
  31. },
  32. {
  33. type: StepType.CONFIGURE,
  34. description: t(
  35. 'To configure the SDK, initialize it with the integration before or after your app has been created:'
  36. ),
  37. configurations: [
  38. {
  39. language: 'python',
  40. code: `
  41. from pyramid.config import Configurator
  42. from wsgiref.simple_server import make_server
  43. import sentry_sdk
  44. from sentry_sdk.integrations.pyramid import PyramidIntegration
  45. sentry_sdk.init(
  46. dsn="${dsn}",
  47. integrations=[
  48. PyramidIntegration(),
  49. ],
  50. # Set traces_sample_rate to 1.0 to capture 100%
  51. # of transactions for performance monitoring.
  52. # We recommend adjusting this value in production.
  53. traces_sample_rate=1.0,
  54. )
  55. def sentry_debug(request):
  56. division_by_zero = 1 / 0
  57. with Configurator() as config:
  58. config.add_route('sentry-debug', '/')
  59. config.add_view(sentry_debug, route_name='sentry-debug')
  60. app = config.make_wsgi_app()
  61. server = make_server('0.0.0.0', 6543, app)
  62. server.serve_forever()
  63. `,
  64. },
  65. ],
  66. },
  67. ];
  68. // Configuration End
  69. export function GettingStartedWithPyramid({dsn, ...props}: ModuleProps) {
  70. return <Layout steps={steps({dsn})} introduction={introduction} {...props} />;
  71. }
  72. export default GettingStartedWithPyramid;