Skip to content

Commit 65d45df

Browse files
committed
Merge pull request #3 from blackopseng3/master
Bugfix and improvements
2 parents 76f3735 + 18d2be9 commit 65d45df

7 files changed

Lines changed: 15 additions & 13 deletions

File tree

lib/stackify/authorization/authorizable.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ def authorized!
3030

3131
def successfull_authorisation response
3232
Stackify::EnvDetails.instance.update_auth_info JSON.parse(response.body)
33-
Stackify.internal_log :info, 'Authorisation is finished successfully.'
33+
Stackify.internal_log :info, 'Authorization is finished successfully.'
3434
end
3535

3636
def unsuccessfull_authorisation response, caller
37-
Stackify.log_internal_error "Authorisation finally failed: #{response_string(response)}"
37+
Stackify.log_internal_error "Authorization finally failed: #{response_string(response)}"
3838
Stackify.shutdown_all caller unless @@authorized
3939
end
4040

lib/stackify/authorization/authorization_client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def auth_task attempts
2222
end
2323
}
2424
Stackify::ScheduleTask.new properties do
25-
Stackify.internal_log :debug, 'AthorizationClient: trying to athorize...'
25+
Stackify.internal_log :debug, 'AthorizationClient: trying to authorize...'
2626
send_request BASE_URI, Stackify::EnvDetails.instance.auth_info.to_json
2727
end
2828
end

lib/stackify/logger_client.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ def initialize
55
@@errors_governor = Stackify::ErrorsGovernor.new
66
end
77

8-
def log level, msg
8+
def log level, msg, call_trace
99
Stackify::Utils.do_only_if_authorized_and_mode_is_on Stackify::MODES[:logging] do
1010
if acceptable? level, msg && Stackify.working?
1111
worker = Stackify::AddMsgWorker.new
12-
task = log_message_task level, msg
12+
task = log_message_task level, msg, call_trace
1313
worker.async_perform ScheduleDelay.new, task
1414
end
1515
end
@@ -56,9 +56,12 @@ def is_appropriate_env?
5656
Stackify.configuration.env.downcase.to_sym == Stackify::EnvDetails.instance.auth_info['ConfiguredEnvironmentName'].downcase.to_sym
5757
end
5858

59-
def log_message_task level, msg
59+
def log_message_task level, msg, call_trace
6060
Stackify::ScheduleTask.new ({limit: 1}) do
61-
Stackify.msgs_queue << Stackify::MsgObject.new(level, msg, caller[0]).to_h
61+
e = Exception.new(msg)
62+
e.set_backtrace(call_trace)
63+
ex = StackifiedError.new(e, binding())
64+
Stackify.msgs_queue << Stackify::MsgObject.new(level, ex.message, caller[0], ex).to_h
6265
end
6366
end
6467

lib/stackify/logger_proxy.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def initialize logger
88
LoggerProxy.class_eval do
99
define_method level.to_sym do |*args , &block|
1010
msg = message(args, block)
11-
Stackify.logger_client.log(level.downcase, msg)
11+
Stackify.logger_client.log(level.downcase, msg, caller)
1212
@logger.send(level.to_sym, args, &block)
1313
end
1414
end

lib/stackify/metrics/metric_aggregate.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ def initialize aggr_metric
3838

3939
def to_h
4040
{
41-
'Count' => @count,
4241
'MetricType' => @metric_type,
4342
'MetricID' => @metric_id,
4443
'Name' => @name,

lib/stackify/metrics/metrics_client.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def upload_aggregates aggr_metrics
203203
mon_info = @monitor_ids[metric.name_key]
204204
else
205205
req = @metrics_sender.monitor_info metric
206-
if req.try(:code) == '200'
206+
if req.try(:status) == 200
207207
mon_info = JSON.parse req.body
208208
if !mon_info.nil? && !mon_info['MonitorID'].nil? && mon_info['MonitorID'] > 0
209209
@monitor_ids[metric.name_key] = mon_info
@@ -229,7 +229,7 @@ def upload_aggregates aggr_metrics
229229
#get identified once
230230
aggr_metrics_for_upload = aggr_metrics.select { |_key, aggr_metric| !aggr_metric.monitor_id.nil? }
231231
response = @metrics_sender.upload_metrics aggr_metrics_for_upload
232-
Stackify.internal_log :info, 'Metrics are uploaded successfully' if response.try(:code) == '200'
232+
Stackify.internal_log :info, 'Metrics are uploaded successfully' if response.try(:status) == 200
233233
all_success
234234
end
235235
end

lib/stackify/metrics/metrics_sender.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def monitor_info aggr_metric
77
if Stackify.authorized?
88
send_request GET_METRIC_INFO_URI, GetMetricRequest.new(aggr_metric).to_h.to_json
99
else
10-
Stackify.log_internal_error "Getting of monitor_info is failed because of authorisation failure"
10+
Stackify.log_internal_error "Getting of monitor_info is failed because of authorization failure"
1111
end
1212
end
1313

@@ -22,7 +22,7 @@ def upload_metrics aggr_metrics
2222
end
2323
send_request SUBMIT_METRIS_URI, records.to_json
2424
else
25-
Stackify.log_internal_error "Uploading of metrics is failed because of authorisation failure"
25+
Stackify.log_internal_error "Uploading of metrics is failed because of authorization failure"
2626
end
2727
end
2828
end

0 commit comments

Comments
 (0)