statscloud 1.0.7 → 1.0.8
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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/statscloud.rb +6 -6
- data/lib/statscloud/cluster_client.rb +0 -8
- data/lib/statscloud/helpers/logger_helper.rb +48 -3
- data/lib/statscloud/helpers/plugins_helper.rb +0 -1
- data/lib/statscloud/helpers/socketio_helper.rb +3 -3
- data/lib/statscloud/jobs/register_connection_job.rb +1 -1
- data/lib/statscloud/statscloud_client.rb +2 -4
- data/lib/statscloud/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ef41219d5c5e8f41a545baf7d6227891f8007f7eb29b08f70848a82bda775c9
|
4
|
+
data.tar.gz: dfe3ca26a35f7e103db7f04ebcbce4200d397bcecabea2599a62539cec02e391
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67baa18a0d5a7a590cce861918d2a693256e118548d92033ed80d98f0154d99d38467f2b014554d20ecfb866955826ce669ebab4ac93ee5cb5ae7e90e4408ac5
|
7
|
+
data.tar.gz: 8ca7bff390130ea5f43d4423590e45379d8c5d564b4fba2d258dacdb673c66df16fe2d83790e408def92055ce422d844bd42cc2842f22615f85b1258285fa798
|
data/Gemfile.lock
CHANGED
data/lib/statscloud.rb
CHANGED
@@ -22,7 +22,7 @@ module StatsCloud
|
|
22
22
|
def start(base_config = nil)
|
23
23
|
stats_cloud_instance.start(base_config)
|
24
24
|
rescue StandardError => error
|
25
|
-
|
25
|
+
log_error error
|
26
26
|
end
|
27
27
|
|
28
28
|
# Configures Statscloud environment.
|
@@ -31,7 +31,7 @@ module StatsCloud
|
|
31
31
|
def with_environment(env)
|
32
32
|
stats_cloud_instance.with_environment(env)
|
33
33
|
rescue StandardError => error
|
34
|
-
|
34
|
+
log_error error
|
35
35
|
end
|
36
36
|
|
37
37
|
# Configures Statscloud tags.
|
@@ -40,7 +40,7 @@ module StatsCloud
|
|
40
40
|
def with_tags(tags)
|
41
41
|
stats_cloud_instance.with_tags(tags)
|
42
42
|
rescue StandardError => error
|
43
|
-
|
43
|
+
log_error error
|
44
44
|
end
|
45
45
|
|
46
46
|
# Returns statscloud.io client aka Statsmeter client
|
@@ -51,7 +51,7 @@ module StatsCloud
|
|
51
51
|
def meter
|
52
52
|
stats_cloud_instance.meter
|
53
53
|
rescue StandardError => error
|
54
|
-
|
54
|
+
log_error error
|
55
55
|
end
|
56
56
|
|
57
57
|
# Records a single event.
|
@@ -88,7 +88,7 @@ module StatsCloud
|
|
88
88
|
def cluster_status
|
89
89
|
stats_cloud_instance.cluster_status
|
90
90
|
rescue StandardError => error
|
91
|
-
|
91
|
+
log_error error
|
92
92
|
end
|
93
93
|
|
94
94
|
# Stops statscloud.io service.
|
@@ -99,7 +99,7 @@ module StatsCloud
|
|
99
99
|
def stop
|
100
100
|
stats_cloud_instance.stop
|
101
101
|
rescue StandardError => error
|
102
|
-
|
102
|
+
log_error error
|
103
103
|
end
|
104
104
|
|
105
105
|
private
|
@@ -35,8 +35,6 @@ module StatsCloud
|
|
35
35
|
url = "#{host}/users/current/clusters/#{app}/#{environment}"
|
36
36
|
response = http_client.get(url, headers(token))
|
37
37
|
get_parsed_response(response)
|
38
|
-
rescue StandardError => error
|
39
|
-
logger.error error
|
40
38
|
end
|
41
39
|
|
42
40
|
# Schedules cluster to be (re)deployed.
|
@@ -54,8 +52,6 @@ module StatsCloud
|
|
54
52
|
body = body_hash_parameters(configuration)
|
55
53
|
response = http_client.put(url, body.to_json, headers(token))
|
56
54
|
get_parsed_response(response)
|
57
|
-
rescue StandardError => error
|
58
|
-
logger.error error
|
59
55
|
end
|
60
56
|
|
61
57
|
# Schedules cluster to be undeployed.
|
@@ -69,8 +65,6 @@ module StatsCloud
|
|
69
65
|
url = "#{host}/users/current/clusters/#{app}/#{environment}/undeploy"
|
70
66
|
response = http_client.post(url, nil, headers(token))
|
71
67
|
get_parsed_response(response)
|
72
|
-
rescue StandardError => error
|
73
|
-
logger.error error
|
74
68
|
end
|
75
69
|
|
76
70
|
# Register statscloud client connection.
|
@@ -85,8 +79,6 @@ module StatsCloud
|
|
85
79
|
body = { tags: tags }.to_json
|
86
80
|
response = http_client.post(url, body, headers(token))
|
87
81
|
get_parsed_response(response)
|
88
|
-
rescue StandardError => error
|
89
|
-
logger.error error
|
90
82
|
end
|
91
83
|
|
92
84
|
private
|
@@ -1,21 +1,66 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "fileutils"
|
4
|
+
require "active_support/core_ext/numeric/time"
|
4
5
|
|
5
6
|
module StatsCloud
|
6
7
|
# This helper works to help log errors and info about StatsCloud service work.
|
7
8
|
module LoggerHelper
|
8
|
-
# Log information about work to
|
9
|
+
# Log information about work to standard output
|
9
10
|
def logger
|
10
11
|
file_utils.mkdir_p "log"
|
11
|
-
@logger ||=
|
12
|
+
@logger ||= logger_service.new(File.join("log", "statscloud.log")).tap do |log|
|
12
13
|
log.progname = "StatsCloud"
|
13
14
|
end
|
14
15
|
end
|
15
16
|
|
17
|
+
# Logs information with 10 minutes interval
|
18
|
+
def log_info(info_message)
|
19
|
+
logged = log_with_interval(info_type, last_info_log_at, info_message)
|
20
|
+
update_last_info_at && log_stop_logging("information") if logged
|
21
|
+
true
|
22
|
+
end
|
23
|
+
|
24
|
+
# Logs errors with 10 minutes interval
|
25
|
+
def log_error(error_message)
|
26
|
+
logged = log_with_interval(error_type, last_error_log_at, error_message)
|
27
|
+
update_last_error_at && log_stop_logging("errors") if logged
|
28
|
+
false
|
29
|
+
end
|
30
|
+
|
16
31
|
private
|
17
32
|
|
18
|
-
|
33
|
+
attr_reader :last_error_log_at, :last_info_log_at
|
34
|
+
|
35
|
+
def log_with_interval(type, last_log_at, message)
|
36
|
+
logger.add(type, message) if can_log?(last_log_at)
|
37
|
+
end
|
38
|
+
|
39
|
+
def can_log?(last_log_at)
|
40
|
+
last_log_at.nil? || Time.now - last_log_at > 10.minutes
|
41
|
+
end
|
42
|
+
|
43
|
+
def log_stop_logging(message_type)
|
44
|
+
logger.info "Logging #{message_type} from #{self.class} will be stopped for 10 minutes."
|
45
|
+
end
|
46
|
+
|
47
|
+
def update_last_info_at
|
48
|
+
@last_info_log_at = Time.now
|
49
|
+
end
|
50
|
+
|
51
|
+
def update_last_error_at
|
52
|
+
@last_error_log_at = Time.now
|
53
|
+
end
|
54
|
+
|
55
|
+
def info_type
|
56
|
+
Logger::INFO
|
57
|
+
end
|
58
|
+
|
59
|
+
def error_type
|
60
|
+
Logger::ERROR
|
61
|
+
end
|
62
|
+
|
63
|
+
def logger_service
|
19
64
|
Logger
|
20
65
|
end
|
21
66
|
|
@@ -29,7 +29,7 @@ module StatsCloud
|
|
29
29
|
listen_events
|
30
30
|
listen_errors
|
31
31
|
rescue StandardError => error
|
32
|
-
|
32
|
+
log_error(error)
|
33
33
|
close
|
34
34
|
end
|
35
35
|
|
@@ -46,7 +46,7 @@ module StatsCloud
|
|
46
46
|
this = self
|
47
47
|
|
48
48
|
@client.on :disconnect do
|
49
|
-
this.
|
49
|
+
this.log_error("StatsCloud client disconnected from the StatsCloud server")
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
@@ -64,7 +64,7 @@ module StatsCloud
|
|
64
64
|
this = self
|
65
65
|
|
66
66
|
@client.on :error do |error|
|
67
|
-
this.
|
67
|
+
this.log_error error
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
@@ -160,7 +160,7 @@ module StatsCloud
|
|
160
160
|
@cluster = @cluster_client.get_cluster(@token, @app).body
|
161
161
|
@graphite_url = @cluster[:graphiteUrl]
|
162
162
|
check_cluster_status(@cluster)
|
163
|
-
|
163
|
+
log_info successful_message
|
164
164
|
end
|
165
165
|
|
166
166
|
def check_cluster_status(cluster)
|
@@ -173,7 +173,7 @@ module StatsCloud
|
|
173
173
|
end
|
174
174
|
|
175
175
|
def create_cluster_client
|
176
|
-
StatsCloud::ClusterClient.new(env)
|
176
|
+
StatsCloud::ClusterClient.new(env, @config["endpoint"])
|
177
177
|
end
|
178
178
|
|
179
179
|
def register_connection_job
|
@@ -183,8 +183,6 @@ module StatsCloud
|
|
183
183
|
def create_statsmeter_client(cluster, token, plugins, tags)
|
184
184
|
host = cluster[:statsmeterUrl]
|
185
185
|
StatsCloud::StatsmeterClient.new(host, token, plugins, tags)
|
186
|
-
rescue StandardError => e
|
187
|
-
logger.error e
|
188
186
|
end
|
189
187
|
end
|
190
188
|
end
|
data/lib/statscloud/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: statscloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roman Ovcharov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-12-
|
11
|
+
date: 2018-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|