pack_stats 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +6 -16
- data/lib/pack_stats/gauge_metric.rb +13 -1
- data/lib/pack_stats.rb +17 -4
- metadata +2 -13
- data/sorbet/config +0 -4
- data/sorbet/rbi/gems/ast@2.4.2.rbi +0 -584
- data/sorbet/rbi/gems/code_ownership@1.29.2.rbi +0 -525
- data/sorbet/rbi/gems/code_teams@1.0.0.rbi +0 -120
- data/sorbet/rbi/gems/dogapi@1.45.0.rbi +0 -551
- data/sorbet/rbi/gems/manual.rbi +0 -4
- data/sorbet/rbi/gems/packs@0.0.5.rbi +0 -111
- data/sorbet/rbi/gems/parse_packwerk@0.16.0.rbi +0 -224
- data/sorbet/rbi/gems/rspec@3.10.0.rbi +0 -13
- data/sorbet/rbi/gems/rubocop-packs@0.0.30.rbi +0 -272
- data/sorbet/rbi/todo.rbi +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60677361991af3d26c3e99c8869f07d92bd4be100ca7247b17ea89e898de4537
|
4
|
+
data.tar.gz: 10f3807f7d6641cc8228ea824167aa284d58f69375f27d2f623235d532f3d3ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9757afa0869a454e6b0569b0004a66341c5f4f15d015f530c94397a510b379823593efd7242ceaa6b142b4156827d7aaee32047227686973342baa85d6f9c809
|
7
|
+
data.tar.gz: 33bbcbbaf89cc0ff2de1ccce13b472b51c321dac78bcab9726aeadb568512c2cd0f2bcb5aefec7f10c18db2020658752967cc7d9c60969c685df8474cffeaa80
|
data/README.md
CHANGED
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
This gem is used to report opinionated statistics about modularization to DataDog and other observability systems.
|
4
4
|
|
5
|
+
# Configuring Packs
|
6
|
+
This gem assumes you've correctly configured the [`packs`](https://github.com/rubyatscale/packs#configuration) gem so that `pack_stats` knows where to find your code's packs.
|
7
|
+
|
5
8
|
# Configuring Ownership
|
6
9
|
The gem reports metrics per-team, where each team is configured based on metadata included in Packwerk package.yml files.
|
7
10
|
|
@@ -62,13 +65,7 @@ namespace(:modularization) do
|
|
62
65
|
# `enforce_dependencies` and `enforce_privacy` set to true, then update deprecations.
|
63
66
|
old_packages = ParsePackwerk.all
|
64
67
|
old_packages.each do |package|
|
65
|
-
new_package =
|
66
|
-
dependencies: package.dependencies,
|
67
|
-
enforce_dependencies: true,
|
68
|
-
enforce_privacy: true,
|
69
|
-
metadata: package.metadata,
|
70
|
-
name: package.name
|
71
|
-
)
|
68
|
+
new_package = package.with(enforce_dependencies: true, enforce_privacy: true)
|
72
69
|
ParsePackwerk.write_package_yml!(new_package)
|
73
70
|
end
|
74
71
|
|
@@ -76,14 +73,7 @@ namespace(:modularization) do
|
|
76
73
|
|
77
74
|
# Now we reset it back so that the protection values are the same as the native packwerk configuration
|
78
75
|
old_packages.each do |package|
|
79
|
-
|
80
|
-
dependencies: package.dependencies,
|
81
|
-
enforce_dependencies: package.enforce_dependencies,
|
82
|
-
enforce_privacy: package.enforce_privacy,
|
83
|
-
metadata: package.metadata,
|
84
|
-
name: package.name
|
85
|
-
)
|
86
|
-
ParsePackwerk.write_package_yml!(new_package)
|
76
|
+
ParsePackwerk.write_package_yml!(package)
|
87
77
|
end
|
88
78
|
|
89
79
|
PackStats.report_to_datadog!(
|
@@ -98,7 +88,7 @@ end
|
|
98
88
|
|
99
89
|
# Using Other Observability Tools
|
100
90
|
|
101
|
-
Right now this tool sends metrics to DataDog
|
91
|
+
Right now this tool sends metrics to DataDog only. However, if you want to use this with other tools, you can call `PackStats.get_metrics(...)` to get generic metrics that you can then send to whatever observability provider you use.
|
102
92
|
|
103
93
|
# Setting Up Your Dashboards
|
104
94
|
|
@@ -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:
|
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
|
+
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:
|
11
|
+
date: 2023-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: code_teams
|
@@ -202,17 +202,6 @@ files:
|
|
202
202
|
- lib/pack_stats/private/source_code_file.rb
|
203
203
|
- lib/pack_stats/tag.rb
|
204
204
|
- lib/pack_stats/tags.rb
|
205
|
-
- sorbet/config
|
206
|
-
- sorbet/rbi/gems/ast@2.4.2.rbi
|
207
|
-
- sorbet/rbi/gems/code_ownership@1.29.2.rbi
|
208
|
-
- sorbet/rbi/gems/code_teams@1.0.0.rbi
|
209
|
-
- sorbet/rbi/gems/dogapi@1.45.0.rbi
|
210
|
-
- sorbet/rbi/gems/manual.rbi
|
211
|
-
- sorbet/rbi/gems/packs@0.0.5.rbi
|
212
|
-
- sorbet/rbi/gems/parse_packwerk@0.16.0.rbi
|
213
|
-
- sorbet/rbi/gems/rspec@3.10.0.rbi
|
214
|
-
- sorbet/rbi/gems/rubocop-packs@0.0.30.rbi
|
215
|
-
- sorbet/rbi/todo.rbi
|
216
205
|
homepage: https://github.com/rubyatscale/pack_stats
|
217
206
|
licenses:
|
218
207
|
- MIT
|
data/sorbet/config
DELETED