telemetry(amazonq): Add metrics utility to instrument generated patches applied to existing code.
Types of changes
[ ] Bug fix (non-breaking change which fixes an issue)
[x] New feature (non-breaking change which adds functionality)
Description
Problem: We do not yet instrument "lines of code generated" or "lines of code accepted" for patches to existing files. To do this requires inspecting a diff and applying some heuristics around what we count, focused on collecting the count of generated or accepted code (i.e. sum of lines inserted/modified).
Solution: This utility enables us to diff the before/after content of a file and report the number of lines of code in the diff. The solutions counts inserted/modified lines, and counts characters within each line, excluding leading and trailing whitespace.
The solution may be considered naive in the following ways, by design:
Performing a whitespace-sensitive diff
Counting chars, as opposed to graphemes
Counting empty lines and trailing newlines
Not counting deleted lines
The solution is tested to pin down these behaviors, which may be subject to future changes.
Checklist
[x] My code follows the code style of this project
[x] I have added tests to cover my changes
[ ] A short description of the change has been added to the CHANGELOG if the change is customer-facing in the IDE.
[ ] I have added metrics for my changes (if required)
License
I confirm that my contribution is made under the terms of the Apache 2.0 license.
telemetry(amazonq): Add metrics utility to instrument generated patches applied to existing code.
Types of changes
Description
Problem: We do not yet instrument "lines of code generated" or "lines of code accepted" for patches to existing files. To do this requires inspecting a diff and applying some heuristics around what we count, focused on collecting the count of generated or accepted code (i.e. sum of lines inserted/modified).
Solution: This utility enables us to diff the before/after content of a file and report the number of lines of code in the diff. The solutions counts inserted/modified lines, and counts characters within each line, excluding leading and trailing whitespace.
The solution may be considered naive in the following ways, by design:
The solution is tested to pin down these behaviors, which may be subject to future changes.
Checklist
License
I confirm that my contribution is made under the terms of the Apache 2.0 license.