stackdriver_simple 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/stackdriver_simple.rb +16 -9
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8a37bc4258e49a7b77212919f1ab0c25e336bf2958ce271ddbea063d3e04141c
4
- data.tar.gz: 3664cbdae55a36ce54481685646a498c31be81d2918a0fbc4a64963cd49df0ed
3
+ metadata.gz: 02b2c2aa0a26fbdd060e67106ee5dbc514ec3b7aa6d24bfac9e06f9a16d53b24
4
+ data.tar.gz: ad44b7126632783bec5975c07028cdf08a228986a6a9ccaa186539138d001c7b
5
5
  SHA512:
6
- metadata.gz: 45d77dbe4f5df8a918ff85abe8f14d23517f69609b38a41b73d2b4c78c3b1d39ee5aef14d9b0bd8fec03b39333cd1e2120f742e4a236f69f600e53e7df62c7fc
7
- data.tar.gz: 2e00019c756160f4e93e93fe82ebe0d86118ef09e6f8bcae4f91aaa2cd673796e0809858d10ea7c1dd128c6b023b466857cbcf175b64acaf0b5753b5486abca7
6
+ metadata.gz: 0d330cf39a6e75fc26b9125cfd42f97095dba7f2ce038736bd82548887aebf46e59d117c89b0e58486b56f4d7ef22fae2a9bab491bd65627a8da848a528840e1
7
+ data.tar.gz: 6921e3f679501fba82a13ac6b9fafa10b3d7ac72fea15a6cec7b8b8c2d874cf6c7e2b1586169aa9471a1c6fcc982ea029b52a530a8b1e5dadfab5583c28baf18
@@ -10,7 +10,7 @@ class StackdriverSimple
10
10
  raise ArgumentError if @google_cloud_project.include?(" ")
11
11
  end
12
12
 
13
- # This assumes the following two ENV vars are set:
13
+ # This assumes the following ENV var is set:
14
14
  #
15
15
  # * GOOGLE_APPLICATION_CREDENTIALS=<path-to-credentials>
16
16
  def submit_gauge(name, value)
@@ -18,24 +18,31 @@ class StackdriverSimple
18
18
  raise ArgumentError, "name cannot include /" if name.to_s.include?("/")
19
19
  raise ArgumentError, "value cannot be nil" if value.nil?
20
20
 
21
- # This might have optional arguments for providing the project and credentials?
22
- client = Google::Cloud::Monitoring::Metric.new
23
- project_name = Google::Cloud::Monitoring::V3::MetricServiceClient.project_path(@google_cloud_project)
21
+ client = Google::Cloud::Monitoring.metric_service #do |config|
22
+ # The client can be initialised with a block to explicitly provide credentials. This
23
+ # gem is already published with the assumption that credentials will be loaded automatically
24
+ # based on the GOOGLE_APPLICATION_CREDENTIALS env var, and I don't have the energy to change
25
+ # that behaviour for now.
26
+ # client = Google::Cloud::Monitoring.metric_service do |config|
27
+ # config.credentials = "/path/to/credentials.json"
28
+ #end
24
29
 
25
- series = Google::Monitoring::V3::TimeSeries.new
30
+ project_name = Google::Cloud::Monitoring::V3::MetricService::Paths.project_path(project: @google_cloud_project)
31
+
32
+ series = Google::Cloud::Monitoring::V3::TimeSeries.new
26
33
  metric = Google::Api::Metric.new type: "custom.googleapis.com/#{name}"
27
34
  series.metric = metric
28
35
 
29
36
  resource = Google::Api::MonitoredResource.new type: "global"
30
37
  series.resource = resource
31
38
 
32
- point = Google::Monitoring::V3::Point.new
33
- point.value = Google::Monitoring::V3::TypedValue.new double_value: value
39
+ point = Google::Cloud::Monitoring::V3::Point.new
40
+ point.value = Google::Cloud::Monitoring::V3::TypedValue.new double_value: value
34
41
  now = Time.now
35
42
  end_time = Google::Protobuf::Timestamp.new seconds: now.to_i, nanos: now.usec
36
- point.interval = Google::Monitoring::V3::TimeInterval.new end_time: end_time
43
+ point.interval = Google::Cloud::Monitoring::V3::TimeInterval.new end_time: end_time
37
44
  series.points << point
38
45
 
39
- client.create_time_series project_name, [series]
46
+ client.create_time_series name: project_name, time_series: [series]
40
47
  end
41
48
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stackdriver_simple
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Healy
@@ -28,14 +28,14 @@ dependencies:
28
28
  name: google-cloud-monitoring
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "<"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "<"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.0'
41
41
  description: An easy way to submit metrics to stackdriver