How I write CI pipelines in 2023

Dagger is a programmable CI/CD engine that runs your pipelines inside containers1 which makes it easier to test things locally and to setup complex workflows. Not having to write yaml/bash/etc as the workflow gets more complex is a huge advantage for me. I’m working on a personal project that will allow people to deploy their code by selecting a GitHub repository. Me and a friend have decided to use Dagger to clone the user provided Git repository and build a Docker image and it was extremely easy to get it working. ...

August 5, 2023 · 2 min · poorlydefinedbehaviour

Sending logs and traces to Grafana cloud from your Rust application

Sending logs and traces from a Rust app to Grafana cloud Run the Grafana agent Put the Grafana agent config in grafana-agent/agent/agent.yaml. server: log_level: debug logs: configs: - name: default positions: filename: /tmp/positions.yaml scrape_configs: - job_name: varlogs static_configs: - targets: [localhost] labels: job: varlogs app: rust-grafana-metrics-logs-traces __path__: /var/log/app/*log clients: - url: <grafana-cloud-loki-url> traces: configs: - name: default receivers: otlp: protocols: grpc: remote_write: - endpoint: tempo-us-central1.grafana.net:443 insecure: false # only add this if TLS is not required basic_auth: username: <grafana-cloud-tempo-username> password: <grafana-cloud-tempo-password> batch: timeout: 5s send_batch_size: 100 Run the Grafana agent docker run \ -v $PWD/grafana-agent/data:/etc/agent/data \ -v $PWD/grafana-agent/agent.yaml:/etc/agent/agent.yaml \ -v $PWD/log:/var/log/app \ -p 4317:4317 \ grafana/agent:v0.35.0 Dependencies being used Replace axum with whatever dependency you are using. The ones you’ll use no matter the framework are: ...

July 22, 2023 · 3 min · poorlydefinedbehaviour

Why Rc<T> is not Send

Why Rc cannot be sent between threads We get a compile error if we try to send Rc<T> to another thread: use std::rc::Rc; fn main() { let rc = Rc::new(1); std::thread::spawn(|| { println!("{}", *rc); }) .join(); } error[E0277]: `Rc<i32>` cannot be shared between threads safely --> src/main.rs:5:3 | 5 | std::thread::spawn(|| { | ^^^^^^^^^^^^^^^^^^ `Rc<i32>` cannot be shared between threads safely | = help: the trait `Sync` is not implemented for `Rc<i32>` = note: required because of the requirements on the impl of `Send` for `&Rc<i32>` = note: required because it appears within the type `[closure@src/main.rs:5:22: 7:4]` note: required by a bound in `spawn` --> /home/bruno/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/mod.rs:625:8 | 625 | F: Send + 'static, | ^^^^ required by this bound in `spawn` For more information about this error, try `rustc --explain E0277`. The compile error is triggered because the closure passed to std::thread::spawn must be Send. Types that implement Send are types that can be transferred across thread boundaries. ...

March 27, 2022 · 4 min · poorlydefinedbehaviour