stackdriver 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. data/lib/stackdriver.rb +19 -10
  2. metadata +18 -13
  3. checksums.yaml +0 -7
  4. checksums.yaml.gz.asc +0 -11
  5. data.tar.gz.asc +0 -11
  6. metadata.gz.asc +0 -11
@@ -2,24 +2,33 @@ require 'multi_json'
2
2
 
3
3
  module StackDriver
4
4
  POST_URI = "https://custom-gateway.stackdriver.com/v1/custom"
5
-
6
- def self.init customer_id, api_key
7
- @customer_id = customer_id
8
- @api_key = api_key
5
+ DELETE_URI = "https://custom-gateway.stackdriver.com/v1/delete_custom"
6
+
7
+ def self.init *args
8
+ if args.count > 1
9
+ puts "Customer ID is no longer needed, and will be deprecated"
10
+ args.shift
9
11
  end
10
-
12
+ @api_key = args[0]
13
+ end
14
+
11
15
  def self.send_metric name, value, time, instance=''
12
16
  msg = build_message name, value, time, instance
13
- post MultiJson.dump(msg)
17
+ post MultiJson.dump(msg), StackDriver::POST_URI
18
+ end
19
+
20
+ def self.delete_metric name, time
21
+ msg = build_message name, nil, time
22
+ post MultiJson.dump(msg), StackDriver::DELETE_URI
14
23
  end
15
24
 
16
25
  private
17
26
 
18
- def self.post msg
27
+ def self.post msg, uri
19
28
  headers = {'content-type' => 'application/json',
20
29
  'x-stackdriver-apikey' => @api_key}
21
30
 
22
- uri = URI(StackDriver::POST_URI)
31
+ uri = URI(uri)
23
32
  http = Net::HTTP.new(uri.host, uri.port)
24
33
  http.use_ssl = true
25
34
 
@@ -33,8 +42,8 @@ module StackDriver
33
42
 
34
43
  def self.build_message name, value, time, instance=''
35
44
  data_point = {'name' => name, 'value' => value, 'collected_at' => time}
45
+ data_point.merge!('value' => value) unless value.nil?
36
46
  data_point.merge!('instance' => instance) unless instance.empty?
37
- {'timestamp' => Time.now.to_i, 'customer_id' => @customer_id,
38
- 'proto_version' => '1', 'data' => data_point}
47
+ {'timestamp' => Time.now.to_i, 'proto_version' => '1', 'data' => data_point}
39
48
  end
40
49
  end
metadata CHANGED
@@ -1,60 +1,65 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stackdriver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Grant T. Olson
9
+ - Sam Marx
8
10
  autorequire:
9
11
  bindir: bin
10
12
  cert_chain: []
11
- date: 2013-11-19 00:00:00.000000000 Z
13
+ date: 2014-03-31 00:00:00.000000000 Z
12
14
  dependencies:
13
15
  - !ruby/object:Gem::Dependency
14
16
  name: multi_json
15
17
  requirement: !ruby/object:Gem::Requirement
18
+ none: false
16
19
  requirements:
17
- - - '>='
20
+ - - ! '>='
18
21
  - !ruby/object:Gem::Version
19
22
  version: 1.7.0
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
23
27
  requirements:
24
- - - '>='
28
+ - - ! '>='
25
29
  - !ruby/object:Gem::Version
26
30
  version: 1.7.0
27
- description: Send StackDriver custom metrics via the API.
31
+ description: Send and delete StackDriver custom metrics via the API.
28
32
  email:
29
- - kgo@grant-olson.net
33
+ - smarx@spredfast.com
30
34
  executables: []
31
35
  extensions: []
32
36
  extra_rdoc_files: []
33
37
  files:
34
38
  - LICENSE
35
39
  - ./lib/stackdriver.rb
36
- homepage: https://github.com/grant-olson/stackdriver-ruby
40
+ homepage: https://github.com/sammarx/stackdriver-ruby
37
41
  licenses:
38
42
  - BSD 3 Clause
39
- metadata: {}
40
43
  post_install_message:
41
44
  rdoc_options: []
42
45
  require_paths:
43
46
  - lib
44
47
  required_ruby_version: !ruby/object:Gem::Requirement
48
+ none: false
45
49
  requirements:
46
- - - '>='
50
+ - - ! '>='
47
51
  - !ruby/object:Gem::Version
48
52
  version: '0'
49
53
  required_rubygems_version: !ruby/object:Gem::Requirement
54
+ none: false
50
55
  requirements:
51
- - - '>='
56
+ - - ! '>='
52
57
  - !ruby/object:Gem::Version
53
58
  version: '0'
54
59
  requirements: []
55
60
  rubyforge_project:
56
- rubygems_version: 2.0.6
61
+ rubygems_version: 1.8.25
57
62
  signing_key:
58
- specification_version: 4
59
- summary: Send StackDriver custom metrics
63
+ specification_version: 3
64
+ summary: StackDriver custom metrics gem
60
65
  test_files: []
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 45cccb2aaa57cee3afdbed410e598586906b0301
4
- data.tar.gz: 8476945867c544898327da3b42b6afcae4d39b90
5
- SHA512:
6
- metadata.gz: 9bb5743ab4d515f2bd4d7ae8539bb9fffff3a091258a49a5614dafeb396b66095885bfbfab4065675a78785238e7ea82f95448f6910624803d6fe14ead6ecf78
7
- data.tar.gz: 5007e74fbc395038bb504e83350a1b452ce2d2abc446cec62f35c8ae344af8b55f16569c3932eb56e6cd15157f84a7ad3afbe515e783f08587069be13f3c579b
@@ -1,11 +0,0 @@
1
- -----BEGIN PGP SIGNATURE-----
2
- Version: GnuPG v1.4.12 (GNU/Linux)
3
-
4
- iQEcBAABAgAGBQJSi/dWAAoJEP5F5V2hilTWHgEH/j5D4+0Lu/aglJbnYljwabXV
5
- g2/iCJnlgP6uecgZ/ZOnuZ9b8CcE4B9wK+XsHbpqJVO0UiX6KRAJ9aYVvH56JvVL
6
- M6QwPIngUKR8HIkaJ4ODs8Wy0dh3Ussetjnk8OtemArueuq4naOlNogQrcdpm0Gt
7
- HR5GYMt9NGY8HsaBA6A7yOqHdG5z+21m9Xvz3+ECt2zvKzL+49yOeOxUqG5G1H8/
8
- VQPCAtUWVLLI/sy+wsLAkMppFcX3bJ5RHPhn/DDGlQjN2emfuKrdpSLGKHuhtAzr
9
- wbRtnVoNe/ZQDDQEaeLixPHAfKqrWbOOyrhw2DjLINUApnYRgpepyIjUU+FqmIk=
10
- =pNkb
11
- -----END PGP SIGNATURE-----
data.tar.gz.asc DELETED
@@ -1,11 +0,0 @@
1
- -----BEGIN PGP SIGNATURE-----
2
- Version: GnuPG v1.4.12 (GNU/Linux)
3
-
4
- iQEcBAABAgAGBQJSi/dTAAoJEP5F5V2hilTWsOUIALaRdak6Ouh5Hks6m1/H9Du9
5
- KljVXqXKwNwChG+7G8iEjF+z+XSTYcc8s7NoGOpdv61ydCHVJb9LNNmA9hshJFNE
6
- Jko4+Iroe/bI6Vd1nq8sudWSslGx1LrPaJD4emCmLn0XuuUX1hh7VAo+500afy2D
7
- 5Qbc9ocpTe3q9f/b4/++7g1mTL+IlnSR+bCKwpfb5thNfDhZgf4PVVsf5cCs4qDg
8
- 3bsp3Mx8LYTozo4t4cjEotzmQND7/ROpsY/VM6HZAq2JAAiM7Y77OGg0NKzf2ITN
9
- Ofq5xOZxfwY1R87k/NXvDN3GJ85HMm21lR0/G5cPNKy8ok/y6MA0zCGoMzhGnYY=
10
- =oyQi
11
- -----END PGP SIGNATURE-----
metadata.gz.asc DELETED
@@ -1,11 +0,0 @@
1
- -----BEGIN PGP SIGNATURE-----
2
- Version: GnuPG v1.4.12 (GNU/Linux)
3
-
4
- iQEcBAABAgAGBQJSi/dPAAoJEP5F5V2hilTWrkwIAJPzJ3EGd1++cCdO/Z+G+CKK
5
- OY1RmA6sP4x8nD+XFQxdPASHHXN9Qto6/dtQTnD5nStJxiGF9mh7f+K2vu/3Vq2u
6
- ugqlA/jE0WkRzgQGZF6jGUyzjfOkGl4CTuFoNV2a/D+s86i4JOw74tt1pLs42Fvf
7
- AMUYN1F//Dlqg1psDUPMW8A/QX1T+eb8RbTTUQSw6NTanUuLlD1YlJ39iWDI+aMz
8
- omc1y6EJzmBtjBMY+PcLWqJnM/tRpsBJODJhbK7gx2j4X3fbwiOX7ZhDoy4CJyka
9
- VFwyUjvgNc7F4YzZwyDD4RD6pSxevJIp54yg1EyQmpejXg4y5ulGLLHbit8adu0=
10
- =26D/
11
- -----END PGP SIGNATURE-----