Metrics
Engineering metrics are used to monitor the health and performance of a development team. Although no metric should be used as a key performance indicator, some can be used to get an overall picture of the codebase, development processes, and team efficiency.
Key Engineering Metrics¶
-
Branch and Pull Request Age:
- How to measure: Calculated by the average age of branches and pull requests across the code repository being observed.
- Usefulness: If branches and pull requests are stagnant and not being merged into the main branch of a repository this shows that there is "extra" work being done by engineers or that the deployment cycle time is taking too long leading to features not being released or bugs not being fixed.
-
Code Coverage:
- How to measure: A 3rd party tooling that runs during CI/CD builds to monitor unit test coverage of a codebase.
- Usefulness: Although automated and manual tests are always needed for software development, unit tests can be used before deploying to QA to catch immediate issues. Unit tests will execute faster than most automated tests, and if issues can be found through the unit test, less time/resources are used to find issues after code has been deployed.
-
Code Quality:
- How to measure: A 3rd party tooling that runs during CI/CD builds.
- Usefulness: As codebases become larger they become more difficult to manage. Code quality monitoring tools can check the entire codebase to measure certain metrics that can cause problems in the future.
- Some metrics of Code Quality:
- Static Code Analysis Findings: coding style/standard violations, code smells (design issues or anti-patterns), security vulnerabilities
- Code Coverage: mentioned above, but also falls under code quality
- Code Complexity: cyclomatic complexity (complexity of code based on control flow paths), nesting depth in structures like loops and conditionals, method/function length (can lead to complexity and readability issues)
- Code Duplication: if multiple pieces of code serve the same purpose, issues can arise when one is changed and the other is missed
- Dependency Analysis: there can be outdated or deprecated dependencies, conflicts in dependencies, and license compliance leading to legal troubles
-
Code Review Metrics:
- How to measure: average time of code review turnaround and review comment density of new code.
- Usefulness: Although comments are not a catch-all of good code reviews, being able to see that comments are being made helps ensure that code reviews are meaningful and impactful. The turnaround time of code reviews is also important as pull requests waiting for review are not being deployed/tested.
-
Performance Metrics:
- How to measure: performance of the application, response time, error rate
- Usefulness: This is what customers will notice on their end. By measuring these metrics before release, engineers can identify bottlenecks, optimize code and infrastructure, and catch issues before releasing to the customer.