Class: Fluent::Plugin::SentryOutput
- Inherits:
-
Output
- Object
- Output
- Fluent::Plugin::SentryOutput
- Defined in:
- lib/fluent/plugin/out_sentry.rb
Instance Method Summary collapse
- #create_sentry_event_ingestion_url ⇒ Object
- #send_to_sentry(record, time) ⇒ Object
- #write(chunk) ⇒ Object
Instance Method Details
#create_sentry_event_ingestion_url ⇒ Object
147 148 149 |
# File 'lib/fluent/plugin/out_sentry.rb', line 147 def create_sentry_event_ingestion_url "#{@ingest_url}/api/#{@project_id}/store/?sentry_key=#{@auth_token}&sentry_version=7" end |
#send_to_sentry(record, time) ⇒ Object
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/fluent/plugin/out_sentry.rb', line 151 def send_to_sentry(record, time) event = SentryMessageFormat.new( record['timestamp'] || Time.at(time).to_i || Time.now.to_i, SecureRandom.hex(16), record['component_name'] || nil, record['environment'] || nil, record['commitId'] || nil, record['tags'] || nil, record['request'] || nil, record['exception'] || nil, record['platform'] || 'node', record['transaction'] || nil, record['oTelTraceId'] || 'ukw-ukw-1', record['user'] || {} ) url = create_sentry_event_ingestion_url request_payload = event.to_json log.debug 'Sending payload - ', request_payload, ' to - ', url Net::HTTP.post(URI(url), request_payload) end |
#write(chunk) ⇒ Object
136 137 138 139 140 141 142 143 144 145 |
# File 'lib/fluent/plugin/out_sentry.rb', line 136 def write(chunk) chunk.each do |time, record| log.debug time, record begin send_to_sentry(record, time) rescue => e log.error 'Unable to send event to Sentry, Err class - ', e.class, ', error message - ', e., ', error backtrace - ', e.backtrace end end end |