Commit 8338073a authored by Steve Abrams's avatar Steve Abrams

Merge branch '262081-symbol-pkg-events' into 'master'

NuGet symbol package event tracking

See merge request gitlab-org/gitlab!64554
parents 58d4e8f4 507fd6e9
......@@ -3,7 +3,7 @@
class Packages::Event < ApplicationRecord
belongs_to :package, optional: true
UNIQUE_EVENTS_ALLOWED = %i[push_package delete_package pull_package].freeze
UNIQUE_EVENTS_ALLOWED = %i[push_package delete_package pull_package pull_symbol_package push_symbol_package].freeze
EVENT_SCOPES = ::Packages::Package.package_types.merge(container: 1000, tag: 1001).freeze
EVENT_PREFIX = "i_package"
......@@ -21,7 +21,9 @@ class Packages::Event < ApplicationRecord
delete_tag: 7,
delete_tag_bulk: 8,
list_tags: 9,
cli_metadata: 10
cli_metadata: 10,
pull_symbol_package: 11,
push_symbol_package: 12
}
enum originator_type: { user: 0, deploy_token: 1, guest: 2 }
......
---
key_path: counts.package_events_i_package_nuget_pull_symbol_package
name: nuget_symbol_packages_pulled
description: A count of NuGet symbol packages that have been downloaded from the package registry
product_section: ops
product_stage: package
product_group: group::package
product_category: package registry
value_type: number
status: implemented
milestone: "14.1"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/64554
time_frame: all
data_source: redis
data_category: Optional
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
---
key_path: counts.package_events_i_package_nuget_push_symbol_package
name: nuget_symbol_packages_pushed
description: A count of NuGet symbol packages that have been uploaded to the package registry
product_section: ops
product_stage: package
product_group: group::package
product_category: package registry
value_type: number
status: implemented
milestone: "14.1"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/64554
time_frame: all
data_source: redis
data_category: Optional
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
---
key_path: counts.package_events_i_package_pull_symbol_package
name: symbol_packages_pulled
description: A count of symbol packages that have been pulled from the package registry
product_section: ops
product_stage: package
product_group: group::package
product_category: package registry
value_type: number
status: implemented
milestone: "14.1"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/64554
time_frame: all
data_source: redis
data_category: Optional
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
\ No newline at end of file
---
key_path: counts.package_events_i_package_pull_symbol_package_by_deploy_token
name: symbol_packages_pulled_by_deploy_token
description: A count of symbol packages that have been pulled with a deploy token from the package registry
product_section: ops
product_stage: package
product_group: group::package
product_category: package registry
value_type: number
status: implemented
milestone: "14.1"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/64554
time_frame: all
data_source: redis
data_category: Optional
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
---
key_path: counts.package_events_i_package_pull_symbol_package_by_guest
name: symbol_packages_pulled_by_guest
description: A count of symbol packages that have been pulled with by a guest from the package registry
product_section: ops
product_stage: package
product_group: group::package
product_category: package registry
value_type: number
status: implemented
milestone: "14.1"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/64554
time_frame: all
data_source: redis
data_category: Optional
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
\ No newline at end of file
---
key_path: counts.package_events_i_package_pull_symbol_package_by_user
name: symbol_packages_pulled_by_user
description: A count of symbol packages that have been pulled with by an authenticated user from the package registry
product_section: ops
product_stage: package
product_group: group::package
product_category: package registry
value_type: number
status: implemented
milestone: "14.1"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/64554
time_frame: all
data_source: redis
data_category: Optional
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
---
key_path: counts.package_events_i_package_push_symbol_package
name: symbol_packages_pushed
description: A count of symbol packages that have been pushed to the package registry
product_section: ops
product_stage: package
product_group: group::package
product_category: package registry
value_type: number
status: implemented
milestone: "14.1"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/64554
time_frame: all
data_source: redis
data_category: Optional
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
---
key_path: counts.package_events_i_package_push_symbol_package_by_deploy_token
name: symbol_packages_pushed_by_deploy_token
description: A count of symbol packages that have been pushed with a deploy token to the package registry
product_section: ops
product_stage: package
product_group: group::package
product_category: package registry
value_type: number
status: implemented
milestone: "14.1"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/64554
time_frame: all
data_source: redis
data_category: Optional
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
---
key_path: counts.package_events_i_package_push_symbol_package_by_guest
name: symbol_packages_pushed_by_guest
description: A count of symbol packages that have been pushed by a guest to the package registry
product_section: ops
product_stage: package
product_group: group::package
product_category: package registry
value_type: number
status: implemented
milestone: "14.1"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/64554
time_frame: all
data_source: redis
data_category: Optional
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
---
key_path: counts.package_events_i_package_push_symbol_package_by_user
name: symbol_packages_pushed_by_user
description: A count of symbol packages that have been pushed by an authenticated user to the package registry
product_section: ops
product_stage: package
product_group: group::package
product_category: package registry
value_type: number
status: implemented
milestone: "14.1"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/64554
time_frame: all
data_source: redis
data_category: Optional
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
......@@ -4472,6 +4472,20 @@ Status: `data_available`
Tiers: `free`, `premium`, `ultimate`
### `counts.package_events_i_package_nuget_pull_symbol_package`
A count of NuGet symbol packages that have been downloaded from the package registry
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/counts_all/20210709191135_package_events_i_package_nuget_pull_symbol_package.yml)
Group: `group::package`
Data Category: `Optional`
Status: `implemented`
Tiers: `free`, `premium`, `ultimate`
### `counts.package_events_i_package_nuget_push_package`
A count of NuGet packages that have been published
......@@ -4486,6 +4500,20 @@ Status: `data_available`
Tiers: `free`, `premium`, `ultimate`
### `counts.package_events_i_package_nuget_push_symbol_package`
A count of NuGet symbol packages that have been uploaded to the package registry
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/counts_all/20210709191829_package_events_i_package_nuget_push_symbol_package.yml)
Group: `group::package`
Data Category: `Optional`
Status: `implemented`
Tiers: `free`, `premium`, `ultimate`
### `counts.package_events_i_package_pull_package`
A count of packages that have been downloaded from the package registry
......@@ -4542,6 +4570,62 @@ Status: `data_available`
Tiers: `free`, `premium`, `ultimate`
### `counts.package_events_i_package_pull_symbol_package`
A count of symbol packages that have been pulled from the package registry
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/counts_all/20210709210941_package_events_i_package_pull_symbol_package.yml)
Group: `group::package`
Data Category: `Optional`
Status: `implemented`
Tiers: `free`, `premium`, `ultimate`
### `counts.package_events_i_package_pull_symbol_package_by_deploy_token`
A count of symbol packages that have been pulled with a deploy token from the package registry
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/counts_all/20210709211058_package_events_i_package_pull_symbol_package_by_deploy_token.yml)
Group: `group::package`
Data Category: `Optional`
Status: `implemented`
Tiers: `free`, `premium`, `ultimate`
### `counts.package_events_i_package_pull_symbol_package_by_guest`
A count of symbol packages that have been pulled with by a guest from the package registry
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/counts_all/20210709211248_package_events_i_package_pull_symbol_package_by_guest.yml)
Group: `group::package`
Data Category: `Optional`
Status: `implemented`
Tiers: `free`, `premium`, `ultimate`
### `counts.package_events_i_package_pull_symbol_package_by_user`
A count of symbol packages that have been pulled with by an authenticated user from the package registry
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/counts_all/20210709211341_package_events_i_package_pull_symbol_package_by_user.yml)
Group: `group::package`
Data Category: `Optional`
Status: `implemented`
Tiers: `free`, `premium`, `ultimate`
### `counts.package_events_i_package_push_package`
A count of packages that have been published to the package registry
......@@ -4598,6 +4682,62 @@ Status: `data_available`
Tiers: `free`, `premium`, `ultimate`
### `counts.package_events_i_package_push_symbol_package`
A count of symbol packages that have been pushed to the package registry
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/counts_all/20210709211439_package_events_i_package_push_symbol_package.yml)
Group: `group::package`
Data Category: `Optional`
Status: `implemented`
Tiers: `free`, `premium`, `ultimate`
### `counts.package_events_i_package_push_symbol_package_by_deploy_token`
A count of symbol packages that have been pushed with a deploy token to the package registry
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/counts_all/20210709211636_package_events_i_package_push_symbol_package_by_deploy_token.yml)
Group: `group::package`
Data Category: `Optional`
Status: `implemented`
Tiers: `free`, `premium`, `ultimate`
### `counts.package_events_i_package_push_symbol_package_by_guest`
A count of symbol packages that have been pushed by a guest to the package registry
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/counts_all/20210709211731_package_events_i_package_push_symbol_package_by_guest.yml)
Group: `group::package`
Data Category: `Optional`
Status: `implemented`
Tiers: `free`, `premium`, `ultimate`
### `counts.package_events_i_package_push_symbol_package_by_user`
A count of symbol packages that have been pushed by an authenticated user to the package registry
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/counts_all/20210709211831_package_events_i_package_push_symbol_package_by_user.yml)
Group: `group::package`
Data Category: `Optional`
Status: `implemented`
Tiers: `free`, `premium`, `ultimate`
### `counts.package_events_i_package_pypi_delete_package`
A count of Python packages that have been deleted from the package registry
......
......@@ -134,7 +134,16 @@ module API
use :file_params
end
put 'symbolpackage' do
upload_nuget_package_file(symbol_package: true)
upload_nuget_package_file(symbol_package: true) do |package|
track_package_event(
'push_symbol_package',
:nuget,
category: 'API::NugetPackages',
user: current_user,
project: package.project,
namespace: package.project.namespace
)
end
rescue ObjectStorage::RemoteStoreError => e
Gitlab::ErrorTracking.track_exception(e, extra: { file_name: params[:file_name], project_id: project_or_group.id })
......@@ -175,15 +184,13 @@ module API
not_found!('Package') unless package_file
if params[:format] == 'nupkg'
track_package_event(
'pull_package',
:nuget,
category: 'API::NugetPackages',
project: package_file.project,
namespace: package_file.project.namespace
)
end
track_package_event(
params[:format] == 'snupkg' ? 'pull_symbol_package' : 'pull_package',
:nuget,
category: 'API::NugetPackages',
project: package_file.project,
namespace: package_file.project.namespace
)
# nuget and dotnet don't support 302 Moved status codes, supports_direct_download has to be set to false
present_carrierwave_file!(package_file.file, supports_direct_download: false)
......
......@@ -32,14 +32,24 @@
- i_package_nuget_delete_package
- i_package_nuget_pull_package
- i_package_nuget_push_package
- i_package_nuget_pull_symbol_package
- i_package_nuget_push_symbol_package
- i_package_pull_package
- i_package_pull_package_by_deploy_token
- i_package_pull_package_by_guest
- i_package_pull_package_by_user
- i_package_pull_symbol_package
- i_package_pull_symbol_package_by_deploy_token
- i_package_pull_symbol_package_by_guest
- i_package_pull_symbol_package_by_user
- i_package_push_package
- i_package_push_package_by_deploy_token
- i_package_push_package_by_guest
- i_package_push_package_by_user
- i_package_push_symbol_package
- i_package_push_symbol_package_by_deploy_token
- i_package_push_symbol_package_by_guest
- i_package_push_symbol_package_by_user
- i_package_pypi_delete_package
- i_package_pypi_pull_package
- i_package_pypi_push_package
......
......@@ -14,7 +14,7 @@ RSpec.describe Gitlab::UsageDataCounters::PackageEventCounter, :clean_gitlab_red
end
it 'includes the right events' do
expect(described_class::KNOWN_EVENTS.size).to eq 53
expect(described_class::KNOWN_EVENTS.size).to eq 63
end
described_class::KNOWN_EVENTS.each do |event|
......
......@@ -170,7 +170,9 @@ RSpec.shared_examples 'process nuget upload' do |user_type, status, add_member =
it_behaves_like 'package workhorse uploads'
it_behaves_like 'creates nuget package files'
unless symbol_package
if symbol_package
it_behaves_like 'a package tracking event', 'API::NugetPackages', 'push_symbol_package'
else
it_behaves_like 'a package tracking event', 'API::NugetPackages', 'push_package'
end
end
......@@ -311,6 +313,8 @@ RSpec.shared_examples 'process nuget download content request' do |user_type, st
expect(response.media_type).to eq('application/octet-stream')
end
it_behaves_like 'a package tracking event', 'API::NugetPackages', 'pull_symbol_package'
end
context 'with lower case package name' do
......
......@@ -147,7 +147,7 @@ RSpec.shared_examples 'a package tracking event' do |category, action|
stub_feature_flags(collect_package_events: true)
end
it "creates a gitlab tracking event #{action}", :snowplow do
it "creates a gitlab tracking event #{action}", :snowplow, :aggregate_failures do
expect { subject }.to change { Packages::Event.count }.by(1)
expect_snowplow_event(category: category, action: action, **snowplow_gitlab_standard_context)
......
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