Commit cce5d7bd authored by Rajendra Kadam's avatar Rajendra Kadam Committed by Markus Koller

Add License metric classes for Zuora Subscription ID and License MD5

parent a0f715ed
...@@ -9,6 +9,7 @@ value_type: string ...@@ -9,6 +9,7 @@ value_type: string
status: data_available status: data_available
time_frame: none time_frame: none
data_source: license data_source: license
instrumentation_class: 'LicenseMdFiveMetric'
data_category: Standard data_category: Standard
distribution: distribution:
- ee - ee
......
...@@ -9,6 +9,7 @@ value_type: string ...@@ -9,6 +9,7 @@ value_type: string
status: data_available status: data_available
time_frame: none time_frame: none
data_source: license data_source: license
instrumentation_class: 'ZuoraSubscriptionIdMetric'
data_category: Standard data_category: Standard
distribution: distribution:
- ee - ee
......
# frozen_string_literal: true
module Gitlab
module Usage
module Metrics
module Instrumentations
class LicenseMdFiveMetric < ::Gitlab::Usage::Metrics::Instrumentations::GenericMetric
value do
::License.current.md5
end
end
end
end
end
end
# frozen_string_literal: true
module Gitlab
module Usage
module Metrics
module Instrumentations
class ZuoraSubscriptionIdMetric < ::Gitlab::Usage::Metrics::Instrumentations::GenericMetric
value do
::License.current.subscription_id
end
end
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::Usage::Metrics::Instrumentations::LicenseMdFiveMetric do
it_behaves_like 'a correct instrumented metric value', { time_frame: 'none', data_source: 'ruby' } do
let(:expected_value) { Digest::MD5.hexdigest(::License.current.data) }
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::Usage::Metrics::Instrumentations::ZuoraSubscriptionIdMetric do
it_behaves_like 'a correct instrumented metric value', { time_frame: 'none', data_source: 'ruby' } do
let(:expected_value) { ::License.current.subscription_id }
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::UsageDataMetrics do
describe '.uncached_data' do
subject { described_class.uncached_data }
around do |example|
described_class.instance_variable_set(:@definitions, nil)
example.run
described_class.instance_variable_set(:@definitions, nil)
end
before do
allow(ActiveRecord::Base.connection).to receive(:transaction_open?).and_return(false) # rubocop:disable Database/MultipleDatabases
end
context 'with instrumentation_class' do
it 'includes top level keys' do
expect(subject).to include(:license_md5)
expect(subject).to include(:license_subscription_id)
end
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