appmonitor 0.0.15 → 0.0.17

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f6debb44002babbb29bde93485cbd0cad0a85f31
4
- data.tar.gz: 03221a29f484f97d17d82fb1ac94de839437fc57
3
+ metadata.gz: 0dd40358d6f66af203f178ea0015941d205fc45f
4
+ data.tar.gz: 9d5a8056b8643c47fda4a2faa4a7c6e817d0569d
5
5
  SHA512:
6
- metadata.gz: d7154004a16f786a5823accb95dab8e3f27e97777267623255176e7022e7ff818f0bd65e840caf066f413ef0b32a1085570b0bcb2c172252bb294af92e83b876
7
- data.tar.gz: ef493748f89fbfd480d33553755e2d2aaca05cd49651eb0f692ce40280acb9d8201d2be33e585e503f9fb2635360ab69daa576705faeca9d987b4895f335d711
6
+ metadata.gz: de08cf7955df61d62878eaf82cb45b9da2f7b3de52e3123267da896335cd12aa96beb3cc416ee061d7d2e23f4b19484764c0daa18c1039ec4c98a5b0008e5b94
7
+ data.tar.gz: f580182251cb784cd7fc87ff710a5d413d31f6a3df8748d65b93e0f6050e0bec97167b501d2c8982bfa6643d450692c7f6dc6d3bc50a57e4cf2a2360bf0fa8b7
@@ -19,7 +19,7 @@ module AppMonitor
19
19
  rake_called_name = options[:rake_command_line].split(":", 2)
20
20
  rake_namespace = rake_called_name.first
21
21
  {method: options[:rake_command_line], time: Time.now.to_i.to_s, message: exception.message.inspect, stack_trace:
22
- exception.backtrace.join("\n"), klass: rake_namespace, environment: Rails.env || ''}
22
+ exception.backtrace.join("\n"), klass: rake_namespace, environment: Rails.env || ''}
23
23
  end
24
24
 
25
25
  end
@@ -3,7 +3,6 @@ require 'net/http'
3
3
  require 'active_support/core_ext'
4
4
  require 'action_dispatch'
5
5
  require 'appmonitor/event_notification'
6
- require 'appmonitor/github_api'
7
6
 
8
7
  module AppMonitor
9
8
  class EventNotifier
@@ -14,14 +13,10 @@ module AppMonitor
14
13
  @app = app
15
14
  configure
16
15
  @config[:ignore_exceptions] ||= self.class.default_ignore_exceptions
17
- @github = GithubApi.new(token: @config[:github_oauth_token], repo: @config[:github_repo_url]) if @config[:github_oauth_token] && @config[:github_repo_url]
18
-
19
16
  end
20
17
 
21
18
  def configure(opts = {})
22
19
  @config = {
23
- github_oauth_token: '',
24
- github_repo_url: '',
25
20
  api_key: '',
26
21
  project_id: '',
27
22
  monitoring: {development: '', staging: '', production: ''}
@@ -67,21 +62,19 @@ module AppMonitor
67
62
  end
68
63
 
69
64
  def send_exception(exception)
70
- type = 'Error'
71
65
  unless ignored_exception(@config[:ignore_exceptions], exception)
72
66
  event = EventNotification.build_exception_hash(exception, @request)
73
- @event = event.merge(type: type)
74
- notify_on_event(type)
67
+ @event = event.to_json
68
+ notify_on_event("Error")
75
69
  end
76
70
  end
77
71
 
78
72
  def send_rake_event(exception, options = {})
79
- type = 'RakeError'
80
73
  configure
81
- unless (ignored_exception(@config[:ignore_exceptions], exception) || !@config[:monitoring]["#{Rails.env.to_s.downcase}"])
74
+ unless (ignored_exception(@config[:ignore_exceptions], exception) || !@config[:monitoring]["#{Rails.env.to_s.downcase}"])
82
75
  event = EventNotification.build_rake_event(exception, options)
83
- @event = event.merge(type: type)
84
- notify_on_event(type)
76
+ @event = event.to_json
77
+ notify_on_event("RakeError")
85
78
  end
86
79
  end
87
80
 
@@ -91,20 +84,6 @@ module AppMonitor
91
84
  end
92
85
 
93
86
  def notify_on_event(type)
94
- response = send_request(type)
95
- Rails.logger.debug ("Appmonitor: Event has been sent")
96
-
97
- unless response.kind_of? Net::HTTPSuccess
98
- Rails.logger.warn('Appmonitor WARNING: Something went wrong, please check your config')
99
- Rails.logger.warn("AppMonitor WARNING: Response ''#{response.code}: #{response.message}''")
100
- puts 'Appmonitor WARNING: Something went wrong, please check your config'
101
- puts "AppMonitor WARNING: Response #{response.inspect}"
102
- end
103
-
104
- send_to_github if @github
105
- end
106
-
107
- def send_request(type)
108
87
  uri = URI.parse(API_MESSAGE_URL)
109
88
  https = Net::HTTP.new(uri.host, uri.port)
110
89
  https.use_ssl = false
@@ -113,13 +92,19 @@ module AppMonitor
113
92
  'appm_projectId' => @config[:project_id],
114
93
  'appm_type' => type}
115
94
  )
116
- request.body = @event.to_json
117
- https.request(request)
118
95
 
119
- end
96
+ request.body = @event
97
+ response = https.request(request)
120
98
 
121
- def send_to_github
122
- @github.handle_event(@event)
99
+ Rails.logger.debug ("Appmonitor: Event has been sent")
100
+ puts 'Appmonitor: Event has been sent'
101
+
102
+ unless response.kind_of? Net::HTTPSuccess
103
+ Rails.logger.warn('Appmonitor WARNING: Something went wrong, please check your config')
104
+ Rails.logger.warn("AppMonitor WARNING: Response ''#{response.code}: #{response.message}''")
105
+ puts 'Appmonitor WARNING: Something went wrong, please check your config'
106
+ puts "AppMonitor WARNING: Response #{response.inspect}"
107
+ end
123
108
  end
124
109
 
125
110
  end
@@ -13,7 +13,7 @@ module AppMonitor
13
13
  def display_error_message_with_notifications(ex)
14
14
  display_error_message_without_notifications(ex)
15
15
  en = AppMonitor::EventNotifier.new(nil)
16
- en.send_rake_event(ex, :rake_command_line => reconstruct_command_line)
16
+ en.send_rake_event(ex,:rake_command_line => reconstruct_command_line)
17
17
  end
18
18
 
19
19
  def reconstruct_command_line
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appmonitor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Team Gappers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-03 00:00:00.000000000 Z
11
+ date: 2015-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -38,21 +38,7 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: octokit
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- description: AppMonitor agent for ruby language. We provide GIthub Integration - issues.
41
+ description: AppMonitor agent for ruby language
56
42
  email: gappers-tip-fiit@googlegroups.com
57
43
  executables: []
58
44
  extensions: []
@@ -61,8 +47,6 @@ files:
61
47
  - lib/appmonitor.rb
62
48
  - lib/appmonitor/event_notification.rb
63
49
  - lib/appmonitor/event_notifier.rb
64
- - lib/appmonitor/github/issue.rb
65
- - lib/appmonitor/github_api.rb
66
50
  - lib/appmonitor/rake_patch.rb
67
51
  homepage: http://rubygems.org/gems/appmonitor
68
52
  licenses:
@@ -89,3 +73,4 @@ signing_key:
89
73
  specification_version: 4
90
74
  summary: AppMonitor agent for ruby language
91
75
  test_files: []
76
+ has_rdoc:
@@ -1,58 +0,0 @@
1
- module AppMonitor
2
- module Github
3
- class Issue
4
-
5
- RUBY_OBJECT_REGEX = /\#\<.*\>/
6
-
7
- def initialize(event)
8
- @event=event
9
- end
10
-
11
- def title
12
- "#{@event[:klass]}/#{@event[:method]}: #{@event[:message]}"
13
- end
14
-
15
- def type
16
- @event[:type]
17
- end
18
-
19
- def error_request_details
20
- content = "**URL**: #{@event[:url]}\n"
21
- content << "**Parameters**: #{@event[:params]}\n"
22
- content << "**IP address**: #{@event[:ip_address]}\n"
23
- content << "**Session:** #{@event[:session]}\n"
24
- end
25
-
26
- def body
27
- content = "### First occurrence of this #{@event[:type]}\n"
28
- content << "**Action:** #{@event[:klass]}/#{@event[:method]}\n"
29
- content << "**Message**: #{@event[:message]}\n"
30
- content << "**Environment:** #{@event[:environment]}\n"
31
- content << "**Timestamp:** #{@event[:time]}\n"
32
- content << "**Human time:** #{Time.at(@event[:time].to_i).strftime("Occurred on %d/%m/%Y at %H:%M:%S")}\n"
33
- if type == 'Error'
34
- content << error_request_details
35
- end
36
- content << "**Stacktrace:** \n```ruby\n#{@event[:stack_trace]}\n```"
37
- end
38
-
39
- def additional_occurrence_comment
40
- content = "### Another occurrence of this #{@event[:type]}\n"
41
- content << "**Environment:** #{@event[:environment]}\n"
42
- content << "**Timestamp:** #{@event[:time]}\n"
43
- content << "**Human time:** #{Time.at(@event[:time].to_i).strftime("Occurred on %d/%m/%Y at %H:%M:%S")}\n"
44
- if type == 'Error'
45
- content << error_request_details
46
- end
47
- content
48
- end
49
-
50
- def self.compare_issues(existing, new)
51
- existing_title = existing.title.gsub(RUBY_OBJECT_REGEX, '')
52
- new_title = new.title.gsub(RUBY_OBJECT_REGEX, '')
53
- existing_title == new_title
54
- end
55
-
56
- end
57
- end
58
- end
@@ -1,54 +0,0 @@
1
- require 'octokit'
2
- require 'appmonitor/github/issue'
3
-
4
- module AppMonitor
5
- class GithubApi
6
- attr_accessor :client, :repo
7
-
8
- GITHUB_API_ISSUED_CLOSED_STATE = 'closed'
9
-
10
- def initialize(args)
11
- @client = Octokit::Client.new(:access_token => args[:token])
12
- @repo = args[:repo]
13
- end
14
-
15
- def issues
16
- @client.issues(@repo, state: 'all')
17
- end
18
-
19
- def handle_event(event)
20
- begin
21
- @issue = AppMonitor::Github::Issue.new(event)
22
- existing_issue = find_issue(issues)
23
- if existing_issue
24
- reopen_issue(existing_issue[:number])
25
- else
26
- create_issue
27
- end
28
- rescue Octokit::Unauthorized
29
- Rails.logger.warn('Appmonitor WARNING: Wrong Github credentials')
30
- puts ('Appmonitor WARNING: Wrong Github credentials')
31
- end
32
- end
33
-
34
- def find_issue(issues)
35
- issues.select { |x| AppMonitor::Github::Issue.compare_issues(x, @issue) }.first
36
- end
37
-
38
- def create_issue
39
-
40
- @client.create_issue(@repo, @issue.title, @issue.body, labels: ['bug', @issue.type])
41
-
42
- end
43
-
44
- def reopen_issue(number)
45
- @client.reopen_issue(@repo, number)
46
- add_comment_to_an_issue(number, @issue.additional_occurrence_comment)
47
- end
48
-
49
- def add_comment_to_an_issue(number, comment)
50
- @client.add_comment(@repo, number, comment)
51
- end
52
-
53
- end
54
- end