This file contains hidden or 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
| require 'active_record/log_subscriber' | |
| class SlowQueryLog < ActiveSupport::LogSubscriber | |
| if Rails.configuration.respond_to?(:slow_query_log_threshold_in_ms) | |
| if @@threshold = Rails.configuration.slow_query_log_threshold_in_ms | |
| @@threshold = @@threshold.to_i == 0 ? nil : @@threshold.to_i | |
| end | |
| else | |
| @@threshold = nil |
This file contains hidden or 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
| require 'logger' | |
| Class.new do | |
| LOGGER = Logger.new(STDOUT) | |
| # Logger.new File.open('jmx.log', File::WRONLY | File::APPEND) | |
| def initialize; @done = nil end | |
| def start |
This file contains hidden or 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
| if JRUBY_VERSION < '1.7.19' | |
| require 'thread'; require 'java' | |
| org.jruby.RubyThreadGroup.field_reader :rubyThreadList | |
| ThreadGroup.class_eval do | |
| def list | |
| threads = [] | |
| list = to_java.rubyThreadList | |
| list.synchronized do # iterator must be sync-ed | |
| list.each { |t| threads << t if t } | |
| end |
This file contains hidden or 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
| # Copyright 2012-2013 Barry Allard <barry.allard@gmail.com> | |
| # All rights reserved. | |
| # | |
| # Redistribution and use in source and binary forms, with or without modification, | |
| # are permitted provided that the following conditions are met: | |
| # | |
| # 1. Redistributions of source code must retain the above copyright notice, this | |
| # list of conditions and the following disclaimer. | |
| # | |
| # 2. Redistributions in binary form must reproduce the above copyright notice, |
This file contains hidden or 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
| require 'jruby' | |
| class CurrentThreadAwareFormatter < Logger::Formatter | |
| FORMAT = "%s [%5s] {%s} -- %s\n".freeze | |
| def call(severity, time, progname, msg) | |
| thread = Thread.current | |
| thread_id = JRuby.reference(thread).getNativeThread.to_s | |
| thread_id << ' ' << ( thread[:name] || thread.to_s ) | |
| FORMAT % [format_datetime(time), severity, thread_id, msg2str(msg)] | |
| end | |
| end |
This file contains hidden or 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
| ::ActiveRecord::ConnectionAdapters::ConnectionPool.class_eval do | |
| def release_connection(with_id = current_connection_id) | |
| #synchronize do | |
| conn = @reserved_connections.delete(with_id) | |
| checkin conn, true if conn | |
| #end | |
| end | |
| def checkin(conn, on_release = nil) |
This file contains hidden or 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
| require 'celluloid/internal_pool' | |
| # NOTE: this also avoids JRuby bug with ThreadGroup#list ! | |
| # require 'celluloid' likely happened already : | |
| if Celluloid.internal_pool | |
| Celluloid.internal_pool.shutdown | |
| Celluloid.internal_pool = nil | |
| end |
This file contains hidden or 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
| require 'logging' | |
| module Logging | |
| # require 'logging/repository' | |
| # class Repository | |
| # # include Singleton | |
| # | |
| # def initialize; require 'thread_safe' | |
| # # @h = {:root => ::Logging::RootLogger.new} | |
| # @h = ThreadSafe::Cache.new |
This file contains hidden or 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
| require 'celluloid/stack_dump' | |
| module Celluloid | |
| class StackDump | |
| class ActorState | |
| attr_accessor :thread_name, :thread_id | |
| def dump |
This file contains hidden or 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
| require 'benchmark' | |
| TIMES = 10_000 | |
| Benchmark.bmbm do |x| | |
| x.report("java.lang.System.get_property [#{TIMES}x]") do | |
| TIMES.times do | |
| java.lang.System.get_property('jars.skip') == 'true' | |
| end |