repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
ankane/dexter | https://github.com/ankane/dexter/blob/bc8d0905269f4336d5d23a39696f9fc4f452ce48/lib/dexter/logging.rb | lib/dexter/logging.rb | module Dexter
module Logging
COLOR_CODES = {
red: 31,
green: 32,
yellow: 33,
cyan: 36
}
def output
$dexter_output || $stdout
end
def log(message = "")
output.puts(message) unless $log_level == "error"
end
def colorize(message, color)
if output.t... | ruby | MIT | bc8d0905269f4336d5d23a39696f9fc4f452ce48 | 2026-01-04T15:58:45.791976Z | false |
ankane/dexter | https://github.com/ankane/dexter/blob/bc8d0905269f4336d5d23a39696f9fc4f452ce48/lib/dexter/processor.rb | lib/dexter/processor.rb | module Dexter
class Processor
include Logging
def initialize(source, collector, indexer, interval:)
@source = source
@collector = collector
@indexer = indexer
@starting_interval = 3
@interval = interval
@mutex = Mutex.new
@last_checked_at = {}
log "Started" ... | ruby | MIT | bc8d0905269f4336d5d23a39696f9fc4f452ce48 | 2026-01-04T15:58:45.791976Z | false |
ankane/dexter | https://github.com/ankane/dexter/blob/bc8d0905269f4336d5d23a39696f9fc4f452ce48/lib/dexter/column_resolver.rb | lib/dexter/column_resolver.rb | module Dexter
class ColumnResolver
include Logging
def initialize(connection, queries, log_level:)
@connection = connection
@queries = queries
@log_level = log_level
end
def perform
tables = Set.new(@queries.flat_map(&:candidate_tables))
columns = tables.any? ? self.col... | ruby | MIT | bc8d0905269f4336d5d23a39696f9fc4f452ce48 | 2026-01-04T15:58:45.791976Z | false |
ankane/dexter | https://github.com/ankane/dexter/blob/bc8d0905269f4336d5d23a39696f9fc4f452ce48/lib/dexter/query.rb | lib/dexter/query.rb | module Dexter
class Query
attr_reader :statement, :fingerprint, :total_time, :calls, :plans
attr_accessor :tables, :missing_tables, :new_cost, :indexes, :suggest_index, :pass1_indexes, :pass2_indexes, :pass3_indexes, :candidate_tables, :tables_from_views, :index_mapping, :columns, :candidate_columns
def ... | ruby | MIT | bc8d0905269f4336d5d23a39696f9fc4f452ce48 | 2026-01-04T15:58:45.791976Z | false |
ankane/dexter | https://github.com/ankane/dexter/blob/bc8d0905269f4336d5d23a39696f9fc4f452ce48/lib/dexter/connection.rb | lib/dexter/connection.rb | module Dexter
class Connection
include Logging
def initialize(dbname:, host:, port:, username:, log_sql:)
@dbname = dbname
@host = host
@port = port
@username = username
@log_sql = log_sql
@mutex = Mutex.new
end
def setup(enable_hypopg)
if server_version_num... | ruby | MIT | bc8d0905269f4336d5d23a39696f9fc4f452ce48 | 2026-01-04T15:58:45.791976Z | false |
ankane/dexter | https://github.com/ankane/dexter/blob/bc8d0905269f4336d5d23a39696f9fc4f452ce48/lib/dexter/indexer.rb | lib/dexter/indexer.rb | module Dexter
class Indexer
include Logging
def initialize(connection:, **options)
@connection = connection
@create = options[:create]
@tablespace = options[:tablespace]
@log_level = options[:log_level]
@exclude_tables = options[:exclude]
@include_tables = Array(options[:i... | ruby | MIT | bc8d0905269f4336d5d23a39696f9fc4f452ce48 | 2026-01-04T15:58:45.791976Z | false |
ankane/dexter | https://github.com/ankane/dexter/blob/bc8d0905269f4336d5d23a39696f9fc4f452ce48/lib/dexter/client.rb | lib/dexter/client.rb | module Dexter
class Client
extend Logging
include Logging
attr_reader :arguments, :options
def self.start
Client.new(ARGV).perform
rescue Error => e
abort colorize(e.message.strip, :red)
end
def initialize(args)
@arguments, @options = parse_args(args)
end
def ... | ruby | MIT | bc8d0905269f4336d5d23a39696f9fc4f452ce48 | 2026-01-04T15:58:45.791976Z | false |
ankane/dexter | https://github.com/ankane/dexter/blob/bc8d0905269f4336d5d23a39696f9fc4f452ce48/lib/dexter/sources/pg_stat_statements_source.rb | lib/dexter/sources/pg_stat_statements_source.rb | module Dexter
class PgStatStatementsSource
def initialize(connection)
@connection = connection
end
def perform(collector)
stat_statements.each do |row|
collector.add(row["query"], row["duration_ms"].to_f, row["calls"].to_i)
end
end
# could group, sum, and filter min_tim... | ruby | MIT | bc8d0905269f4336d5d23a39696f9fc4f452ce48 | 2026-01-04T15:58:45.791976Z | false |
ankane/dexter | https://github.com/ankane/dexter/blob/bc8d0905269f4336d5d23a39696f9fc4f452ce48/lib/dexter/sources/pg_stat_activity_source.rb | lib/dexter/sources/pg_stat_activity_source.rb | module Dexter
class PgStatActivitySource
def initialize(connection)
@connection = connection
end
def perform(collector)
previous_queries = {}
10.times do
active_queries = {}
processed_queries = {}
stat_activity.each do |row|
if row["state"] == "active... | ruby | MIT | bc8d0905269f4336d5d23a39696f9fc4f452ce48 | 2026-01-04T15:58:45.791976Z | false |
ankane/dexter | https://github.com/ankane/dexter/blob/bc8d0905269f4336d5d23a39696f9fc4f452ce48/lib/dexter/sources/log_source.rb | lib/dexter/sources/log_source.rb | module Dexter
class LogSource
def initialize(logfile, input_format)
@log_parser =
case input_format
when "csv"
CsvLogParser.new(logfile)
when "json"
JsonLogParser.new(logfile)
when "sql"
SqlLogParser.new(logfile)
else
StderrLogP... | ruby | MIT | bc8d0905269f4336d5d23a39696f9fc4f452ce48 | 2026-01-04T15:58:45.791976Z | false |
ankane/dexter | https://github.com/ankane/dexter/blob/bc8d0905269f4336d5d23a39696f9fc4f452ce48/lib/dexter/sources/statement_source.rb | lib/dexter/sources/statement_source.rb | module Dexter
class StatementSource
def initialize(statements)
@statements = statements
end
def perform(collector)
@statements.each do |statement|
collector.add(statement, 0, 0, true)
end
end
end
end
| ruby | MIT | bc8d0905269f4336d5d23a39696f9fc4f452ce48 | 2026-01-04T15:58:45.791976Z | false |
ankane/dexter | https://github.com/ankane/dexter/blob/bc8d0905269f4336d5d23a39696f9fc4f452ce48/lib/dexter/parsers/stderr_log_parser.rb | lib/dexter/parsers/stderr_log_parser.rb | module Dexter
class StderrLogParser < LogParser
LINE_SEPARATOR = ": ".freeze
DETAIL_LINE = "DETAIL: ".freeze
def perform(collector)
active_line = nil
duration = nil
@logfile.each_line do |line|
if active_line
if line.include?(DETAIL_LINE)
add_parameters(... | ruby | MIT | bc8d0905269f4336d5d23a39696f9fc4f452ce48 | 2026-01-04T15:58:45.791976Z | false |
ankane/dexter | https://github.com/ankane/dexter/blob/bc8d0905269f4336d5d23a39696f9fc4f452ce48/lib/dexter/parsers/sql_log_parser.rb | lib/dexter/parsers/sql_log_parser.rb | module Dexter
class SqlLogParser < LogParser
def perform(collector)
# TODO support streaming
@logfile.read.split(";").each do |statement|
statement = statement.strip
collector.add(statement, 0) unless statement.empty?
end
end
end
end
| ruby | MIT | bc8d0905269f4336d5d23a39696f9fc4f452ce48 | 2026-01-04T15:58:45.791976Z | false |
ankane/dexter | https://github.com/ankane/dexter/blob/bc8d0905269f4336d5d23a39696f9fc4f452ce48/lib/dexter/parsers/json_log_parser.rb | lib/dexter/parsers/json_log_parser.rb | module Dexter
class JsonLogParser < LogParser
FIRST_LINE_REGEX = /\A.+/
def perform(collector)
@logfile.each_line do |line|
row = JSON.parse(line.chomp)
if (m = REGEX.match(row["message"]))
# replace first line with match
# needed for multiline queries
acti... | ruby | MIT | bc8d0905269f4336d5d23a39696f9fc4f452ce48 | 2026-01-04T15:58:45.791976Z | false |
ankane/dexter | https://github.com/ankane/dexter/blob/bc8d0905269f4336d5d23a39696f9fc4f452ce48/lib/dexter/parsers/csv_log_parser.rb | lib/dexter/parsers/csv_log_parser.rb | module Dexter
class CsvLogParser < LogParser
FIRST_LINE_REGEX = /\A.+/
def perform(collector)
CSV.new(@logfile.to_io).each do |row|
message = row[13]
detail = row[14]
if (m = REGEX.match(message))
# replace first line with match
# needed for multiline querie... | ruby | MIT | bc8d0905269f4336d5d23a39696f9fc4f452ce48 | 2026-01-04T15:58:45.791976Z | false |
ankane/dexter | https://github.com/ankane/dexter/blob/bc8d0905269f4336d5d23a39696f9fc4f452ce48/lib/dexter/parsers/log_parser.rb | lib/dexter/parsers/log_parser.rb | module Dexter
class LogParser
REGEX = /duration: (\d+\.\d+) ms (statement|execute [^:]+): (.+)/
def initialize(logfile)
@logfile = logfile
end
private
def add_parameters(active_line, details)
if details.start_with?("parameters: ")
params = Hash[details[12..-1].split(", ").m... | ruby | MIT | bc8d0905269f4336d5d23a39696f9fc4f452ce48 | 2026-01-04T15:58:45.791976Z | false |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/spec/spec_helper.rb | spec/spec_helper.rb | # This file was generated by the `rspec --init` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# Require this file using `require "spec_helper"` to ensure that it is only
# loaded once.
#
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
if ENV... | ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | false |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/spec/support/configuration.rb | spec/support/configuration.rb | require "yaml"
require "erb"
module Configuration
def config
filename = File.join(File.dirname(File.expand_path(__FILE__)), 'minimum.conf.yaml')
@config ||= YAML::load(ERB.new(File.read(filename)).result)
end
end
| ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | false |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/spec/factories/backend.rb | spec/factories/backend.rb | FactoryGirl.define do
factory :backend, :class => Hash do
sequence(:name) { |n| "server#{n}" }
sequence(:host) { |n| "hostname#{n}" }
sequence(:port)
labels {}
# needed to build hashes instead of classes
initialize_with { attributes }
# convert keys to strings, since backends always ha... | ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | false |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/spec/bin/synapse_spec.rb | spec/bin/synapse_spec.rb | require 'spec_helper'
require 'tempfile'
require 'synapse/service_watcher/multi/multi'
describe 'parseconfig' do
it 'parses a templated config' do
allow_any_instance_of(Synapse::Synapse).to receive(:run)
expect(Synapse::Synapse).to receive(:new).
with(hash_including(
{"services" =>
{"t... | ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | false |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/spec/lib/synapse_spec.rb | spec/lib/synapse_spec.rb | require 'spec_helper'
require 'synapse'
require 'synapse/service_watcher/base/base'
describe Synapse do
let(:discovery) {
{
"method" => "base"
}
}
let(:local_haproxy) {
{
"port" => 3213,
"server_options" => "check inter 2s rise 3 fall 2",
"bind_options" => "",
"lis... | ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | false |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/spec/lib/synapse/service_watcher_ec2tags_spec.rb | spec/lib/synapse/service_watcher_ec2tags_spec.rb | require 'spec_helper'
require 'synapse/service_watcher/ec2tag/ec2tag'
require 'logging'
class Synapse::ServiceWatcher::Ec2tagWatcher
attr_reader :synapse
attr_accessor :default_servers, :ec2
end
class FakeAWSInstance
def ip_address
@ip_address ||= fake_address
end
def private_ip_address
@private_... | ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | false |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/spec/lib/synapse/service_watcher_marathon_spec.rb | spec/lib/synapse/service_watcher_marathon_spec.rb | require 'spec_helper'
require 'synapse/service_watcher/marathon/marathon'
describe Synapse::ServiceWatcher::MarathonWatcher do
let(:mocksynapse) do
mock_synapse = instance_double(Synapse::Synapse)
mockgenerator = Synapse::ConfigGenerator::BaseGenerator.new()
allow(mock_synapse).to receive(:available_gene... | ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | false |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/spec/lib/synapse/haproxy_spec.rb | spec/lib/synapse/haproxy_spec.rb | require 'spec_helper'
require 'synapse/config_generator/haproxy'
require 'active_support/all'
require 'active_support/testing/time_helpers'
class MockWatcher; end;
describe Synapse::ConfigGenerator::Haproxy do
include ActiveSupport::Testing::TimeHelpers
subject { Synapse::ConfigGenerator::Haproxy.new(config['hap... | ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | true |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/spec/lib/synapse/service_watcher_docker_spec.rb | spec/lib/synapse/service_watcher_docker_spec.rb | require 'spec_helper'
require 'synapse/service_watcher/docker/docker'
class Synapse::ServiceWatcher::DockerWatcher
attr_reader :check_interval, :watcher, :synapse
attr_accessor :default_servers
end
describe Synapse::ServiceWatcher::DockerWatcher do
let(:mocksynapse) do
mock_synapse = instance_double(Synapse... | ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | false |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/spec/lib/synapse/file_output_spec.rb | spec/lib/synapse/file_output_spec.rb | require 'spec_helper'
require 'fileutils'
require 'synapse/config_generator/file_output'
describe Synapse::ConfigGenerator::FileOutput do
subject { Synapse::ConfigGenerator::FileOutput.new(config['file_output']) }
before(:example) do
FileUtils.mkdir_p(config['file_output']['output_directory'])
end
after(... | ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | false |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/spec/lib/synapse/service_watcher_zookeeper_spec.rb | spec/lib/synapse/service_watcher_zookeeper_spec.rb | require 'spec_helper'
require 'active_support/all'
require 'active_support/testing/time_helpers'
require 'synapse/service_watcher/zookeeper/zookeeper'
require 'synapse/service_watcher/zookeeper_poll/zookeeper_poll'
require 'synapse/service_watcher/zookeeper_dns/zookeeper_dns'
require 'synapse/service_watcher/zookeeper... | ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | true |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/spec/lib/synapse/service_watcher_dns_spec.rb | spec/lib/synapse/service_watcher_dns_spec.rb | require 'spec_helper'
require 'synapse/service_watcher/dns/dns'
describe Synapse::ServiceWatcher::DnsWatcher do
let(:mock_synapse) do
mock_synapse = instance_double(Synapse::Synapse)
mockgenerator = Synapse::ConfigGenerator::BaseGenerator.new()
allow(mock_synapse).to receive(:available_generators).and_re... | ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | false |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/spec/lib/synapse/atomic_spec.rb | spec/lib/synapse/atomic_spec.rb | require 'spec_helper'
require 'synapse/atomic'
describe Synapse::AtomicValue do
let(:initial_value) { 'mock-value' }
let(:internal_mu) { subject.instance_variable_get(:@mu) }
subject { Synapse::AtomicValue.new(initial_value) }
describe '#initialize' do
it 'creates successfully' do
expect { subject ... | ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | false |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/spec/lib/synapse/service_watcher_spec.rb | spec/lib/synapse/service_watcher_spec.rb | require 'spec_helper'
require 'synapse/service_watcher'
describe Synapse::ServiceWatcher do
let(:mock_synapse) do
mock_synapse = instance_double(Synapse::Synapse)
mockgenerator = Synapse::ConfigGenerator::BaseGenerator.new()
allow(mock_synapse).to receive(:available_generators).and_return({
'haprox... | ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | false |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/spec/lib/synapse/retry_policy_spec.rb | spec/lib/synapse/retry_policy_spec.rb | require 'spec_helper'
require 'synapse/retry_policy'
describe "Synapse::RetryPolicy" do
include Synapse::RetryPolicy
context 'with_retry' do
it "default retry succeed" do
expect_attempts = 1
attempts = 0
expected_result = "done"
result = with_retry do
attempts += 1
expe... | ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | false |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/spec/lib/synapse/service_watcher_base_spec.rb | spec/lib/synapse/service_watcher_base_spec.rb | require 'spec_helper'
class Synapse::ServiceWatcher::BaseWatcher
attr_reader :should_exit, :default_servers
end
describe Synapse::ServiceWatcher::BaseWatcher do
let(:mocksynapse) do
mock_synapse = instance_double(Synapse::Synapse)
mockgenerator = Synapse::ConfigGenerator::BaseGenerator.new()
allow(moc... | ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | false |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/spec/lib/synapse/service_watcher_multi_spec.rb | spec/lib/synapse/service_watcher_multi_spec.rb | require 'spec_helper'
require 'synapse/service_watcher/multi/multi'
require 'synapse/service_watcher/zookeeper/zookeeper'
require 'synapse/service_watcher/dns/dns'
require 'synapse/service_watcher/multi/resolver/base'
describe Synapse::ServiceWatcher::MultiWatcher do
let(:mock_synapse) do
mock_synapse = instance... | ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | false |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/spec/lib/synapse/multi_resolver/union_spec.rb | spec/lib/synapse/multi_resolver/union_spec.rb | require 'spec_helper'
require 'synapse/service_watcher/multi/resolver/union'
require 'synapse/service_watcher/base/base'
describe Synapse::ServiceWatcher::Resolver::UnionResolver do
let(:watchers) { {'primary' => primary_watcher, 'secondary' => secondary_watcher} }
let(:primary_watcher) {
w = double(Synapse::... | ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | false |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/spec/lib/synapse/multi_resolver/sequential_spec.rb | spec/lib/synapse/multi_resolver/sequential_spec.rb | require 'spec_helper'
require 'synapse/service_watcher/multi/resolver/sequential'
require 'synapse/service_watcher/base/base'
describe Synapse::ServiceWatcher::Resolver::SequentialResolver do
let(:watchers) { {'primary' => primary_watcher, 'secondary' => secondary_watcher} }
let(:primary_watcher) {
w = double... | ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | false |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/spec/lib/synapse/multi_resolver/loader_spec.rb | spec/lib/synapse/multi_resolver/loader_spec.rb | require 'spec_helper'
require 'synapse/service_watcher/base/base'
require 'synapse/service_watcher/multi/resolver'
require 'synapse/service_watcher/multi/resolver/base'
require 'synapse/service_watcher/multi/resolver/s3_toggle'
describe Synapse::ServiceWatcher::Resolver do
subject { Synapse::ServiceWatcher::Resolver... | ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | false |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/spec/lib/synapse/multi_resolver/base_spec.rb | spec/lib/synapse/multi_resolver/base_spec.rb | require 'spec_helper'
require 'synapse/service_watcher/multi/resolver/base'
require 'synapse/service_watcher/base/base'
describe Synapse::ServiceWatcher::Resolver::BaseResolver do
let(:opts) {
{'method' => 'base'}
}
let(:watchers) {
[
instance_double(Synapse::ServiceWatcher::BaseWatcher)
]
}... | ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | false |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/spec/lib/synapse/multi_resolver/s3_toggle_spec.rb | spec/lib/synapse/multi_resolver/s3_toggle_spec.rb | require 'spec_helper'
require 'synapse/service_watcher/multi/resolver/s3_toggle'
require 'synapse/service_watcher/base/base'
require 'active_support/all'
require 'active_support/testing/time_helpers'
describe Synapse::ServiceWatcher::Resolver::S3ToggleResolver do
include ActiveSupport::Testing::TimeHelpers
let(:w... | ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | false |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/lib/synapse.rb | lib/synapse.rb | require 'logger'
require 'json'
require 'uri'
require 'aws-sdk'
require 'synapse/version'
require 'synapse/log'
require 'synapse/statsd'
require 'synapse/config_generator'
require 'synapse/service_watcher'
require 'synapse/atomic'
require 'synapse/version'
module Synapse
class Synapse
include Logging
inclu... | ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | false |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/lib/synapse/retry_policy.rb | lib/synapse/retry_policy.rb | module Synapse
module RetryPolicy
include Synapse::StatsD
def with_retry(options = {}, &callback)
max_attempts = options['max_attempts'] || 1
max_delay = options['max_delay'] || 3600
base_interval = options['base_interval'] || 0
max_interval = options['max_interval'] || 0
retria... | ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | false |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/lib/synapse/statsd.rb | lib/synapse/statsd.rb | require 'datadog/statsd'
require 'synapse/log'
module Synapse
module StatsD
def statsd
@@STATSD ||= StatsD.statsd_for(self.class.name)
end
def statsd_increment(key, tags = [])
statsd.increment(key, tags: tags, sample_rate: sample_rate_for(key))
end
def statsd_time(key, tags = [])
... | ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | false |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/lib/synapse/version.rb | lib/synapse/version.rb | module Synapse
VERSION = "0.18.9"
end
| ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | false |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/lib/synapse/log.rb | lib/synapse/log.rb | module Synapse
module Logging
def log
@logger ||= Logging.logger_for(self.class.name)
end
# Use a hash class-ivar to cache a unique Logger per class:
@loggers = {}
class << self
def logger_for(classname)
@loggers[classname] ||= configure_logger_for(classname)
end
... | ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | false |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/lib/synapse/config_generator.rb | lib/synapse/config_generator.rb | require 'synapse/log'
require 'synapse/config_generator/base'
module Synapse
class ConfigGenerator
# the type which actually dispatches generator creation requests
def self.create(type, opts)
generator = begin
type = type.downcase
require "synapse/config_generator/#{type}"
# hap... | ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | false |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/lib/synapse/base.rb | lib/synapse/base.rb | module Synapse
def log
@@log ||= Logger.new(STDERR)
end
end
| ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | false |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/lib/synapse/atomic.rb | lib/synapse/atomic.rb | require 'thread'
module Synapse
class AtomicValue
def initialize(initial_value)
@mu = Mutex.new
set(initial_value)
end
def get
return @mu.synchronize { @value }
end
def set(new_value)
@mu.synchronize {
@value = new_value
}
end
def get_and_set(new_v... | ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | false |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/lib/synapse/service_watcher.rb | lib/synapse/service_watcher.rb | require "synapse/log"
require "synapse/service_watcher/base/base"
require "synapse/service_watcher/multi/multi"
module Synapse
class ServiceWatcher
extend Synapse::Logging
# the method which actually dispatches watcher creation requests
def self.create(name, opts, synapse, reconfigure_callback)
op... | ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | false |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/lib/synapse/service_watcher/base/base.rb | lib/synapse/service_watcher/base/base.rb | require 'synapse/log'
require 'synapse/statsd'
require 'synapse/retry_policy'
require 'synapse/atomic'
require 'set'
require 'hashdiff'
class Synapse::ServiceWatcher
class BaseWatcher
include Synapse::Logging
include Synapse::StatsD
include Synapse::RetryPolicy
LEADER_WARN_INTERVAL = 30
attr_re... | ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | false |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/lib/synapse/service_watcher/docker/docker.rb | lib/synapse/service_watcher/docker/docker.rb | require "synapse/service_watcher/base/base"
require 'docker'
class Synapse::ServiceWatcher
class DockerWatcher < BaseWatcher
def start
@check_interval = @discovery['check_interval'] || 15.0
@watcher = Thread.new do
watch
end
end
private
def validate_discovery_opts
rai... | ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | false |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/lib/synapse/service_watcher/ec2tag/ec2tag.rb | lib/synapse/service_watcher/ec2tag/ec2tag.rb | require 'synapse/service_watcher/base/base'
require 'aws-sdk'
class Synapse::ServiceWatcher
class Ec2tagWatcher < BaseWatcher
attr_reader :check_interval
def start
region = @discovery['aws_region'] || ENV['AWS_REGION']
log.info "Connecting to EC2 region: #{region}"
@ec2 = AWS::EC2.new(
... | ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | false |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/lib/synapse/service_watcher/multi/resolver.rb | lib/synapse/service_watcher/multi/resolver.rb | class Synapse::ServiceWatcher
class Resolver
def self.load_resolver(opts, watchers, notification_callback)
raise ArgumentError, "resolver method not provided" unless opts.has_key?('method')
method = opts['method'].downcase
resolver = begin
require "synapse/service_watcher/mul... | ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | false |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/lib/synapse/service_watcher/multi/multi.rb | lib/synapse/service_watcher/multi/multi.rb | require "synapse/service_watcher/base/base"
require "synapse/service_watcher/multi/resolver"
require "synapse/log"
require "synapse/statsd"
class Synapse::ServiceWatcher
# MultiWatcher allows using multiple watchers to obtain service discovery data
# with a configurable resolution strategy among them.
#
# Dis... | ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | false |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/lib/synapse/service_watcher/multi/resolver/base.rb | lib/synapse/service_watcher/multi/resolver/base.rb | require "synapse/log"
require "synapse/statsd"
class Synapse::ServiceWatcher::Resolver
class BaseResolver
include Synapse::Logging
include Synapse::StatsD
def initialize(opts, watchers, notification_callback)
super()
log.info "creating base resolver"
@opts = opts
@watchers = wa... | ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | false |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/lib/synapse/service_watcher/multi/resolver/sequential.rb | lib/synapse/service_watcher/multi/resolver/sequential.rb | require 'synapse/service_watcher/multi/resolver/base'
require 'synapse/log'
require 'synapse/statsd'
require 'synapse/atomic'
class Synapse::ServiceWatcher::Resolver
class SequentialResolver < BaseResolver
include Synapse::Logging
include Synapse::StatsD
def initialize(opts, watchers, reconfigure_callba... | ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | false |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/lib/synapse/service_watcher/multi/resolver/s3_toggle.rb | lib/synapse/service_watcher/multi/resolver/s3_toggle.rb | require 'synapse/service_watcher/multi/resolver/base'
require 'synapse/log'
require 'synapse/statsd'
require 'synapse/atomic'
require 'aws-sdk'
require 'timeout'
require 'thread'
require 'yaml'
class Synapse::ServiceWatcher::Resolver
class S3ToggleResolver < BaseResolver
include Synapse::Logging
include Syn... | ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | false |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/lib/synapse/service_watcher/multi/resolver/union.rb | lib/synapse/service_watcher/multi/resolver/union.rb | require 'synapse/service_watcher/multi/resolver/base'
require 'synapse/log'
require 'synapse/statsd'
class Synapse::ServiceWatcher::Resolver
class UnionResolver < BaseResolver
include Synapse::Logging
include Synapse::StatsD
def validate_opts
raise ArgumentError, "union resolver expects method to ... | ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | false |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/lib/synapse/service_watcher/marathon/marathon.rb | lib/synapse/service_watcher/marathon/marathon.rb | require 'synapse/service_watcher/base/base'
require 'json'
require 'net/http'
require 'resolv'
class Synapse::ServiceWatcher
class MarathonWatcher < BaseWatcher
def start
@check_interval = @discovery['check_interval'] || 10.0
@connection = nil
@watcher = Thread.new { sleep splay; watch }
en... | ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | false |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/lib/synapse/service_watcher/zookeeper_poll/zookeeper_poll.rb | lib/synapse/service_watcher/zookeeper_poll/zookeeper_poll.rb | require 'synapse/service_watcher/base/base'
require 'synapse/service_watcher/zookeeper/zookeeper'
require 'synapse/atomic'
require 'zk'
require 'thread'
class Synapse::ServiceWatcher
class ZookeeperPollWatcher < ZookeeperWatcher
def initialize(opts, synapse, reconfigure_callback)
super(opts, synapse, reco... | ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | false |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/lib/synapse/service_watcher/zookeeper/zookeeper.rb | lib/synapse/service_watcher/zookeeper/zookeeper.rb | require "synapse/service_watcher/base/base"
require 'synapse/atomic'
require 'thread'
require 'zk'
require 'zookeeper'
require 'base64'
require 'objspace'
class Synapse::ServiceWatcher
class ZookeeperWatcher < BaseWatcher
NUMBERS_RE = /^\d+$/
MIN_JITTER = 0
MAX_JITTER = 120
# when zk child name star... | ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | false |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/lib/synapse/service_watcher/zookeeper_dns/zookeeper_dns.rb | lib/synapse/service_watcher/zookeeper_dns/zookeeper_dns.rb | require 'synapse/service_watcher/base/base'
require 'synapse/service_watcher/dns/dns'
require 'synapse/service_watcher/zookeeper/zookeeper'
require 'thread'
# Watcher for watching Zookeeper for entries containing DNS names that are
# continuously resolved to IP Addresses. The use case for this watcher is to
# allow ... | ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | false |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/lib/synapse/service_watcher/dns/dns.rb | lib/synapse/service_watcher/dns/dns.rb | require "synapse/service_watcher/base/base"
require 'thread'
require 'resolv'
class Synapse::ServiceWatcher
class DnsWatcher < BaseWatcher
def start
@check_interval = @discovery['check_interval'] || 30.0
@nameserver = @discovery['nameserver']
@watcher = Thread.new do
watch
end
... | ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | false |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/lib/synapse/service_watcher/zookeeper_dns_poll/zookeeper_dns_poll.rb | lib/synapse/service_watcher/zookeeper_dns_poll/zookeeper_dns_poll.rb | require 'synapse/service_watcher/base/base'
require 'synapse/service_watcher/zookeeper_dns/zookeeper_dns'
require 'synapse/service_watcher/zookeeper_poll/zookeeper_poll'
require 'thread'
class Synapse::ServiceWatcher
class ZookeeperDnsPollWatcher < ZookeeperDnsWatcher
def make_zookeeper_watcher(queue)
zoo... | ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | false |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/lib/synapse/config_generator/haproxy.rb | lib/synapse/config_generator/haproxy.rb | require 'synapse/config_generator/base'
require 'fileutils'
require 'json'
require 'socket'
require 'digest/sha1'
require 'set'
require 'hashdiff'
require 'open3'
class Synapse::ConfigGenerator
class Haproxy < BaseGenerator
include Synapse::Logging
NAME = 'haproxy'.freeze
HAPROXY_CMD_BATCH_SIZE = 4
... | ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | true |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/lib/synapse/config_generator/base.rb | lib/synapse/config_generator/base.rb | require 'synapse/log'
require 'synapse/statsd'
class Synapse::ConfigGenerator
class BaseGenerator
include Synapse::Logging
include Synapse::StatsD
NAME = 'base'.freeze
attr_reader :opts
def initialize(opts={})
@opts = opts
end
# Exposes NAME as 'name' so we can remain consistent... | ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | false |
airbnb/synapse | https://github.com/airbnb/synapse/blob/89e05f098e5924cea2e1369eacc99bc5f7e0d435/lib/synapse/config_generator/file_output.rb | lib/synapse/config_generator/file_output.rb | require 'synapse/config_generator/base'
require 'fileutils'
require 'tempfile'
class Synapse::ConfigGenerator
class FileOutput < BaseGenerator
include Synapse::Logging
NAME = 'file_output'.freeze
def initialize(opts)
super(opts)
unless opts.has_key?("output_directory")
raise Argum... | ruby | MIT | 89e05f098e5924cea2e1369eacc99bc5f7e0d435 | 2026-01-04T15:58:42.405058Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/spec/test_prof_spec.rb | spec/test_prof_spec.rb | # frozen_string_literal: true
describe TestProf do
describe "#artifact_path" do
before do
described_class.config.output_dir = "tmp/test"
end
after { FileUtils.rmdir(described_class.config.output_dir) if File.directory?(described_class.config.output_dir) }
context "ensures creation of output_d... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/spec/cop_helper.rb | spec/cop_helper.rb | # frozen_string_literal: true
require "rubocop"
require "rubocop/test_prof/plugin"
require "rubocop/rspec/support"
RSpec.configure do |config|
config.include(RuboCop::RSpec::ExpectOffense)
end
| ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/spec/spec_helper.rb | spec/spec_helper.rb | # frozen_string_literal: true
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
begin
require "debug" unless ENV["CI"]
rescue LoadError
end
require "open3"
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each { |f| require f }
RSpec.configure do |config|
config.mock_with :rspec
config.order = ... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/spec/bugs/rspec_dissect_pending_spec.rb | spec/bugs/rspec_dissect_pending_spec.rb | # frozen_string_literal: true
# https://github.com/test-prof/test-prof/issues/60
describe "RSpecDissect with pending examples", type: :integration do
specify do
output = run_rspec(
"rspec_dissect_pending",
chdir: File.join(__dir__, "fixtures"),
env: {"RD_PROF" => "1"}
)
expect(output).... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/spec/bugs/let_it_be_savepoint_spec.rb | spec/bugs/let_it_be_savepoint_spec.rb | # frozen_string_literal: true
# https://github.com/test-prof/test-prof/issues/265
describe "let_it_be + mysql + savepoints", type: :integration do
specify "works" do
output = run_rspec(
"let_it_be_savepoint",
chdir: File.join(__dir__, "fixtures")
)
expect(output).to include("0 failures")
e... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/spec/bugs/before_all_any_fixture_multidb_spec.rb | spec/bugs/before_all_any_fixture_multidb_spec.rb | # frozen_string_literal: true
# https://github.com/test-prof/test-prof/issues/310
describe "before_all + any_fixture + multidb", type: :integration do
specify "works" do
output = run_rspec(
"before_all_any_fixture_multidb",
chdir: File.join(__dir__, "fixtures")
)
expect(output).to include("0... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/spec/bugs/time_patch_handling_spec.rb | spec/bugs/time_patch_handling_spec.rb | # frozen_string_literal: true
# https://github.com/test-prof/test-prof/issues/10
describe "Time.now patching handling (e.g. Timecop)", type: :integration do
context "TestProf.now" do
specify "works with ad-hoc patch" do
output = run_rspec(
"time_patch",
chdir: File.join(__dir__, "fixtures")... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/spec/bugs/rspec_detection_false_positive_spec.rb | spec/bugs/rspec_detection_false_positive_spec.rb | # frozen_string_literal: true
# https://github.com/test-prof/test-prof/issues/8
describe "RSpec false positive detection", type: :integration do
specify do
output = run_minitest("rspec_detection_false_positive", chdir: File.join(__dir__, "fixtures"))
expect(output).to include("1 runs, 1 assertions, 0 failur... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/spec/bugs/fixtures/event_prof_timecop_fixture.rb | spec/bugs/fixtures/event_prof_timecop_fixture.rb | # frozen_string_literal: true
$LOAD_PATH.unshift File.expand_path("../../../../../lib", __FILE__)
require_relative "../../support/ar_models"
require_relative "../../support/transactional_context"
require "timecop"
require "test-prof"
User.after_create { sleep 0.01 }
Timecop.freeze
RSpec.configure do |config|
conf... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/spec/bugs/fixtures/time_patch_fixture.rb | spec/bugs/fixtures/time_patch_fixture.rb | # frozen_string_literal: true
$LOAD_PATH.unshift File.expand_path("../../../../../lib", __FILE__)
require "active_support"
require "active_support/testing/time_helpers"
require "test-prof"
# rubocop:disable Style/GlobalVars
$_now = Time.now
Time.define_singleton_method(:now) { $_now }
# rubocop:enable Style/GlobalVar... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/spec/bugs/fixtures/let_it_be_savepoint_fixture.rb | spec/bugs/fixtures/let_it_be_savepoint_fixture.rb | # frozen_string_literal: true
require "action_controller/railtie"
require "action_view/railtie"
require "active_record/railtie"
require "rspec/rails"
require_relative "../../support/ar_models"
RSpec.configure do |config|
if config.respond_to?(:fixture_paths)
config.fixture_paths = [File.join(__dir__, "fixtures... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/spec/bugs/fixtures/before_all_any_fixture_multidb_fixture.rb | spec/bugs/fixtures/before_all_any_fixture_multidb_fixture.rb | # frozen_string_literal: true
require "action_controller/railtie"
require "action_view/railtie"
require "active_record/railtie"
require "rspec/rails"
require_relative "../../support/ar_models"
RSpec.configure do |config|
if config.respond_to?(:fixture_paths)
config.fixture_paths = [File.join(__dir__, "fixtures... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/spec/bugs/fixtures/rspec_detection_false_positive_fixture.rb | spec/bugs/fixtures/rspec_detection_false_positive_fixture.rb | # frozen_string_literal: true
$LOAD_PATH.unshift File.expand_path("../../../../../lib", __FILE__)
module RSpec
def self.foo
end
end
require "minitest/autorun"
require "test_prof"
class SomethingTest < Minitest::Test
def test_pass
assert true
end
end
| ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/spec/bugs/fixtures/timecop_fixture.rb | spec/bugs/fixtures/timecop_fixture.rb | # frozen_string_literal: true
$LOAD_PATH.unshift File.expand_path("../../../../../lib", __FILE__)
require "timecop" if ENV.fetch("TIMECOP_ORDER", "before") == "before"
require "test-prof"
require "timecop" if ENV.fetch("TIMECOP_ORDER", "before") == "after"
Timecop.freeze
describe "Something" do
it "sleeps a little... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/spec/bugs/fixtures/rspec_dissect_pending_fixture.rb | spec/bugs/fixtures/rspec_dissect_pending_fixture.rb | # frozen_string_literal: true
$LOAD_PATH.unshift File.expand_path("../../../../../lib", __FILE__)
require "test-prof"
describe "Something" do
it "works" do
expect(true).to eq true
end
it "is pending", :pending do
expect(true).to eq false
end
xit "is skipped" do
expect(true).to eq false
end
e... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/spec/support/instrumenter_stub.rb | spec/support/instrumenter_stub.rb | # frozen_string_literal: true
module InstrumenterStub
class << self
def subscribe(event, &block)
listeners[event] = block
end
def notify(event, time)
listeners[event].call(time)
end
private
def listeners
@listeners ||= {}
end
end
end
| ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/spec/support/integration_helpers.rb | spec/support/integration_helpers.rb | # frozen_string_literal: true
module IntegrationHelpers
RUBY_RUNNER = if defined?(JRUBY_VERSION)
# See https://github.com/jruby/jruby/wiki/Improving-startup-time#bundle-exec
"jruby -G"
else
"bundle exec ruby"
end
RSPEC_STUB = File.join(__dir__, "../../bin/rspec")
def run_rspec(path, chdir: nil,... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/spec/support/transactional_minitest.rb | spec/support/transactional_minitest.rb | # frozen_string_literal: true
require "active_record"
module TransactionalMinitest
def setup
ActiveRecord::Base.connection.begin_transaction(joinable: false)
super
end
def teardown
super
ActiveRecord::Base.connection.rollback_transaction
end
end
| ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/spec/support/transactional_context.rb | spec/support/transactional_context.rb | # frozen_string_literal: true
require "active_record"
shared_context "transactional", transactional: true do
prepend_before(:each) do
ActiveRecord::Base.connection.begin_transaction(joinable: false)
::Isolator.incr_thresholds! if defined?(::Isolator)
end
append_after(:each) do
::Isolator.decr_thres... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/spec/support/ar_models.rb | spec/support/ar_models.rb | # frozen_string_literal: true
# Set RAILS_ENV explicitily, so configurations could be picked up
ENV["RAILS_ENV"] = "test"
require "logger"
require "active_record"
require "fabrication"
require "test_prof"
require "active_support/inflector"
require "test_prof/factory_bot"
require "activerecord-jdbc-adapter" if define... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/spec/support/include_lines_matcher.rb | spec/support/include_lines_matcher.rb | # frozen_string_literal: true
# Verify that the actual string contains all lines that included the specified
# lines in the provided order.
#
# Example:
#
# text = <<~TXT
# Jingle bells,
# Jingle bells,
# Jingle all the way
# TXT
#
# # passes
# expect(text).to include_lines("Jingle bells", "Jingl... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/spec/integrations/event_prof_spec.rb | spec/integrations/event_prof_spec.rb | # frozen_string_literal: true
describe "EventProf RSpec" do
specify "with default options", :aggregate_failures do
output = run_rspec("event_prof", env: {"EVENT_PROF" => "test.event"})
expect(output).to include("EventProf results for test.event")
expect(output).to match(/Total time: 00:00\.359 of 00:0\d... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/spec/integrations/tps_prof_spec.rb | spec/integrations/tps_prof_spec.rb | # frozen_string_literal: true
describe "TPSProf" do
context "RSpec" do
specify "with default options", :aggregate_failures do
output = run_rspec("tps_prof", env: {"TPS_PROF" => "1", "TPS_PROF_MIN" => "2"})
expect(output).to include("TPSProf enabled (top-10)")
expect(output).to match(/Total TPS... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/spec/integrations/let_it_be_spec.rb | spec/integrations/let_it_be_spec.rb | # frozen_string_literal: true
describe "LetItBe" do
specify "it works" do
output = run_rspec("let_it_be")
expect(output).to include("0 failures")
end
specify "default and metadata modifiers" do
output = run_rspec("let_it_be_modifiers")
expect(output).to include("0 failures")
end
specify "... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/spec/integrations/rspec_stamp_spec.rb | spec/integrations/rspec_stamp_spec.rb | # frozen_string_literal: true
describe "RSpecStamp" do
before do
FileUtils.cp(
File.expand_path("../../integrations/fixtures/rspec/rspec_stamp_fixture_tmpl.rb", __FILE__),
File.expand_path("../../integrations/fixtures/rspec/rspec_stamp_fixture.rb", __FILE__)
)
end
after do
FileUtils.rm(
... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/spec/integrations/factory_doctor_spec.rb | spec/integrations/factory_doctor_spec.rb | # frozen_string_literal: true
describe "FactoryDoctor" do
context "Minitest Integration" do
it "works when there are bad examples", :aggregate_failures do
output = run_minitest("factory_doctor", env: {"FDOC" => "1", "FDOC_THRESHOLD" => "0"})
expect(output).to include("FactoryDoctor report")
ex... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/spec/integrations/memory_prof_minitest_spec.rb | spec/integrations/memory_prof_minitest_spec.rb | # frozen_string_literal: true
number_regex = /\d+\.?\d{0,2}/
memory_human_regex = /#{number_regex}[KMGTPEZ]?B/
percent_regex = /#{number_regex}%/
describe "MemoryProf Minitest" do
specify "with default options", :aggregate_failures do
output = run_minitest("memory_prof", env: {"TEST_MEM_PROF" => "test"})
e... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/spec/integrations/factory_default_spec.rb | spec/integrations/factory_default_spec.rb | # frozen_string_literal: true
describe "FactoryDefault", :aggregate_failures do
context "RSpec integration" do
specify "basic" do
output = run_rspec("factory_default")
expect(output).to include("0 failures")
end
specify "fabrication" do
output = run_rspec("factory_default_fabrication"... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/spec/integrations/profilers_spec.rb | spec/integrations/profilers_spec.rb | # frozen_string_literal: true
PROFILERS_AVAILABLE =
begin
require "stackprof"
require "ruby-prof"
require "vernier"
rescue LoadError
end
describe "general profilers", skip: !PROFILERS_AVAILABLE do
context "RSpec integration" do
context "ruby prof" do
specify "per example" do
outp... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/spec/integrations/event_prof_minitest_spec.rb | spec/integrations/event_prof_minitest_spec.rb | # frozen_string_literal: true
describe "EventProf" do
specify "Minitest integration with default rank by time", :aggregate_failures do
output = run_minitest("event_prof", env: {"EVENT_PROF" => "test.event"})
expect(output).to include("EventProf results for test.event")
expect(output).to match(/Total tim... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/spec/integrations/factory_prof_spec.rb | spec/integrations/factory_prof_spec.rb | # frozen_string_literal: true
describe "FactoryProf" do
context "RSpec integration" do
specify "simple printer", :aggregate_failures do
output = run_rspec("factory_prof", env: {"FPROF" => "1"})
expect(output).to include("FactoryProf enabled (simple mode)")
expect(output).to include("Factories... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/spec/integrations/logging_spec.rb | spec/integrations/logging_spec.rb | # frozen_string_literal: true
describe "Logging" do
context "RSpec integration" do
specify "global all", :aggregate_failures do
output = run_rspec("logging", env: {"LOG" => "all"}, options: "--tag test:global")
expect(output).to include("examples, 0 failures")
expect(output).to include("INSER... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/spec/integrations/sample_spec.rb | spec/integrations/sample_spec.rb | # frozen_string_literal: true
describe "Tests Sampling" do
context "RSpec integration" do
specify "SAMPLE=2" do
output = run_rspec("sample", env: {"SAMPLE" => "2"})
expect(output).to include("2 examples, 0 failures")
end
specify "SAMPLE=1" do
output = run_rspec("sample", env: {"SAMPLE... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/spec/integrations/rubocop_spec.rb | spec/integrations/rubocop_spec.rb | # frozen_string_literal: true
describe "RuboCop cops" do
context "AggregateExamples" do
specify do
output = run_rubocop("aggregate_failures", cop: "RSpec/AggregateExamples")
expect(output).to include("1 offense detected")
expect(output).to include("RSpec/AggregateExamples")
end
end
end
| ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
test-prof/test-prof | https://github.com/test-prof/test-prof/blob/32513491a2d6b61ef7ef4906731daef61740bb04/spec/integrations/memory_prof_rspec_spec.rb | spec/integrations/memory_prof_rspec_spec.rb | # frozen_string_literal: true
number_regex = /\d+\.?\d{0,2}/
memory_human_regex = /#{number_regex}[KMGTPEZ]?B/
percent_regex = /#{number_regex}%/
describe "MemoryProf RSpec" do
specify "with default options", :aggregate_failures do
output = run_rspec("memory_prof", env: {"TEST_MEM_PROF" => "test", "TEST_MEM_PRO... | ruby | MIT | 32513491a2d6b61ef7ef4906731daef61740bb04 | 2026-01-04T15:58:51.674285Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.