Skip to content

gitlab: Implement metric to measure latency of API calls

On various mutating operations, we're calling GitLab's internal API to verify that the mutating operation is in fact allowed for the user. These checks may take a significant amount of time, as GitLab will do deep inspection of the proposed changes by calling various API endpoints of Gitaly. But right now, it is quite hard to see exactly how long they take because 1. the correlation ID gets lost and 2. we only log when the POST to the internal API finished, but never when it started.

The first pain point needs to be fixed on Rails side: we already send the X-Request-Id header via the gitlabnet client implementation. So we instead improve observability at least a bit by implementing latency metrics which measure how long each of the POSTs is taking.


I was a bit annoyed by the structure we had with regards to the GitLab API client, which is why most of the commits first focus on splitting it out into its own package and then polishing the interface a bit. I hope you don't mind that this significantly increases the MR's size.

Merge request reports

Loading