How to Calculate Developer Productivity Metrics Using MergeStat and DevZero

Vishal Pallerla

Cover Image for How to Calculate Developer Productivity Metrics Using MergeStat and DevZero

While we have previously discussed the significance of metrics in evaluating developer performance in our blog post, Measuring Developer Productivity to Maximizing Software Engineering Success, we understand that applying these concepts practically might appear challenging. To make this transition smoother, we have come up with a detailed guide on how to actually calculate some of these crucial metrics using MergeStat

What is MergeStat? #

MergeStat is an open-source tool that enables SQL queries on the tools and processes involved in building and shipping software. It allows you to treat your code and configuration files like a database to operationalize aspects of the software development lifecycle (SDLC). MergeStat can run on most infrastructure and is fully self-deployable, ensuring security and privacy

Initially, MergeStat was a project known as Gitqlite. It aimed to streamline the process of querying historical data in code repositories by melding SQLite and Git.

MergeStat is about garnering insights from information that may be spread across different codebases and developer teams.

What is DevZero? #

DevZero is a cloud-based development platform that offers developers the ability to create and manage their own development environments quickly and easily. It allows developers to develop and test their applications in environments that closely resemble the production environment, helping them ship code faster with more confidence.

Learn more about DevZero and why you should check it out

Using MergeStat with DevZero to calculate Metrics #

1. If you haven’t yet, Create a DevZero account with our simple Get Started flow.

2. Check here for more information on how to create and set up your DevZero account and customize it further.

3. Once signed in to DevZero Console, Create a copy of MergeStat template using this link or from the dashboard.

Metrics with MergeStat DevZero TemplateLaunch MergeStat with DevZero

4. Click Launch and it will take you to your console where it starts creating your workspace.

MergeStat workspace creation in progressMergeStat workspace build in progress

5. After a few minutes, your development environment with MergeStat is ready to go.

Mergestat workspace is readyMergeStat in DevZero is ready

6. Your environment is now set up and you are ready to go. Click on the 3 dots and select Share

Share MergeStatShare MergeStat

7. Select port 3300 and then click Create link

Sharelink creationShare link creation

Make a note of this link as you will need it later.

8. Select Open in Web Browser . You should see your environment fully set up.

MergeStat Template in VS Code ServerMergeStat Template in VS Code for the Web

9. Open Terminal from the UI or with the shortcut (Ctrl + ` OR CMD+Shift+`)

10. Make sure you are already in the mergestat folder and if not, navigate to the mergestat project folder

cd /home/devzero/projects/mergestat

11. Now, as mergestat mentions in their Getting Started guide, run the command

docker-compose up
docker compose uprunning docker-compose up

12. When the app is up, go to the share link you created in Step 8.

Mergestat login pageMergeStat Login Page

Login with the following credentials

Database user: postgres

Database password: password

13. Once logged in, you should be able to access the MergeStat UI.

You ca check the queries for metrics under Queries -> Saved Queries

Metrics Queries in Saved QueriesQueries to calculate various metrics pre-populated in saved queries

14. In order to run any queries, you first need to add a Git Source and Repos.

Adding a new repoAdd a new git source
Add a Git SourceAdding a git source

Then, add any repo URL you want to analyze and save.

Blog ImageAdd repo url and save

NOTE: if you'd like to make use of GitHub API data (any sync type that uses the GitHub API including repo auto imports) or any private GitHub repos you will need to supply a GitHub personal access token.

15. Following the instructions here, add your PAT with necessary permissions based on if you provided a public or private repository URL.

16. Then, click on the added repo and sync the data you are interested in. For the metrics queries we have in saved queries, you would require data from the following syncs as shown in the image.

Blog Imagerepo syncs

Once the data is synchronized, proceed to saved queries, run them and check the results for yourself. You can add your own queries or modify existing queries.

Example of running a query in mergestatanalyzing merge trends for the mergestat repo

How to contribute to MergeStat using DevZero? #

If you are interested in contributing to MergeStat project, the DevZero environment you created will be able to help. All you need to do is check out the file and follow the instructions.

Conclusion #

By measuring these metrics and utilizing the features and benefits of MergeStat and DevZero, you can gain valuable insights into your development team's productivity and make informed decisions to improve their performance.

picture of Vishal Pallerla

Vishal Pallerla

Developer Advocate, DevZero

Share this post