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
127 128 129 130 131 132 133 |
# File 'lib/fluent/plugin/out_airbrake_python.rb', line 127 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 |
# File 'lib/fluent/plugin/out_airbrake_python.rb', line 123 def (record) record['message'].sub(, ) end |
#build_notice(tag, time, record) ⇒ Object
182 183 184 185 186 |
# File 'lib/fluent/plugin/out_airbrake_python.rb', line 182 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
135 136 137 138 139 140 141 |
# File 'lib/fluent/plugin/out_airbrake_python.rb', line 135 def build_parameters_dump(record) if @parameters_dump_key record[@parameters_dump_key] else nil end end |
#build_session_dump(record) ⇒ Object
143 144 145 146 147 148 149 |
# File 'lib/fluent/plugin/out_airbrake_python.rb', line 143 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) = Regexp.new(, Regexp::MULTILINE) @loglevel = Integer(@loglevel) rescue PY_LOGLEVEL_MAP[@loglevel] end |
#emit(tag, es, chain) ⇒ Object
188 189 190 191 192 193 |
# File 'lib/fluent/plugin/out_airbrake_python.rb', line 188 def emit(tag, es, chain) es.each do |time, record| notice = build_notice(tag, time, record) @sender.send_to_airbrake(notice) if notice end end |
#notice_from_py_record(aconf, tag, record) ⇒ Object
151 152 153 154 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 |
# File 'lib/fluent/plugin/out_airbrake_python.rb', line 151 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'] >= @loglevel end |