pyramid.tsx 2.1 KB

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