pack_stats 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 43fc659730748dbbe47795bd71e3b421b746b8a76b1f8fe4c8d058161c3175b6
4
- data.tar.gz: f5ad0c0e321f701bd7f426a67faaca0988a00ac5b47c44995139818918e4c540
3
+ metadata.gz: 60677361991af3d26c3e99c8869f07d92bd4be100ca7247b17ea89e898de4537
4
+ data.tar.gz: 10f3807f7d6641cc8228ea824167aa284d58f69375f27d2f623235d532f3d3ba
5
5
  SHA512:
6
- metadata.gz: 2d4d160bc1584c09a97c271a1f45a38b56183730f65c8a9235b85add2eb45e30a2e403ea19a13364b2a5e06fba41bbad4a36fb4e42adab96b205cadb61e117d4
7
- data.tar.gz: 99d1de19334442e788ff48e27a3c980891e0cdfffb6327667dd3338e62b45499762e5d55580244fcac6771c87e3c05a93fe3589445c9ed9a09b22072d040a9ba
6
+ metadata.gz: 9757afa0869a454e6b0569b0004a66341c5f4f15d015f530c94397a510b379823593efd7242ceaa6b142b4156827d7aaee32047227686973342baa85d6f9c809
7
+ data.tar.gz: 33bbcbbaf89cc0ff2de1ccce13b472b51c321dac78bcab9726aeadb568512c2cd0f2bcb5aefec7f10c18db2020658752967cc7d9c60969c685df8474cffeaa80
@@ -17,10 +17,11 @@ module PackStats
17
17
  raise StandardError.new("Metrics names must not exceed 200 characters: #{name}") # rubocop:disable Style/RaiseArgs
18
18
  end
19
19
 
20
+ all_tags = [*tags, max_enforcements_tag]
20
21
  new(
21
22
  name: name,
22
23
  count: count,
23
- tags: tags
24
+ tags: all_tags
24
25
  )
25
26
  end
26
27
 
@@ -35,5 +36,16 @@ module PackStats
35
36
  other.count == self.count &&
36
37
  other.tags == self.tags
37
38
  end
39
+
40
+ sig { params(tag_value: T::Boolean).void }
41
+ def self.set_max_enforcements_tag(tag_value)
42
+ @max_enforcements_tag = T.let(@max_enforcements_tag, T.nilable(Tag))
43
+ @max_enforcements_tag = Tag.new(key: 'max_enforcements', value: tag_value ? 'true' : 'false')
44
+ end
45
+
46
+ sig { returns(Tag) }
47
+ def self.max_enforcements_tag
48
+ @max_enforcements_tag || Tag.new(key: 'max_enforcements', value: 'false')
49
+ end
38
50
  end
39
51
  end
data/lib/pack_stats.rb CHANGED
@@ -39,7 +39,9 @@ module PackStats
39
39
  # See note on get_metrics
40
40
  packaged_source_code_locations: T.nilable(T::Array[Pathname]),
41
41
  # See note on get_metrics
42
- use_gusto_legacy_names: T::Boolean
42
+ use_gusto_legacy_names: T::Boolean,
43
+ # See note on get_metrics
44
+ max_enforcements_tag_value: T::Boolean
43
45
  ).void
44
46
  end
45
47
  def self.report_to_datadog!(
@@ -50,7 +52,8 @@ module PackStats
50
52
  report_time: Time.now, # rubocop:disable Rails/TimeZone
51
53
  verbose: false,
52
54
  packaged_source_code_locations: [],
53
- use_gusto_legacy_names: false
55
+ use_gusto_legacy_names: false,
56
+ max_enforcements_tag_value: false
54
57
  )
55
58
 
56
59
  all_metrics = self.get_metrics(
@@ -58,6 +61,7 @@ module PackStats
58
61
  componentized_source_code_locations: componentized_source_code_locations,
59
62
  app_name: app_name,
60
63
  use_gusto_legacy_names: use_gusto_legacy_names,
64
+ max_enforcements_tag_value: max_enforcements_tag_value,
61
65
  )
62
66
 
63
67
  # This helps us debug what metrics are being sent
@@ -89,7 +93,12 @@ module PackStats
89
93
  # Gusto uses this to preserve historical trends in Dashboards as the names of
90
94
  # things changed, but new dashboards can use names that better match current tooling conventions.
91
95
  # The behavior of setting this parameter to true might change without warning
92
- use_gusto_legacy_names: T::Boolean
96
+ use_gusto_legacy_names: T::Boolean,
97
+ # You can set this to `true` to tag all metrics with `max_enforcements:true`.
98
+ # This is useful if you want to submit two sets of metrics:
99
+ # Once with the violation counts as configured in the app
100
+ # Another time with the violation counts after turning on all enforcements and running `bin/packwerk update`.
101
+ max_enforcements_tag_value: T::Boolean
93
102
  ).returns(T::Array[GaugeMetric])
94
103
  end
95
104
  def self.get_metrics(
@@ -97,8 +106,12 @@ module PackStats
97
106
  componentized_source_code_locations:,
98
107
  app_name:,
99
108
  packaged_source_code_locations: [],
100
- use_gusto_legacy_names: false
109
+ use_gusto_legacy_names: false,
110
+ max_enforcements_tag_value: false
101
111
  )
112
+
113
+ GaugeMetric.set_max_enforcements_tag(max_enforcements_tag_value)
114
+
102
115
  all_metrics = Private::DatadogReporter.get_metrics(
103
116
  source_code_files: source_code_files(
104
117
  source_code_pathnames: source_code_pathnames,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pack_stats
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gusto Engineers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-06 00:00:00.000000000 Z
11
+ date: 2023-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: code_teams