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.
- checksums.yaml +4 -4
- data/lib/stackdriver_simple.rb +16 -9
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02b2c2aa0a26fbdd060e67106ee5dbc514ec3b7aa6d24bfac9e06f9a16d53b24
|
4
|
+
data.tar.gz: ad44b7126632783bec5975c07028cdf08a228986a6a9ccaa186539138d001c7b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d330cf39a6e75fc26b9125cfd42f97095dba7f2ce038736bd82548887aebf46e59d117c89b0e58486b56f4d7ef22fae2a9bab491bd65627a8da848a528840e1
|
7
|
+
data.tar.gz: 6921e3f679501fba82a13ac6b9fafa10b3d7ac72fea15a6cec7b8b8c2d874cf6c7e2b1586169aa9471a1c6fcc982ea029b52a530a8b1e5dadfab5583c28baf18
|
data/lib/stackdriver_simple.rb
CHANGED
@@ -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
|
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
|
-
|
22
|
-
client
|
23
|
-
|
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
|
-
|
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.
|
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
|