fluent-plugin-raygun 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: edc24bda615d05c224793d1baa813dc422a64a98
4
- data.tar.gz: d741af36f438c3049e7f944e9da92889877b9434
3
+ metadata.gz: 2098ef0c94ef25075639408963c046c61a8038be
4
+ data.tar.gz: 6345b818ee5f787b7ec70d85e8fb2f426947287d
5
5
  SHA512:
6
- metadata.gz: c00437615db8bb7d2622bef193d772f0aff546e316f8ee471e79d4731e2cc1b563ade8e5ebc8c643e5def46159ce251aa3c96907ed499acbb5f199386cc3df15
7
- data.tar.gz: 92766065e66a203c195986564b49bf6e889e0d3c702c21c6f80a7360d97af4da2bff034efb405829a75715178a8a5ea10ecf21625a93bf679606a8b247dd6445
6
+ metadata.gz: d38e46305094211b9a0e7162517370925ad050cd6ab1af633305b2be91a41ca07399f153e84b809ba8531c9d7c41d1fb63309832b18a56f41fb0221ef19782b5
7
+ data.tar.gz: daf3bc2a488c4ae69d9739b56f1ba9e4db80535b7746754845552dd8baa61e7322d166fcb03ff548d8a05dec9009d8c28db67ce40246a19bea082364b8145792
data/README.md CHANGED
@@ -4,7 +4,7 @@ fluent-plugin-raygun is a fluentd output plugin that sends aggregated errors/exc
4
4
 
5
5
  ## Copyright
6
6
 
7
- Copyright © 2018 - John-Daniel Trask ([@traskjd](https://twitter.com/traskjd))
7
+ Copyright © 2018 - Raygun ([@raygunio](https://twitter.com/raygunio))
8
8
 
9
9
  ## License
10
10
 
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "fluent-plugin-raygun"
7
- spec.version = "0.0.1"
7
+ spec.version = "0.0.2"
8
8
  spec.authors = ["Taylor Lodge"]
9
9
  spec.email = ["taylor@raygun.io"]
10
10
  spec.summary = %q{Fluentd output plugin that sends aggregated errors/exception events to Raygun. Raygun is a error logging and aggregation platform.}
@@ -3,16 +3,17 @@ class Fluent::RaygunOutput < Fluent::BufferedOutput
3
3
 
4
4
  include Fluent::HandleTagNameMixin
5
5
 
6
- LOG_LEVEL = %w(fatal error warning info debug)
7
- EVENT_KEYS = %w(message timestamp time_spent level logger culprit server_name release tags)
8
- DEFAULT_HOSTNAME_COMMAND = 'hostname'
6
+ LOG_LEVEL = %w[fatal error warning info debug].freeze
7
+ EVENT_KEYS = %w[message timestamp time_spent level logger culprit server_name release tags].freeze
8
+ DEFAULT_HOSTNAME_COMMAND = 'hostname'.freeze
9
9
 
10
- config_param :default_level, :string, :default => 'error'
11
- config_param :default_logger, :string, :default => 'fluentd'
12
- config_param :endpoint_url, :string, :default => 'https://api.raygun.com'
10
+ config_param :default_level, :string, default: 'error'
11
+ config_param :default_logger, :string, default: 'fluentd'
12
+ config_param :endpoint_url, :string, default: 'https://api.raygun.com'
13
13
  config_param :api_key, :string
14
- config_param :flush_interval, :time, :default => 0
15
- config_param :hostname_command, :string, :default => 'hostname'
14
+ config_param :flush_interval, :time, default: 0
15
+ config_param :hostname_command, :string, default: 'hostname'
16
+ config_param :record_already_formatted, :bool, default: false
16
17
 
17
18
  def initialize
18
19
  require 'time'
@@ -48,44 +49,51 @@ class Fluent::RaygunOutput < Fluent::BufferedOutput
48
49
  @http.idle_timeout = 10
49
50
  @http.socket_options << [Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, 1]
50
51
 
51
- log.debug "Started Raygun fluent shipper.."
52
+ log.debug 'Started Raygun fluent shipper..'
52
53
  end
53
54
 
54
55
  def format(tag, time, record)
55
56
  [tag, time, record].to_msgpack
56
57
  end
57
58
 
58
- def shutdown
59
- super
60
- end
61
-
62
59
  def write(chunk)
63
60
  chunk.msgpack_each do |tag, time, record|
64
61
  begin
65
62
  notify_raygun(tag, time, record)
66
- rescue => e
67
- $log.error("Raygun Error:", :error_class => e.class, :error => e.message)
63
+ rescue StandardError => e
64
+ $log.error('Raygun Error:', error_class: e.class, error: e.message)
68
65
  end
69
66
  end
70
67
  end
71
68
 
72
69
  def notify_raygun(tag, time, record)
73
- payload = {
74
- occurredOn: Time.at(time).utc.iso8601,
75
- details: {
76
- machineName: @hostname,
77
- error: {
78
- message: record['messages']
79
- },
80
- tags: [tag],
81
- }
82
- }
70
+ payload =
71
+ if @record_already_formatted
72
+ # Setting @record_already_formatted = true, means you
73
+ # are already happy with the formatting of 'record'
74
+ record
75
+ else
76
+ default_payload_format(tag, time, record)
77
+ end
83
78
 
84
79
  post = Net::HTTP::Post.new(
85
- "#{@endpoint_url}/entries?apikey=#{URI::encode(@api_key)}",
80
+ "#{@endpoint_url}/entries?apikey=#{URI.encode(@api_key)}"
86
81
  )
87
82
  post.body = JSON.generate(payload)
88
83
 
89
- response = @http.request(@uri, post)
84
+ @http.request(@uri, post)
85
+ end
86
+
87
+ def default_payload_format(tag, time, record)
88
+ {
89
+ occurredOn: Time.at(time).utc.iso8601,
90
+ details: {
91
+ machineName: @hostname,
92
+ error: {
93
+ message: record['messages']
94
+ },
95
+ tags: [tag]
96
+ }
97
+ }
90
98
  end
91
99
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-raygun
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taylor Lodge
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-10 00:00:00.000000000 Z
11
+ date: 2018-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler