Pro Yearly is on sale from $80 to $50! »

Rust at Sentry

Rust at Sentry

An introduction to how we use Rust at Sentry.

181de1fb11dffe39774f3e2e23cda3b6?s=128

Armin Ronacher

July 07, 2017
Tweet

Transcript

  1. Rust at Sentry Armin @mitsuhiko Ronacher

  2. Hi, I'm Armin ... and I do Open Source, lots

    of Python and SaaS Flask Sentry …
  3. … and here is where you can find me twitter.com/@mitsuhiko

    github.com/mitsuhiko lucumr.pocoo.org/
  4. 800°C 36° 2' 0.4662" N 118° 15' 38.7792" W 795°C

    789°C 797°C 793°C 805°C 782°C we show you your crashes
  5. None
  6. None
  7. a bit about us chapter 0

  8. Open Source Project “sentry”

  9. Cloud Hosted “sentry.io”

  10. relatively flexible stack postgres, mysql, cassandra, riak, …

  11. our general tech stack chapter 1

  12. Lots of Python

  13. Simple Stack Python RabbitMQ Postgres Riak Redis

  14. Conservative Approach to Adding New Systems

  15. prefer Internal Modularity over building More Services

  16. how does rust fit?

  17. why is there Rust? chapter 2

  18. a bit of a hobby of mine

  19. turned into sentry-cli (command line client to manage organizations /

    build integration)
  20. later reused components for Python modules

  21. now part of our tech stack

  22. how we started chapter 3

  23. why we use Rust for sentry-cli

  24. $ otool -L which sentry-cli /usr/local/bin/sentry-cli: /System/Library/Frameworks/Security.framework/Versions/A/Security /usr/lib/libiconv.2.dylib /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation /usr/lib/libcurl.4.dylib

    /usr/lib/libz.1.dylib /usr/lib/libSystem.B.dylib
  25. $ curl -sL https://sentry.io/get-cli/ | bash $ npm install sentry-cli-binary

  26. that and crates.io

  27. rejected alternatives go JavaScript (bundled node) C / C++ Python

    / Ruby
  28. things that work well serialization / deserialization error handling console

    UX file size
  29. from client to server chapter 4

  30. None
  31. sourcemap parsing

  32. reused sentry-cli code for server

  33. +20 sec -> < 500ms processing time

  34. debug symbols

  35. proguard

  36. marrying python and rust chapter 5

  37. github.com/mitsuhiko/snaek

  38. from setuptools import setup, find_packages setup( name='example', version='0.0.1', packages=find_packages(), include_package_data=True,

    zip_safe=False, platforms='any', install_requires=[ 'snaek', ], snaek_rust_modules=[ ('example._native', 'rust/'), ] )
  39. build rust library expose rust -> cabi snaek to consume

  40. #[repr(C)] pub struct Point { pub x: f32, pub y:

    f32, } #[no_mangle] pub unsafe extern "C" fn example_get_origin() -> Point { Point { x: 0.0, y: 0.0 } }
  41. from example._native import lib def get_origin(): point = lib.example_get_origin() return

    (point.x, point.y)
  42. things in rust to love chapter 6

  43. #[derive(Serialize, Deserialize, Debug, Default)] pub struct Deploy { #[serde(rename="environment")] pub

    env: String, pub name: Option<String>, pub url: Option<String>, #[serde(rename="dateStarted")] pub started: Option<DateTime<UTC>>, #[serde(rename="dateFinished")] pub finished: Option<DateTime<UTC>>, }
  44. /// Lists all deploys for a release pub fn list_deploys(&self,

    org: &str, version: &str) -> ApiResult<Vec<Deploy>> { self.get(&format!("/organizations/{}/releases/{}/deploys/", PathArg(org), PathArg(version)))? .convert() }
  45. super flexible (de)serialization layer

  46. crates we use / built chapter 7

  47. if_chain lazy_static error-chain always useful

  48. serde serde_derive serde_json serde_yaml for serialization

  49. console indicatif dialoguer for pretty console UI ours :)

  50. rust-curl openssl-probe HTTP stuff

  51. elementtree XML ours :)

  52. things we don't like chapter 8

  53. compile times :'(

  54. things rust needs chapter 9

  55. “what not to do” guide

  56. incremental compilation

  57. higher level C ABI tools

  58. Questions?