ffwd-google-cloud 0.4.5 → 0.4.6

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
  SHA1:
3
- metadata.gz: 545a58cedb871175a2eae3b65422f5ddfd03851d
4
- data.tar.gz: 93bae64294e5dbeb5c5a654dac9878f4178a45bb
3
+ metadata.gz: 361e6fba065147958d18bf71cc0b48bb96f8f5bb
4
+ data.tar.gz: 8dedd6d559bc81c6542a3bdfa39d3ed8ebd7e8b5
5
5
  SHA512:
6
- metadata.gz: 3e1d6d266b9e1304bf2ef70ca80c238ddbc3e4438faa5f8552537346c695f933a4a70f53c73fd71bb9dfd1a73e98c49b79bc027722bfefddd58357982ecb0511
7
- data.tar.gz: ea0a626db8c218dd2e985e3b0627b25b3cea0e79da8f790ef8a67528d1d970459d24b258185be082b90e6a3daeb7088dd5f8172db0e41c33405e49a30ec54e82
6
+ metadata.gz: b6e8bcbc321302513fb3814e3d4e9975da9640e2ebbbc552ed7e3816953a3888b68160b035064fbf995cf3c3f2b7b5572d0419a34dad5f4d43f9f7133601f640
7
+ data.tar.gz: 8682ee6cabafb38d1117279dd99f38db593dcd967c869c851e677db08b797d2bf11385e830ea21eec145bd0b94a9071f68e4c3a390ce09378c0c84d47799977d
@@ -13,11 +13,14 @@
13
13
  # License for the specific language governing permissions and limitations under
14
14
  # the License.
15
15
  require 'set'
16
+ require 'zlib'
16
17
 
17
18
  module FFWD::Plugin::GoogleCloud
18
19
  CUSTOM_PREFIX = "custom.cloudmonitoring.googleapis.com"
19
20
 
20
21
  module Utils
22
+ M64 = 1 << 64
23
+
21
24
  def self.make_common_labels buffer
22
25
  return nil if buffer.empty?
23
26
  make_labels buffer.first.fixed_attr
@@ -33,7 +36,8 @@ module FFWD::Plugin::GoogleCloud
33
36
  buffer.each do |m|
34
37
  d = make_desc(m)
35
38
 
36
- seen_key = [d[:metric], d[:labels].map{|k, v| [k, v]}.sort].hash
39
+ # using built-in hash OK since we are only internally de-duplicating.
40
+ seen_key = [d[:metric], d[:labels].keys.sort].hash
37
41
 
38
42
  if seen.member?(seen_key)
39
43
  dropped += 1
@@ -67,7 +71,9 @@ module FFWD::Plugin::GoogleCloud
67
71
  entries << what unless what.nil?
68
72
  entries = entries.join('.')
69
73
 
70
- hash = attributes.keys.sort.hash.abs.to_s(32)
74
+ # ruby Object#hash is inconsistent across runs, so we will instead
75
+ # perform a custom hashing.
76
+ hash = hash_labels(attributes).to_s(32)
71
77
 
72
78
  unless entries.empty?
73
79
  "#{CUSTOM_PREFIX}/#{m.key}/#{entries}-#{hash}"
@@ -76,6 +82,12 @@ module FFWD::Plugin::GoogleCloud
76
82
  end
77
83
  end
78
84
 
85
+ def self.hash_labels attributes
86
+ attributes.keys.sort.map{|v| Zlib::crc32(v.to_s)}.reduce(33){|k, v|
87
+ (63 * k + v).modulo(M64)
88
+ }
89
+ end
90
+
79
91
  def self.make_labels attr
80
92
  Hash[attr.select{|k, v| k.to_s != "what"}.map{|k, v|
81
93
  ["#{CUSTOM_PREFIX}/#{k}", v]
@@ -16,7 +16,7 @@
16
16
  module FFWD
17
17
  module Plugin
18
18
  module GoogleCloud
19
- VERSION = "0.4.5"
19
+ VERSION = "0.4.6"
20
20
  end
21
21
  end
22
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ffwd-google-cloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - John-John Tedro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-12 00:00:00.000000000 Z
11
+ date: 2015-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: em-http-request
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 0.4.5
33
+ version: 0.4.6
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 0.4.5
40
+ version: 0.4.6
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement