Commit eff7845f authored by Ash McKenzie's avatar Ash McKenzie

Merge branch '31590-tag-delete-instrumentation' into 'master'

collect docker registry related metrics

Closes #31590

See merge request gitlab-org/gitlab!17063
parents 7146903d 1c20f590
......@@ -85,6 +85,8 @@ export default {
v-gl-modal="modalId"
:title="s__('ContainerRegistry|Remove repository')"
:aria-label="s__('ContainerRegistry|Remove repository')"
data-track-event="click_button"
data-track-label="registry_repository_delete"
class="js-remove-repo btn-inverted"
variant="danger"
>
......
......@@ -192,6 +192,8 @@ export default {
v-gl-modal="modalId"
:disabled="!itemsToBeDeleted || itemsToBeDeleted.length === 0"
class="js-delete-registry float-right"
data-track-event="click_button"
data-track-label="bulk_registry_tag_delete"
variant="danger"
:title="s__('ContainerRegistry|Remove selected tags')"
:aria-label="s__('ContainerRegistry|Remove selected tags')"
......@@ -246,6 +248,8 @@ export default {
v-gl-modal="modalId"
:title="s__('ContainerRegistry|Remove tag')"
:aria-label="s__('ContainerRegistry|Remove tag')"
data-track-event="click_button"
data-track-label="registry_tag_delete"
variant="danger"
class="js-delete-registry-row float-right btn-inverted btn-border-color btn-icon"
@click="deleteSingleItem(index)"
......
......@@ -8,6 +8,7 @@ module Projects
def index
@images = project.container_repositories
track_event(:list_repositories)
respond_to do |format|
format.html
......@@ -21,6 +22,7 @@ module Projects
def destroy
DeleteContainerRepositoryWorker.perform_async(current_user.id, image.id)
track_event(:delete_repository)
respond_to do |format|
format.json { head :no_content }
......
......@@ -8,6 +8,7 @@ module Projects
LIMIT = 15
def index
track_event(:list_tags)
respond_to do |format|
format.json do
render json: ContainerTagsSerializer
......@@ -22,6 +23,7 @@ module Projects
result = Projects::ContainerRepository::DeleteTagsService
.new(image.project, current_user, tags: [params[:id]])
.execute(image)
track_event(:delete_tag)
respond_to do |format|
format.json { head(result[:status] == :success ? :ok : bad_request) }
......@@ -43,6 +45,7 @@ module Projects
result = Projects::ContainerRepository::DeleteTagsService
.new(image.project, current_user, tags: tag_names)
.execute(image)
track_event(:delete_tag_bulk)
respond_to do |format|
format.json { head(result[:status] == :success ? :no_content : :bad_request) }
......
---
title: Collect docker registry related metrics
merge_request: 17063
author:
type: added
......@@ -40,6 +40,12 @@ describe Projects::Registry::RepositoriesController do
expect(response).to have_gitlab_http_status(:ok)
end
it 'tracks the event' do
expect(Gitlab::Tracking).to receive(:event).with(anything, 'list_repositories', {})
go_to_index
end
it 'creates a root container repository' do
expect { go_to_index }.to change { ContainerRepository.all.count }.by(1)
expect(ContainerRepository.first).to be_root_repository
......@@ -92,8 +98,16 @@ describe Projects::Registry::RepositoriesController do
expect(DeleteContainerRepositoryWorker).to receive(:perform_async).with(user.id, repository.id)
delete_repository(repository)
expect(response).to have_gitlab_http_status(:no_content)
end
it 'tracks the event' do
expect(Gitlab::Tracking).to receive(:event).with(anything, 'delete_repository', {})
allow(DeleteContainerRepositoryWorker).to receive(:perform_async).with(user.id, repository.id)
delete_repository(repository)
end
end
end
end
......
......@@ -38,6 +38,12 @@ describe Projects::Registry::TagsController do
expect(response).to match_response_schema('registry/tags')
expect(response).to include_pagination_headers
end
it 'tracks the event' do
expect(Gitlab::Tracking).to receive(:event).with(anything, 'list_tags', {})
get_tags
end
end
context 'when user can read the registry' do
......@@ -100,6 +106,13 @@ describe Projects::Registry::TagsController do
destroy_tag('test.')
end
it 'tracks the event' do
expect_delete_tags(%w[test.])
expect(controller).to receive(:track_event).with(:delete_tag)
destroy_tag('test.')
end
end
end
......@@ -134,6 +147,13 @@ describe Projects::Registry::TagsController do
bulk_destroy_tags(tags)
end
it 'tracks the event' do
expect_delete_tags(tags)
expect(Gitlab::Tracking).to receive(:event).with(anything, 'delete_tag_bulk', {})
bulk_destroy_tags(tags)
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment