Last active
August 18, 2020 07:11
-
-
Save FlowerWrong/66e3fd61314e95d5ca0a90c9e6929631 to your computer and use it in GitHub Desktop.
write elastic ruby agent apm to file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
class FileAdapter | |
include ElasticAPM::Logging | |
def initialize(config) | |
@config = config | |
@mutex = Mutex.new | |
@logger_file = File.new('log/apm.log', 'a+') | |
end | |
def write(str) | |
return false if @config.disable_send | |
begin | |
@mutex.synchronize do | |
@logger_file.puts(str) | |
end | |
rescue IOError => e | |
error('FileAdapter error: %s', e.inspect) | |
rescue Errno::EPIPE => e | |
error('FileAdapter error: %s', e.inspect) | |
rescue Exception => e | |
error('FileAdapter error: %s', e.inspect) | |
end | |
end | |
def flush(reason = :force) | |
@mutex.synchronize do | |
error('FileAdapter flush: %s', reason) | |
@logger_file&.close | |
end | |
end | |
end |
Author
FlowerWrong
commented
Aug 18, 2020
create_table :metricsets do |t|
t.jsonb :samples
t.jsonb :transaction
t.jsonb :span
t.timestamps
end
create_table :spans, id: :string do |t|
t.string :transaction_id
t.string :parent_id
t.string :name
t.string :t # type
t.decimal :duration
t.jsonb :context
t.jsonb :stacktrace
t.string :trace_id
t.timestamps
end
create_table :transactions, id: :string do |t|
t.string :trace_id
t.string :parent_id
t.string :name
t.string :t # type
t.string :result
t.decimal :duration
t.boolean :sampled
t.jsonb :context
t.jsonb :span_count
t.timestamps
end
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment