Slide 1

Slide 1 text

Rust at Sentry Armin @mitsuhiko Ronacher

Slide 2

Slide 2 text

Hi, I'm Armin ... and I do Open Source, lots of Python and SaaS Flask Sentry …

Slide 3

Slide 3 text

… and here is where you can find me twitter.com/@mitsuhiko github.com/mitsuhiko lucumr.pocoo.org/

Slide 4

Slide 4 text

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

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

a bit about us chapter 0

Slide 8

Slide 8 text

Open Source Project “sentry”

Slide 9

Slide 9 text

Cloud Hosted “sentry.io”

Slide 10

Slide 10 text

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

Slide 11

Slide 11 text

our general tech stack chapter 1

Slide 12

Slide 12 text

Lots of Python

Slide 13

Slide 13 text

Simple Stack Python RabbitMQ Postgres Riak Redis

Slide 14

Slide 14 text

Conservative Approach to Adding New Systems

Slide 15

Slide 15 text

prefer Internal Modularity over building More Services

Slide 16

Slide 16 text

how does rust fit?

Slide 17

Slide 17 text

why is there Rust? chapter 2

Slide 18

Slide 18 text

a bit of a hobby of mine

Slide 19

Slide 19 text

turned into sentry-cli (command line client to manage organizations / build integration)

Slide 20

Slide 20 text

later reused components for Python modules

Slide 21

Slide 21 text

now part of our tech stack

Slide 22

Slide 22 text

how we started chapter 3

Slide 23

Slide 23 text

why we use Rust for sentry-cli

Slide 24

Slide 24 text

$ 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

Slide 25

Slide 25 text

$ curl -sL https://sentry.io/get-cli/ | bash $ npm install sentry-cli-binary

Slide 26

Slide 26 text

that and crates.io

Slide 27

Slide 27 text

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

Slide 28

Slide 28 text

things that work well serialization / deserialization error handling console UX file size

Slide 29

Slide 29 text

from client to server chapter 4

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

sourcemap parsing

Slide 32

Slide 32 text

reused sentry-cli code for server

Slide 33

Slide 33 text

+20 sec -> < 500ms processing time

Slide 34

Slide 34 text

debug symbols

Slide 35

Slide 35 text

proguard

Slide 36

Slide 36 text

marrying python and rust chapter 5

Slide 37

Slide 37 text

github.com/mitsuhiko/snaek

Slide 38

Slide 38 text

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/'), ] )

Slide 39

Slide 39 text

build rust library expose rust -> cabi snaek to consume

Slide 40

Slide 40 text

#[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 } }

Slide 41

Slide 41 text

from example._native import lib def get_origin(): point = lib.example_get_origin() return (point.x, point.y)

Slide 42

Slide 42 text

things in rust to love chapter 6

Slide 43

Slide 43 text

#[derive(Serialize, Deserialize, Debug, Default)] pub struct Deploy { #[serde(rename="environment")] pub env: String, pub name: Option, pub url: Option, #[serde(rename="dateStarted")] pub started: Option>, #[serde(rename="dateFinished")] pub finished: Option>, }

Slide 44

Slide 44 text

/// Lists all deploys for a release pub fn list_deploys(&self, org: &str, version: &str) -> ApiResult> { self.get(&format!("/organizations/{}/releases/{}/deploys/", PathArg(org), PathArg(version)))? .convert() }

Slide 45

Slide 45 text

super flexible (de)serialization layer

Slide 46

Slide 46 text

crates we use / built chapter 7

Slide 47

Slide 47 text

if_chain lazy_static error-chain always useful

Slide 48

Slide 48 text

serde serde_derive serde_json serde_yaml for serialization

Slide 49

Slide 49 text

console indicatif dialoguer for pretty console UI ours :)

Slide 50

Slide 50 text

rust-curl openssl-probe HTTP stuff

Slide 51

Slide 51 text

elementtree XML ours :)

Slide 52

Slide 52 text

things we don't like chapter 8

Slide 53

Slide 53 text

compile times :'(

Slide 54

Slide 54 text

things rust needs chapter 9

Slide 55

Slide 55 text

“what not to do” guide

Slide 56

Slide 56 text

incremental compilation

Slide 57

Slide 57 text

higher level C ABI tools

Slide 58

Slide 58 text

Questions?