kennel 2.20.0 → 2.21.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d41a632f2e488aacff6253cdb1b161d628d7522ffd4b7ce3e006455b912ca16d
4
- data.tar.gz: 0ffe3c8a9ec7d828aa397460af8f06af307f14e4a9740ff0e1a1693bc6c65950
3
+ metadata.gz: 5f604eb100e46e40ba76333717c9ddb99e06cd85be98f7eb19217b7be1b193b2
4
+ data.tar.gz: 352ead0a6c2ce295f14113d03f9ab956278851d55457340dffa9d6fdf042856e
5
5
  SHA512:
6
- metadata.gz: 8151f10629556f4b9dbad8b11c69e032fca8ebbd00a50e888482a2bb37659ce70028a8740606a90745de3b3808967165b4cc10c1faeac2ccce707bfc57cb8811
7
- data.tar.gz: 6682f0c4815aacd911464f92c94f376110e52219c465f6f482dfbb85399b0ec4ea2b5d33d78ae394f753a04ef959b6b766325bd4bbc2f0b461dd172a24ed1349
6
+ metadata.gz: 5d0e3477bcef3043433fca52d3e3c3940f7cd315c7c89ecebb7a07eb7a50d56adcb46522a51492ef47c72346b10bec7446c495c8d368c5ff741a510e2c8885b9
7
+ data.tar.gz: 0e71a447829ac1dcc996b08858e7dcd720b3e3f6f9e5b2e008bc0e187e952e1cafaa561b62152a37e547053d033ef0c2e37746419205eb1788d859c536f5d77a
@@ -86,7 +86,14 @@ module Kennel
86
86
  end
87
87
  when "synthetics/tests"
88
88
  data[:locations] = :all if data[:locations].sort == Kennel::Models::SyntheticTest::LOCATIONS.sort
89
- else
89
+ when "slo"
90
+ # sli_specification it is only used by datadog if the user switched to "Bad Events"
91
+ # otherwise user would be trying to set sli_specification but the slo does not change since query is used
92
+ if data.key?(:query) && data.key?(:sli_specification)
93
+ delete = (data.dig(:sli_specification, :count, :bad_events_formula) ? :query : :sli_specification)
94
+ data.delete delete
95
+ end
96
+ else # uncovered
90
97
  # noop
91
98
  end
92
99
 
@@ -10,10 +10,16 @@ module Kennel
10
10
 
11
11
  def self.file_location
12
12
  return @file_location if defined?(@file_location)
13
- if (location = instance_methods(false).first)
14
- @file_location = force_relative_path(instance_method(location).source_location.first)
13
+ methods = instance_methods(false)
14
+ if methods.any?
15
+ @file_location = methods.detect do |method|
16
+ location = instance_method(method).source_location.first
17
+ if (path = find_relative_path(location))
18
+ break path
19
+ end
20
+ end || raise("Unable to find file_location for #{name}")
15
21
  else
16
- @file_location = nil
22
+ @file_location = nil # not sure if this is actually needed
17
23
  end
18
24
  end
19
25
 
@@ -29,11 +35,9 @@ module Kennel
29
35
 
30
36
  private
31
37
 
32
- private_class_method def self.force_relative_path(path)
38
+ private_class_method def self.find_relative_path(path)
33
39
  return path unless File.absolute_path?(path)
34
- path.dup.sub!("#{Bundler.root}/", "") ||
35
- path.dup.sub!("#{Dir.pwd}/", "") ||
36
- raise("Unable to make path #{path} relative with bundler root #{Bundler.root} or pwd #{Dir.pwd}")
40
+ path.dup.sub!("#{Bundler.root}/", "") || path.dup.sub!("#{Dir.pwd}/", "")
37
41
  end
38
42
 
39
43
  # hook for users to add custom filtering via `prepend`
@@ -15,7 +15,8 @@ module Kennel
15
15
  groups: nil,
16
16
  monitor_ids: [],
17
17
  thresholds: [],
18
- primary: nil
18
+ primary: nil,
19
+ sli_specification: nil
19
20
  }.freeze
20
21
 
21
22
  settings :type, :description, :thresholds, :query, :tags, :monitor_ids, :monitor_tags, :name, :groups, :sli_specification, :primary
@@ -27,7 +28,8 @@ module Kennel
27
28
  monitor_ids: -> { DEFAULTS.fetch(:monitor_ids) },
28
29
  thresholds: -> { DEFAULTS.fetch(:thresholds) },
29
30
  groups: -> { DEFAULTS.fetch(:groups) },
30
- primary: -> { DEFAULTS.fetch(:primary) }
31
+ primary: -> { DEFAULTS.fetch(:primary) },
32
+ sli_specification: -> { DEFAULTS.fetch(:sli_specification) }
31
33
  )
32
34
 
33
35
  def build_json
@@ -50,9 +52,8 @@ module Kennel
50
52
  data[:target_threshold] = threshold[:target]
51
53
  end
52
54
 
53
- # TODO: if user set sli_specification but we don't use it we should raise, but sadly we can't detect that easily
54
- if type == "time_slice"
55
- data[:sli_specification] = sli_specification
55
+ if (v = sli_specification)
56
+ data[:sli_specification] = v
56
57
  elsif (v = query)
57
58
  data[:query] = v
58
59
  end
@@ -102,10 +103,14 @@ module Kennel
102
103
  [:timeframe, :warning_threshold, :target_threshold].each { |k| actual.delete k }
103
104
  end
104
105
 
105
- # datadog always sets this, but we only set it for time_slice, so discard it for everything else to avoid diff
106
- if expected[:type] != "time_slice"
107
- actual.delete :sli_specification
108
- end
106
+ # discard deprecated query which stays in datadog forever when we are trying to set sli_specification
107
+ # (downgrading to query by setting sli_specification=nil is not supported in the api)
108
+ actual.delete :query if expected[:sli_specification]
109
+
110
+ # user set query so let's not worry about sli_specification even if this might be hiding bugs
111
+ # ideally we'd validate and tell the user that this will have no effect (see importer logic)
112
+ # but I'm not confident this will always be right
113
+ actual.delete :sli_specification if expected[:query]
109
114
 
110
115
  ignore_default(expected, actual, DEFAULTS)
111
116
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Kennel
3
- VERSION = "2.20.0"
3
+ VERSION = "2.21.0"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kennel
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.20.0
4
+ version: 2.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser