fluent-plugin-raygun 0.0.1 → 0.0.2
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/README.md +1 -1
- data/fluent-plugin-raygun.gemspec +1 -1
- data/lib/fluent/plugin/out_raygun.rb +35 -27
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2098ef0c94ef25075639408963c046c61a8038be
|
4
|
+
data.tar.gz: 6345b818ee5f787b7ec70d85e8fb2f426947287d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 -
|
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.
|
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
|
7
|
-
EVENT_KEYS = %w
|
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, :
|
11
|
-
config_param :default_logger, :string, :
|
12
|
-
config_param :endpoint_url, :string, :
|
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, :
|
15
|
-
config_param :hostname_command, :string, :
|
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
|
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(
|
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
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
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
|
80
|
+
"#{@endpoint_url}/entries?apikey=#{URI.encode(@api_key)}"
|
86
81
|
)
|
87
82
|
post.body = JSON.generate(payload)
|
88
83
|
|
89
|
-
|
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.
|
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-
|
11
|
+
date: 2018-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|