reevoo/sapience-rb

View on GitHub
bin/profile

Summary

Maintainability
Test Coverage
#!/usr/bin/env ruby
# frozen_string_literal: true
require "bundler/setup"
require "ruby-prof"
require "sapience"
require "pry"

FILTERED_METHODS = [
  /Integer#times/,
  /Kernel#(\w*)/,
  /NilClass#(\w*)/,
].freeze

# puts "Starting RubyProf"
# RubyProf.start

puts "Configuring Sapience"
dsn = "https://5630e2b96b364d448a68914f3ddb91ce:1d4a94c64a1f4fe39736046fc0261ebb@sentry.io/107100"
Sapience.configure do |config|
  config.log_executor = :immediate_executor
  config.default_level = :debug
  config.backtrace_level = :debug
  config.app_name = "sapience"
  config.appenders << [
    { stream: { io: STDOUT, level: :debug, formatter: :color } },
    { sentry: { level: :error, dsn: dsn } },
  ]
end

logger = Sapience["Profile"]
puts "Logging 10 000 infos"
10_000.times do
  logger.info("something", oh: "my")
end

puts "Logging 1000 errors"
100.times do
  Sapience.test_exception
end

# puts "Stopping RubyProf"
# result = RubyProf.stop
# result.eliminate_methods!(FILTERED_METHODS)
# printer = RubyProf::MultiPrinter.new(result)
# puts "Printing RubyProf Results"
# printer.print(path: "tmp", profile: "profile")