From 02f6d6aa42a69de9e316ec951a032ef03cd07b78 Mon Sep 17 00:00:00 2001 From: Tal Kopel <tkopel@gitlab.com> Date: Mon, 22 Apr 2024 03:52:36 +0000 Subject: [PATCH] Resolve "metric fo sync with GitLab License DB by package type" --- ...tadata_sync_activation_by_type_metric.json | 8 ++++++++ ...etadata_sync_activation_by_type_metric.yml | 20 +++++++++++++++++++ ...metadata_sync_activation_by_type_metric.rb | 15 ++++++++++++++ ...ata_sync_activation_by_type_metric_spec.rb | 10 ++++++++++ 4 files changed, 53 insertions(+) create mode 100644 config/metrics/objects_schemas/package_registry_metadata_sync_activation_by_type_metric.json create mode 100644 ee/config/metrics/settings/20240229135438_package_metadata_sync_activation_by_type_metric.yml create mode 100644 ee/lib/gitlab/usage/metrics/instrumentations/package_registry_metadata_sync_activation_by_type_metric.rb create mode 100644 ee/spec/lib/gitlab/usage/metrics/instrumentations/package_registry_metadata_sync_activation_by_type_metric_spec.rb diff --git a/config/metrics/objects_schemas/package_registry_metadata_sync_activation_by_type_metric.json b/config/metrics/objects_schemas/package_registry_metadata_sync_activation_by_type_metric.json new file mode 100644 index 0000000000000..b86c63552243f --- /dev/null +++ b/config/metrics/objects_schemas/package_registry_metadata_sync_activation_by_type_metric.json @@ -0,0 +1,8 @@ +{ + "type": "array", + "items": { + "type": [ + "string" + ] + } +} diff --git a/ee/config/metrics/settings/20240229135438_package_metadata_sync_activation_by_type_metric.yml b/ee/config/metrics/settings/20240229135438_package_metadata_sync_activation_by_type_metric.yml new file mode 100644 index 0000000000000..40319cbd3dc88 --- /dev/null +++ b/ee/config/metrics/settings/20240229135438_package_metadata_sync_activation_by_type_metric.yml @@ -0,0 +1,20 @@ +--- +key_path: settings.package_metadata_sync_activation_by_type_metric +description: "List the package types that have sync enabled to registries" +product_section: sec +product_stage: secure +product_group: composition_analysis +value_type: object +status: active +milestone: "17.0" +introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/146176 +time_frame: none +data_source: system +data_category: optional +instrumentation_class: PackageRegistryMetadataSyncActivationByTypeMetric +performance_indicator_type: [] +distribution: +- ee +tier: +- ultimate +value_json_schema: "config/metrics/objects_schemas/package_registry_metadata_sync_activation_by_type_metric.json" diff --git a/ee/lib/gitlab/usage/metrics/instrumentations/package_registry_metadata_sync_activation_by_type_metric.rb b/ee/lib/gitlab/usage/metrics/instrumentations/package_registry_metadata_sync_activation_by_type_metric.rb new file mode 100644 index 0000000000000..339fc8a76262d --- /dev/null +++ b/ee/lib/gitlab/usage/metrics/instrumentations/package_registry_metadata_sync_activation_by_type_metric.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module Gitlab + module Usage + module Metrics + module Instrumentations + class PackageRegistryMetadataSyncActivationByTypeMetric < GenericMetric + def value + ::PackageMetadata::SyncConfiguration.permitted_purl_types + end + end + end + end + end +end diff --git a/ee/spec/lib/gitlab/usage/metrics/instrumentations/package_registry_metadata_sync_activation_by_type_metric_spec.rb b/ee/spec/lib/gitlab/usage/metrics/instrumentations/package_registry_metadata_sync_activation_by_type_metric_spec.rb new file mode 100644 index 0000000000000..2d4c9375dd5aa --- /dev/null +++ b/ee/spec/lib/gitlab/usage/metrics/instrumentations/package_registry_metadata_sync_activation_by_type_metric_spec.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Gitlab::Usage::Metrics::Instrumentations::PackageRegistryMetadataSyncActivationByTypeMetric, feature_category: :software_composition_analysis do + let(:expected_value) { PackageMetadata::SyncConfiguration.permitted_purl_types } + let(:expected_query) { expected_value } + + it_behaves_like 'a correct instrumented metric value and query', { time_frame: 'all' } +end -- GitLab