Add internal tracking events for the Maven virtual registry
🎈 Context
At the time of this writing, we have a functional version of the Maven virtual registry. In fact, it is in the beta status.
To know more about this feature, see https://docs.gitlab.com/user/packages/virtual_registry/.
In this MR, we add internal tracking events to the feature.
We basically have two "natural" flows:
- a file is requested and that request is served using the configured upstreams (cache miss scenario).
- a file is requested and that request is served using the virtual registry cache (cache hit scenario).
Thus, we will map these onto a single event: pull_maven_package_file_through_virtual_registry with a single label (possible values: from_upstream or from_cache). Then, on top this event we will have two metrics:
- total count of requests using upstreams (using 3 timeframes:
7d,28dandall). - total count of requests using the cache (using 3 timeframes:
7d,28dandall).
🔬 What does this MR do and why?
- Add internal tracking events for the Maven virtual registry.
- Update the related specs.
📖 References
🖥️ Screenshots or screen recordings
No UI changes.
🧑🔬 How to set up and validate locally
Requirements:
- Have a GitLab instance with an EE license as the maven virtual registry is an EE only feature.
- Have a top level group id ready.
- Have a PAT ready (
apiscope). - Have snowplow micro set up.
First, let's enabled the feature flag: Feature.enable(:maven_virtual_registry)
Now, let's create a virtual registry and an upstream with $ curl:
$ curl -X POST --header "Private-Token: <PAT>" "http://gdk.test:8000/api/v4/groups/<group_id>/-/virtual_registries/packages/maven/registries?name=test" | jq
# note the registry id
$ curl -X POST --header "Private-Token: <PAT>" "http://gdk.test:8000/api/v4/virtual_registries/packages/maven/registries/<registry id>/upstreams?url=https://repo1.maven.org/maven2&name=maven_central" | jq
Alright, everything is ready.
Let's pull a file through the virtual registry. Being brand new, this file will be pulled from the configured upstream, hence trigger the internal event *_from_upstream:
$ curl --header "Private-Token: <PAT>" "http://gdk.test:8000/api/v4/virtual_registries/packages/maven/<registry id>/org/eclipse/jetty/jetty-client/12.0.19/jetty-client-12.0.19.pom"
Look at the snowplow micro dashboard (http://localhost:9091/micro/ui/), you should have 1 good event with the following structure:
Let's pull the same file again. This time around, it has been cached on the first request, so this second requests will be served from the cache.
$ curl --header "Private-Token: <PAT>" "http://gdk.test:8000/api/v4/virtual_registries/packages/maven/<registry id>/org/eclipse/jetty/jetty-client/12.0.19/jetty-client-12.0.19.pom"
Look at the snowplow micro dashboard again. We have 2 good events. The second event should have the following structure:
On both events, the name is correct and the label is correct too. Thus, this change is behaving correctly
🏁 MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

