rust.tsx 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import {Layout, LayoutProps} from 'sentry/components/onboarding/gettingStartedDoc/layout';
  2. import {ModuleProps} from 'sentry/components/onboarding/gettingStartedDoc/sdkDocumentation';
  3. import {StepType} from 'sentry/components/onboarding/gettingStartedDoc/step';
  4. import {t, tct} from 'sentry/locale';
  5. // Configuration Start
  6. export const steps = ({
  7. dsn,
  8. }: {
  9. dsn?: string;
  10. } = {}): LayoutProps['steps'] => [
  11. {
  12. type: StepType.INSTALL,
  13. description: (
  14. <p>
  15. {tct(
  16. 'To add Sentry to your Rust project you just need to add a new dependency to your [code:Cargo.toml]:',
  17. {code: <code />}
  18. )}
  19. </p>
  20. ),
  21. configurations: [
  22. {
  23. language: 'toml',
  24. code: `
  25. [dependencies]
  26. sentry = "0.31.5"
  27. `,
  28. },
  29. ],
  30. },
  31. {
  32. type: StepType.CONFIGURE,
  33. description: (
  34. <p>
  35. {tct(
  36. '[code:Sentry.init()] will return you a guard that when freed, will prevent process exit until all events have been sent (within a timeout):',
  37. {code: <code />}
  38. )}
  39. </p>
  40. ),
  41. configurations: [
  42. {
  43. language: 'rust',
  44. code: `
  45. let _guard = sentry::init(("${dsn}", sentry::ClientOptions {
  46. release: sentry::release_name!(),
  47. ..Default::default()
  48. }));
  49. `,
  50. },
  51. ],
  52. },
  53. {
  54. type: StepType.VERIFY,
  55. description: t(
  56. 'The quickest way to verify Sentry in your Rust application is to cause a panic:'
  57. ),
  58. configurations: [
  59. {
  60. language: 'rust',
  61. code: `
  62. fn main() {
  63. let _guard = sentry::init(("${dsn}", sentry::ClientOptions {
  64. release: sentry::release_name!(),
  65. ..Default::default()
  66. }));
  67. // Sentry will capture this
  68. panic!("Everything is on fire!");
  69. }
  70. `,
  71. },
  72. ],
  73. },
  74. ];
  75. // Configuration End
  76. export function GettingStartedWithRust({dsn, ...props}: ModuleProps) {
  77. return <Layout steps={steps({dsn})} {...props} />;
  78. }
  79. export default GettingStartedWithRust;