Class: Fluent::AirbrakePythonOutput
- Inherits:
-
Output
- Object
- Output
- Fluent::AirbrakePythonOutput
- Defined in:
- lib/fluent/plugin/out_airbrake_python.rb
Defined Under Namespace
Classes: Notice
Constant Summary collapse
- PY_LOGLEVEL_MAP =
{ 'CRITICAL' => 50, 'FATAL' => 50, 'ERROR' => 40, 'WARNING' => 30, 'WARN' => 30, 'INFO' => 20, 'DEBUG' => 10, 'NOTSET' => 0 }
Instance Method Summary collapse
- #build_action_name_py(record) ⇒ Object
- #build_cgi_data_dump(record) ⇒ Object
- #build_component_name_py(record) ⇒ Object
- #build_message_py(record) ⇒ Object
- #build_notice(tag, time, record) ⇒ Object
- #build_parameters_dump(record) ⇒ Object
- #build_session_dump(record) ⇒ Object
- #configure(conf) ⇒ Object
- #emit(tag, es, chain) ⇒ Object
- #notice_from_py_record(aconf, tag, record) ⇒ Object
- #notification_needed(tag, time, record) ⇒ Object
Instance Method Details
#build_action_name_py(record) ⇒ Object
119 120 121 |
# File 'lib/fluent/plugin/out_airbrake_python.rb', line 119 def build_action_name_py(record) record['sys_funcname'] end |
#build_cgi_data_dump(record) ⇒ Object
131 132 133 134 135 136 137 |
# File 'lib/fluent/plugin/out_airbrake_python.rb', line 131 def build_cgi_data_dump(record) if @cgi_data_dump_key record[@cgi_data_dump_key] else nil end end |
#build_component_name_py(record) ⇒ Object
115 116 117 |
# File 'lib/fluent/plugin/out_airbrake_python.rb', line 115 def build_component_name_py(record) record['sys_name'] end |
#build_message_py(record) ⇒ Object
123 124 125 126 127 128 129 |
# File 'lib/fluent/plugin/out_airbrake_python.rb', line 123 def (record) if record['message'] record['message'].sub(@message_regexp, @message_template) else nil end end |
#build_notice(tag, time, record) ⇒ Object
186 187 188 189 190 |
# File 'lib/fluent/plugin/out_airbrake_python.rb', line 186 def build_notice(tag, time, record) if notification_needed(tag, time, record) notice_from_py_record(@aconf, tag, record) end end |
#build_parameters_dump(record) ⇒ Object
139 140 141 142 143 144 145 |
# File 'lib/fluent/plugin/out_airbrake_python.rb', line 139 def build_parameters_dump(record) if @parameters_dump_key record[@parameters_dump_key] else nil end end |
#build_session_dump(record) ⇒ Object
147 148 149 150 151 152 153 |
# File 'lib/fluent/plugin/out_airbrake_python.rb', line 147 def build_session_dump(record) if @session_dump_key record[@session_dump_key] else nil end end |
#configure(conf) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/fluent/plugin/out_airbrake_python.rb', line 78 def configure(conf) super aconf = Airbrake::Configuration.new aconf.host = @host aconf.port = @port ? @port: (@secure ? 443: 80) aconf.proxy_host = @proxy_host aconf.proxy_port = @proxy_port aconf.proxy_user = @proxy_user aconf.proxy_pass = @proxy_pass aconf.param_filters = @param_filters.split(/\s+/) if @param_filters aconf.development_environments = @development_environments.split(/\s+/) if @development_environments aconf.development_lookup = @development_lookup aconf.environment_name = @environment_name aconf.project_root = @project_root aconf.notifier_name = @notifier_name if @notifier_name aconf.notifier_version = @notifier_version if @notifier_version aconf.notifier_url = @notifier_url if @notifier_url aconf.user_information = @user_information if @user_information aconf.framework = @framework if @framework aconf.secure = @secure aconf.use_system_ssl_cert_chain = @use_system_ssl_cert_chain aconf.http_open_timeout = @http_open_timeout if @http_open_timeout aconf.http_read_timeout = @http_read_timeout if @http_read_timeout aconf.project_id = @project_id aconf.api_key = @api_key @aconf = aconf @sender = Airbrake::Sender.new(aconf) @message_regexp = Regexp.new(@message_regexp, Regexp::MULTILINE) @loglevel = Integer(@loglevel) rescue PY_LOGLEVEL_MAP[@loglevel] end |
#emit(tag, es, chain) ⇒ Object
192 193 194 195 196 197 198 |
# File 'lib/fluent/plugin/out_airbrake_python.rb', line 192 def emit(tag, es, chain) es.each do |time, record| notice = build_notice(tag, time, record) @sender.send_to_airbrake(notice) if notice end chain.next end |
#notice_from_py_record(aconf, tag, record) ⇒ Object
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
# File 'lib/fluent/plugin/out_airbrake_python.rb', line 155 def notice_from_py_record(aconf, tag, record) exc_info_rec = record['sys_exc_info'] return nil unless exc_info_rec error_class = nil backtrace = nil if exc_info_rec error_class = exc_info_rec['type'] backtrace = Airbrake::Backtrace.new( exc_info_rec['traceback'].map { |f| Airbrake::Backtrace::Line.new(f[0], f[1], f[2]) } ) end Notice.new( aconf.merge( :error_class => error_class, :backtrace => backtrace, :error_message => (record), :component => build_component_name_py(record), :action => build_action_name_py(record), :hostname => record['sys_host'], :project_id => aconf[:project_id] || tag, :cgi_data => build_cgi_data_dump(record) || {}, :session_data => build_session_dump(record) || {}, :parameters => build_parameters_dump(record) || {}, ) ) end |
#notification_needed(tag, time, record) ⇒ Object
111 112 113 |
# File 'lib/fluent/plugin/out_airbrake_python.rb', line 111 def notification_needed(tag, time, record) record['sys_levelno'] ? record['sys_levelno'] >= @loglevel: false end |