Open Source Summer 2024
Published: 9/30/2024
When writing the project proposal, I hadn't done enough research.
At the same time, I started learning about observability.
I remember completing most of the tasks at the Information and Media Library. There were monitors available that I could connect to.
Origin
My approach to selecting a project was simple: I looked for projects that would benefit my future career. At the time, I wanted to join a major tech company, so I focused on projects related to Ant Group. That's how I came across this project from the Tongsuo community.
During the 2021–2022 open source internship, I had designed test cases for Prometheus in the QA-SIG of the openEuler community. I felt this project wouldn't be too difficult.
Preliminary Research and Writing the Project Proposal
Learning Rust
This project required programming in Rust, using Prometheus libraries to instrument RustyVault and collect metrics.
I started learning Rust by reading a few pages of the official Rust tutorial. Within two days, I gave up this approach because I felt that learning path wasn't suitable for the current task. I only needed a basic understanding of Rust syntax and concepts; there wasn't enough time to dive deep into the principles and design philosophy.
Learning Observability Methodology
I found that the Prometheus documentation on instrumentation wasn't detailed enough to teach me how to accomplish the task, let alone using Rust for it. The Rust documentation was not as thorough as other languages.
After some searching, I discovered a platform called PromLab, which offered a course on using Prometheus for observability tasks.
This course not only taught me how to use Prometheus as a tool, but also introduced the methodology of observability.
The observability methodology goes like this: first, determine the type of target service; second, identify key metrics; finally, implement instrumentation in code.
RustyVault can be considered an online service, so the RED (Rate, Error, Duration) method can be used for observability. For system performance monitoring, the USE method can be applied.
The PromLab course was taught using Go. The content was concise, allowing me to quickly grasp the methodology for this type of task.
There are several ways to implement instrumentation:
- Automatic instrumentation: The target application uses popular frameworks that already have built-in instrumentation code.
- Manual instrumentation: Use the observability framework's client library to instrument the target application, manually performing initialization, collection, and export.
Reading the Project Source Code
When reading the source code, I thought of a method I hadn't used before: starting from the first commit and sequentially examining the changes in the RustyVault project.
After trying this for a few days, I found it impractical — low cost-effectiveness, time-consuming, with almost no noticeable progress.
After thinking it over, I decided to fall back on my old method: using the latest version, setting breakpoints at entry points, and stepping through with a debugger until I understood the software's principles.
The project had a relatively small codebase, so I managed to understand its initialization and runtime logic within a few days, including where to initialize Prometheus variables and where to expose the collected metrics.
Implementation
Following the observability methodology, I first identified a set of metrics to monitor, then asked my mentor whether these metrics were sufficient and if any additional ones were needed.
I initialized the relevant Prometheus components in RustyVault's initialization code.
I implemented middleware for RustyVault that would track service status during HTTP communication.
Finally, I exposed the collected data from the appropriate service.
After configuring the application's address in the Prometheus backend, Prometheus could actively scrape the collected data from the application.
Conclusion
Regarding task management: it's important to clearly define the goal of the task. During implementation, one must be aware whether the current approach is helping to achieve the goal; if not, course correction should happen as soon as possible.
As for learning materials and the right path: a suitable route can make the journey far more efficient.