source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | clio/jit_preloader | https://github.com/clio/jit_preloader | lib/jit_preloader/active_record/associations/singular_association.rb | Ruby | mit | 201 | master | 1,383 | module JitPreloader
module ActiveRecordAssociationsSingularAssociation
def load_target
was_loaded = loaded?
if !loaded? && owner.persisted? && owner.jit_preloader && (reflection.scope.nil? || reflection.scope.arity == 0)
owner.jit_preloader.jit_preload(reflection.name)
end
jit_l... |
github | clio/jit_preloader | https://github.com/clio/jit_preloader | lib/jit_preloader/active_record/associations/preloader/ar6_association.rb | Ruby | mit | 201 | master | 1,902 | module JitPreloader
module PreloaderAssociation
# A monkey patch to ActiveRecord. The old method looked like the snippet
# below. Our changes here are that we remove records that are already
# part of the target, then attach all of the records to a new jit preloader.
#
# def run
# records =... |
github | clio/jit_preloader | https://github.com/clio/jit_preloader | lib/jit_preloader/active_record/associations/preloader/collection_association.rb | Ruby | mit | 201 | master | 1,538 | class ActiveRecord::Associations::Preloader::CollectionAssociation
private
# A monkey patch to ActiveRecord. The old method looked like the snippet
# below. Our changes here are that we remove records that are already
# part of the target, then attach all of the records to a new jit preloader.
#
# def prelo... |
github | clio/jit_preloader | https://github.com/clio/jit_preloader | lib/jit_preloader/active_record/associations/preloader/ar7_branch.rb | Ruby | mit | 201 | master | 1,065 | module JitPreloader
module PreloaderBranch
"""
ActiveRecord version >= 7.x.x introduced an improvement for preloading associations in batches:
https://github.com/rails/rails/blob/main/activerecord/lib/active_record/associations/preloader.rb#L121
Our existing monkey-patches will ignore associations wh... |
github | clio/jit_preloader | https://github.com/clio/jit_preloader | lib/jit_preloader/active_record/associations/preloader/ar7_association.rb | Ruby | mit | 201 | master | 1,980 | module JitPreloader
module PreloaderAssociation
# A monkey patch to ActiveRecord. The old method looked like the snippet
# below. Our changes here are that we remove records that are already
# part of the target, then attach all of the records to a new jit preloader.
#
# def run
# records =... |
github | clio/jit_preloader | https://github.com/clio/jit_preloader | lib/jit_preloader/active_record/associations/preloader/singular_association.rb | Ruby | mit | 201 | master | 1,146 | class ActiveRecord::Associations::Preloader::SingularAssociation
private
# A monkey patch to ActiveRecord. The old method looked like the snippet
# below. Our changes here are that we don't assign the record if the
# target has already been set, and we attach all of the records to a new
# jit preloader.
#
... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | Gemfile | Ruby | mit | 201 | main | 271 | # frozen_string_literal: true
source "https://rubygems.org"
gemspec
gem "benchmark-ips"
gem "rbs", "4.0.2" if RUBY_VERSION.start_with?("4.0")
# Fix install issue for jruby on gem 3.1.8.
# No java stub is published.
gem "bigdecimal", "3.1.7" if RUBY_PLATFORM == "java" |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | Rakefile | Ruby | mit | 201 | main | 12,826 | # frozen_string_literal: true
require "bundler"
require "rubygems/package_task"
require "fileutils"
require "yaml"
VERSION_MANAGERS = {
:chruby => {
:env => "#!/bin/bash\nsource /usr/local/opt/chruby/share/chruby/chruby.sh",
:switch_command => lambda { |version| "chruby #{version}" }
},
:rbenv => {
... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | benchmark.rake | Ruby | mit | 201 | main | 3,341 | # frozen_string_literal: true
# Run using: rake --rakefile benchmark.rake [tasks]
$LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), "lib"))
require "benchmark"
require "benchmark/ips"
require "appsignal"
def process_rss
`ps -o rss= -p #{Process.pid}`.to_i
end
GC.disable
task :default => :"benchma... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | appsignal.gemspec | Ruby | mit | 201 | main | 2,386 | # frozen_string_literal: true
require File.expand_path("lib/appsignal/version", __dir__)
IGNORED_PATHS = [
# Directories
".changesets/",
".github/",
"gemfiles/",
"script/",
"spec/",
# Files
".gitignore",
".gitmodules",
".rspec",
".yardopts",
"benchmark.rake",
"mono.yml",
".rubocop.yml",
... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal.rb | Ruby | mit | 201 | main | 23,256 | # frozen_string_literal: true
require "json"
require "securerandom"
require "stringio"
require "appsignal/logger"
require "appsignal/utils/stdout_and_logger_message"
require "appsignal/helpers/instrumentation"
require "appsignal/helpers/metrics"
# AppSignal for Ruby gem's main module.
#
# Provides method to control ... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/demo.rb | Ruby | mit | 201 | main | 3,183 | # frozen_string_literal: true
require "rack/mock"
module Appsignal
# {Appsignal::Demo} is a way to send demonstration / test samples for a
# exception and a performance issue.
#
# @example Send example transactions
# Appsignal::Demo.transmit
#
# @since 2.0.0
# @see Appsignal::CLI::Demo
# @api priv... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/loaders.rb | Ruby | mit | 201 | main | 2,171 | # frozen_string_literal: true
module Appsignal
# @!visibility private
module Loaders
class << self
def loaders
@loaders ||= {}
end
def instances
@instances ||= {}
end
def register(name, klass)
loaders[name.to_sym] = klass
end
def registered?(... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/environment.rb | Ruby | mit | 201 | main | 4,617 | # frozen_string_literal: true
module Appsignal
# @!visibility private
class Environment
ERROR_ON_YIELD = :APPSIGNAL_ERROR_ON_YIELD
# Add environment metadata.
#
# The key and value of the environment metadata must be a String, even if
# it's actually of another type.
#
# The value of t... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/logger.rb | Ruby | mit | 201 | main | 9,623 | # frozen_string_literal: true
require "logger"
require "set"
module Appsignal
# Logger that flushes logs to the AppSignal logging service.
#
# @see https://docs.appsignal.com/logging/platforms/integrations/ruby.html
# AppSignal Ruby logging documentation.
class Logger < ::Logger
# A wrapper for a bloc... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/rack.rb | Ruby | mit | 201 | main | 3,311 | # frozen_string_literal: true
module Appsignal
# @!visibility private
module Rack
APPSIGNAL_TRANSACTION = "appsignal.transaction"
APPSIGNAL_EVENT_HANDLER_ID = "appsignal.event_handler_id"
APPSIGNAL_EVENT_HANDLER_HAS_ERROR = "appsignal.event_handler.error"
APPSIGNAL_RESPONSE_INSTRUMENTED = "appsigna... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/cli.rb | Ruby | mit | 201 | main | 2,845 | # frozen_string_literal: true
require "optparse"
require "logger"
require "appsignal"
require "appsignal/cli/helpers"
require "appsignal/cli/demo"
require "appsignal/cli/diagnose"
require "appsignal/cli/install"
module Appsignal
# @!visibility private
class CLI
AVAILABLE_COMMANDS = %w[demo diagnose install].f... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/system.rb | Ruby | mit | 201 | main | 2,986 | # frozen_string_literal: true
module Appsignal
# System environment detection module.
#
# Provides useful methods to find out more about the host system.
#
# @!visibility private
module System
LINUX_TARGET = "linux"
LINUX_ARM_ARCHITECTURE = "aarch64"
MUSL_TARGET = "linux-musl"
FREEBSD_TARGE... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/auth_check.rb | Ruby | mit | 201 | main | 1,886 | # frozen_string_literal: true
module Appsignal
# Class used to perform a Push API validation / authentication check against
# the AppSignal Push API.
#
# @example
# config = Appsignal::Config.new(Dir.pwd, "production")
# auth_check = Appsignal::AuthCheck.new(config)
# # Valid push_api_key
# aut... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/sample_data.rb | Ruby | mit | 201 | main | 3,051 | # frozen_string_literal: true
module Appsignal
# @!visibility private
class SampleData
def initialize(key, accepted_type = nil)
@key = key
@accepted_type = accepted_type
@blocks = []
@empty = false
end
def add(data = nil, &block)
@empty = false
if block_given?
... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/custom_marker.rb | Ruby | mit | 201 | main | 2,152 | # frozen_string_literal: true
module Appsignal
# Custom markers are used on AppSignal.com to indicate events in an
# application, to give additional context on graph timelines.
#
# This helper class will send a request to the AppSignal public endpoint to
# create a Custom marker for the application on AppSig... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/transaction.rb | Ruby | mit | 201 | main | 29,758 | # frozen_string_literal: true
require "json"
module Appsignal
class Transaction
# @return [String]
HTTP_REQUEST = "http_request"
# @return [String]
BACKGROUND_JOB = "background_job"
# @!visibility private
ACTION_CABLE = "action_cable"
# @!visibility private
BLANK = ""
... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/extension.rb | Ruby | mit | 201 | main | 3,449 | # frozen_string_literal: true
begin
if Appsignal::System.jruby?
require "appsignal/extension/jruby"
# {Appsignal.extension_loaded} is set in the JRuby extension file
else
require "appsignal_extension"
Appsignal.extension_loaded = true
end
rescue LoadError => error
error_message = "ERROR: AppSig... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/event_formatter.rb | Ruby | mit | 201 | main | 3,969 | # frozen_string_literal: true
module Appsignal
# Keeps track of formatters for types event that we can use to get
# the title and body of an event. Formatters should inherit from this class
# and implement a format(payload) method which returns an array with the title
# and body.
#
# When implementing a fo... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/probes.rb | Ruby | mit | 201 | main | 8,526 | # frozen_string_literal: true
module Appsignal
module Probes
# @return [Integer]
# @!visibility private
ITERATION_IN_SECONDS = 60
# @!visibility private
class ProbeCollection
def initialize
@probes = {}
end
# @return [Integer] Number of probes that are registered.
... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/check_in.rb | Ruby | mit | 201 | main | 3,213 | # frozen_string_literal: true
module Appsignal
module CheckIn
# @!visibility private
HEARTBEAT_CONTINUOUS_INTERVAL_SECONDS = 30
# @!visibility private
NEW_SCHEDULER_MUTEX = Mutex.new
class << self
# @!visibility private
def continuous_heartbeats
@continuous_heartbeats ||= []
... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/marker.rb | Ruby | mit | 201 | main | 2,227 | # frozen_string_literal: true
module Appsignal
# Deploy markers are used on AppSignal.com to indicate changes in an
# application, "Deploy markers" indicate a deploy of an application.
#
# Incidents for exceptions and performance issues will be closed and
# reopened if they occur again in the new deploy.
#... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/utils.rb | Ruby | mit | 201 | main | 440 | # frozen_string_literal: true
module Appsignal
# @!visibility private
module Utils
end
end
require "appsignal/utils/integration_memory_logger"
require "appsignal/utils/stdout_and_logger_message"
require "appsignal/utils/data"
require "appsignal/utils/sample_data_sanitizer"
require "appsignal/utils/integration_l... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/capistrano.rb | Ruby | mit | 201 | main | 414 | # frozen_string_literal: true
require "appsignal"
require "capistrano/version"
Appsignal::Environment.report_enabled("capistrano")
if defined?(Capistrano::VERSION) && Gem::Version.new(Capistrano::VERSION) >= Gem::Version.new(3)
# Capistrano 3+
load File.expand_path("integrations/capistrano/appsignal.cap", __dir_... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/hooks.rb | Ruby | mit | 201 | main | 2,611 | # frozen_string_literal: true
module Appsignal
# @!visibility private
class Hooks
class << self
def register(name, hook)
hooks[name] = hook
end
def load_hooks
hooks.each do |name, hook|
hook.try_to_install(name)
end
end
def hooks
@hooks ... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/internal_errors.rb | Ruby | mit | 201 | main | 384 | # frozen_string_literal: true
module Appsignal
class InternalError < StandardError; end
class NotStartedError < InternalError
# @!visibility private
MESSAGE = <<~MESSAGE
The AppSignal Ruby gem was not started!
This error was raised by calling `Appsignal.check_if_started!`
MESSAGE
# @... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/config.rb | Ruby | mit | 201 | main | 36,583 | # frozen_string_literal: true
require "erb"
require "yaml"
require "uri"
require "socket"
require "tmpdir"
module Appsignal
class Config
# @!visibility private
def self.loader_defaults
@loader_defaults ||= []
end
# @!visibility private
def self.add_loader_defaults(name, env: nil, root_pat... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/transmitter.rb | Ruby | mit | 201 | main | 3,496 | # frozen_string_literal: true
require "net/http"
require "net/https"
require "uri"
require "rack/utils"
require "json"
module Appsignal
# @!visibility private
class Transmitter
JSON_CONTENT_TYPE = "application/json; charset=UTF-8"
NDJSON_CONTENT_TYPE = "application/x-ndjson; charset=UTF-8"
HTTP_ERROR... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/garbage_collection.rb | Ruby | mit | 201 | main | 2,552 | # frozen_string_literal: true
module Appsignal
# @!visibility private
module GarbageCollection
# Return the GC profiler wrapper.
#
# Returns {Profiler} if the Ruby Garbage Collection profiler is enabled.
# This is checked by calling `GC::Profiler.enabled?`.
#
# GC profiling is disabled by d... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/span.rb | Ruby | mit | 201 | main | 2,058 | # frozen_string_literal: true
module Appsignal
# @!visibility private
class Span
def initialize(namespace = nil, ext = nil)
@ext = ext || Appsignal::Extension::Span.root(namespace || "")
end
def child
Span.new(nil, @ext.child)
end
def name=(value)
@ext.set_name(value)
en... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/probes/sidekiq.rb | Ruby | mit | 201 | main | 4,169 | # frozen_string_literal: true
module Appsignal
module Probes
# @!visibility private
class SidekiqProbe
include Helpers
class Sidekiq7Adapter
def self.redis_info
redis_info = nil
::Sidekiq.redis { |c| redis_info = c.info }
redis_info
end
def ... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/probes/gvl.rb | Ruby | mit | 201 | main | 2,208 | # frozen_string_literal: true
module Appsignal
module Probes
# @!visibility private
class GvlProbe
include Helpers
# @!visibility private
def self.dependencies_present?
defined?(::GVLTools) && gvltools_0_2_or_newer? && ruby_3_2_or_newer? &&
!Appsignal::System.jruby?
... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/probes/mri.rb | Ruby | mit | 201 | main | 2,979 | # frozen_string_literal: true
module Appsignal
module Probes
# @!visibility private
class MriProbe
include Helpers
# @!visibility private
def self.dependencies_present?
defined?(::RubyVM) && ::RubyVM.respond_to?(:stat)
end
def initialize(appsignal: Appsignal, gc_profil... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/probes/helpers.rb | Ruby | mit | 201 | main | 1,938 | # frozen_string_literal: true
module Appsignal
module Probes
# @!visibility private
module Helpers
private
def gauge_delta_cache
@gauge_delta_cache ||= {}
end
# Calculate the delta of two values for a gauge metric.
#
# When this method is called, the given value ... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/hooks/sequel.rb | Ruby | mit | 201 | main | 1,642 | # frozen_string_literal: true
module Appsignal
class Hooks
# @!visibility private
module SequelLogExtension
# Add query instrumentation
def log_yield(sql, args = nil)
Appsignal.instrument(
"sql.sequel",
nil,
sql,
Appsignal::EventFormatter::SQL_BODY_... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/hooks/redis.rb | Ruby | mit | 201 | main | 566 | # frozen_string_literal: true
module Appsignal
class Hooks
# @!visibility private
class RedisHook < Appsignal::Hooks::Hook
register :redis
def dependencies_present?
defined?(::Redis) &&
!defined?(::RedisClient) &&
Appsignal.config &&
Appsignal.config[:instru... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/hooks/unicorn.rb | Ruby | mit | 201 | main | 556 | # frozen_string_literal: true
module Appsignal
class Hooks
# @!visibility private
class UnicornHook < Appsignal::Hooks::Hook
register :unicorn
def dependencies_present?
defined?(::Unicorn::HttpServer) &&
defined?(::Unicorn::Worker)
end
def install
require "... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/hooks/active_support_notifications.rb | Ruby | mit | 201 | main | 2,025 | # frozen_string_literal: true
module Appsignal
class Hooks
# @!visibility private
class ActiveSupportNotificationsHook < Appsignal::Hooks::Hook
register :active_support_notifications
def dependencies_present?
defined?(::ActiveSupport::Notifications::Instrumenter)
end
def ins... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/hooks/data_mapper.rb | Ruby | mit | 201 | main | 472 | # frozen_string_literal: true
module Appsignal
class Hooks
# @!visibility private
class DataMapperHook < Appsignal::Hooks::Hook
register :data_mapper
def dependencies_present?
defined?(::DataMapper) &&
defined?(::DataObjects::Connection)
end
def install
req... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/hooks/shoryuken.rb | Ruby | mit | 201 | main | 524 | # frozen_string_literal: true
module Appsignal
class Hooks
# @!visibility private
class ShoryukenHook < Appsignal::Hooks::Hook
register :shoryuken
def dependencies_present?
defined?(::Shoryuken)
end
def install
require "appsignal/integrations/shoryuken"
::Sh... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/hooks/action_mailer.rb | Ruby | mit | 201 | main | 585 | # frozen_string_literal: true
module Appsignal
class Hooks
# @!visibility private
class ActionMailerHook < Appsignal::Hooks::Hook
register :action_mailer
def dependencies_present?
defined?(::ActionMailer)
end
def install
ActiveSupport::Notifications
.subscr... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/hooks/http.rb | Ruby | mit | 201 | main | 823 | # frozen_string_literal: true
module Appsignal
class Hooks
# @!visibility private
class HttpHook < Appsignal::Hooks::Hook
register :http_rb
def self.http6_or_higher?
Gem::Version.new(HTTP::VERSION) >= Gem::Version.new("6.0.0")
end
def dependencies_present?
defined?(H... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/hooks/que.rb | Ruby | mit | 201 | main | 502 | # frozen_string_literal: true
module Appsignal
class Hooks
# @!visibility private
class QueHook < Appsignal::Hooks::Hook
register :que
def dependencies_present?
defined?(::Que::Job)
end
def install
require "appsignal/integrations/que"
::Que::Job.prepend Appsi... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/hooks/resque.rb | Ruby | mit | 201 | main | 394 | # frozen_string_literal: true
module Appsignal
class Hooks
# @!visibility private
class ResqueHook < Appsignal::Hooks::Hook
register :resque
def dependencies_present?
defined?(::Resque)
end
def install
require "appsignal/integrations/resque"
Resque::Job.prepe... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/hooks/webmachine.rb | Ruby | mit | 201 | main | 430 | # frozen_string_literal: true
module Appsignal
class Hooks
# @!visibility private
class WebmachineHook < Appsignal::Hooks::Hook
register :webmachine
def dependencies_present?
defined?(::Webmachine)
end
def install
require "appsignal/integrations/webmachine"
:... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/hooks/celluloid.rb | Ruby | mit | 201 | main | 768 | # frozen_string_literal: true
module Appsignal
class Hooks
# @!visibility private
class CelluloidHook < Appsignal::Hooks::Hook
register :celluloid
def dependencies_present?
defined?(::Celluloid)
end
def install
# Some versions of Celluloid have race conditions while ... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/hooks/dry_monitor.rb | Ruby | mit | 201 | main | 453 | # frozen_string_literal: true
module Appsignal
class Hooks
# @!visibility private
class DryMonitorHook < Appsignal::Hooks::Hook
register :dry_monitor
def dependencies_present?
defined?(::Dry::Monitor::Notifications)
end
def install
require "appsignal/integrations/dry... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/hooks/passenger.rb | Ruby | mit | 201 | main | 521 | # frozen_string_literal: true
module Appsignal
class Hooks
# @!visibility private
class PassengerHook < Appsignal::Hooks::Hook
register :passenger
def dependencies_present?
defined?(::PhusionPassenger)
end
def install
::PhusionPassenger.on_event(:starting_worker_proc... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/hooks/excon.rb | Ruby | mit | 201 | main | 423 | # frozen_string_literal: true
module Appsignal
class Hooks
# @!visibility private
class ExconHook < Appsignal::Hooks::Hook
register :excon
def dependencies_present?
Appsignal.config && defined?(::Excon)
end
def install
require "appsignal/integrations/excon"
:... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/hooks/mri.rb | Ruby | mit | 201 | main | 338 | # frozen_string_literal: true
module Appsignal
class Hooks
# @!visibility private
class MriHook < Appsignal::Hooks::Hook
register :mri
def dependencies_present?
defined?(::RubyVM)
end
def install
Appsignal::Probes.register :mri, Appsignal::Probes::MriProbe
end
... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/hooks/net_http.rb | Ruby | mit | 201 | main | 517 | # frozen_string_literal: true
require "net/http"
module Appsignal
class Hooks
# @!visibility private
class NetHttpHook < Appsignal::Hooks::Hook
register :net_http
def dependencies_present?
Appsignal.config && Appsignal.config[:instrument_net_http]
end
def install
re... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/hooks/code_ownership.rb | Ruby | mit | 201 | main | 632 | # frozen_string_literal: true
module Appsignal
class Hooks
# @!visibility private
class CodeOwnershipHook < Appsignal::Hooks::Hook
register :code_ownership
def dependencies_present?
defined?(::CodeOwnership) &&
Appsignal.config && Appsignal.config[:instrument_code_ownership]
... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/hooks/action_cable.rb | Ruby | mit | 201 | main | 4,015 | # frozen_string_literal: true
module Appsignal
class Hooks
# @!visibility private
class ActionCableHook < Appsignal::Hooks::Hook
register :action_cable
REQUEST_ID = "_appsignal_action_cable.request_id"
def dependencies_present?
defined?(::ActiveSupport::Notifications::Instrumenter... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/hooks/delayed_job.rb | Ruby | mit | 201 | main | 563 | # frozen_string_literal: true
module Appsignal
class Hooks
# @!visibility private
class DelayedJobHook < Appsignal::Hooks::Hook
register :delayed_job
def dependencies_present?
defined?(::Delayed::Plugin)
end
def install
# The DJ plugin is a subclass of Delayed::Plugi... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/hooks/rake.rb | Ruby | mit | 201 | main | 391 | # frozen_string_literal: true
module Appsignal
class Hooks
# @!visibility private
class RakeHook < Appsignal::Hooks::Hook
register :rake
def dependencies_present?
defined?(::Rake::Task)
end
def install
require "appsignal/integrations/rake"
::Rake::Task.prepen... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/hooks/redis_client.rb | Ruby | mit | 201 | main | 878 | # frozen_string_literal: true
module Appsignal
class Hooks
# @!visibility private
class RedisClientHook < Appsignal::Hooks::Hook
register :redis_client
def dependencies_present?
defined?(::RedisClient) &&
Gem::Version.new(::RedisClient::VERSION) >= Gem::Version.new("0.14.0") &&... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/hooks/active_job.rb | Ruby | mit | 201 | main | 6,378 | # frozen_string_literal: true
module Appsignal
class Hooks
# @!visibility private
class ActiveJobHook < Appsignal::Hooks::Hook
register :active_job
def self.version_7_1_or_higher?
@version_7_1_or_higher ||=
if dependencies_present?
major = ::ActiveJob::VERSION::MAJO... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/hooks/ownership.rb | Ruby | mit | 201 | main | 1,656 | # frozen_string_literal: true
module Appsignal
class Hooks
# @!visibility private
class OwnershipHook < Appsignal::Hooks::Hook
register :ownership
def dependencies_present?
defined?(::Ownership) &&
Gem::Version.new(::Ownership::VERSION) >= Gem::Version.new("0.2.0") &&
... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/hooks/at_exit.rb | Ruby | mit | 201 | main | 1,891 | # frozen_string_literal: true
module Appsignal
class Hooks
# @!visibility private
class AtExit < Appsignal::Hooks::Hook
register :at_exit
def dependencies_present?
true
end
def install
Kernel.at_exit(&AtExitCallback.method(:call))
end
# Stop AppSignal be... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/hooks/sidekiq.rb | Ruby | mit | 201 | main | 1,329 | # frozen_string_literal: true
module Appsignal
class Hooks
# @!visibility private
class SidekiqHook < Appsignal::Hooks::Hook
register :sidekiq
def self.version_5_1_or_higher?
@version_5_1_or_higher ||=
if dependencies_present?
Gem::Version.new(::Sidekiq::VERSION) >=... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/hooks/puma.rb | Ruby | mit | 201 | main | 733 | # frozen_string_literal: true
module Appsignal
class Hooks
# @!visibility private
class PumaHook < Appsignal::Hooks::Hook
register :puma
def dependencies_present?
defined?(::Puma) &&
Gem::Version.new(Puma::Const::VERSION) >= Gem::Version.new("3.0.0")
end
def instal... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/hooks/active_support_event_reporter.rb | Ruby | mit | 201 | main | 644 | # frozen_string_literal: true
module Appsignal
class Hooks
# @!visibility private
class ActiveSupportEventReporterHook < Appsignal::Hooks::Hook
register :active_support_event_reporter
def dependencies_present?
defined?(::Rails) &&
defined?(::ActiveSupport::EventReporter) &&
... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/hooks/mongo_ruby_driver.rb | Ruby | mit | 201 | main | 522 | # frozen_string_literal: true
module Appsignal
class Hooks
# @!visibility private
class MongoRubyDriverHook < Appsignal::Hooks::Hook
register :mongo_ruby_driver
def dependencies_present?
defined?(::Mongo::Monitoring::Global)
end
def install
require "appsignal/integra... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/hooks/gvl.rb | Ruby | mit | 201 | main | 679 | # frozen_string_literal: true
module Appsignal
class Hooks
# @!visibility private
class GvlHook < Appsignal::Hooks::Hook
register :gvl
def dependencies_present?
return false if Appsignal::System.jruby?
require "gvltools"
Appsignal.config && Appsignal::Probes::GvlProbe.de... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/cli/install.rb | Ruby | mit | 201 | main | 13,867 | # frozen_string_literal: true
require "erb"
require "io/console"
require "appsignal/demo"
module Appsignal
class CLI
class Install
extend CLI::Helpers
EXCLUDED_ENVIRONMENTS = ["test"].freeze
class << self
def run(push_api_key, options) # rubocop:disable Metrics/AbcSize
self... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/cli/demo.rb | Ruby | mit | 201 | main | 2,489 | # frozen_string_literal: true
require "appsignal/demo"
module Appsignal
class CLI
# Command line tool for sending demonstration samples to AppSignal.com
#
# This command line tool is useful when testing AppSignal on a system and
# validating the local configuration. It tests if the installation of
... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/cli/diagnose.rb | Ruby | mit | 201 | main | 23,605 | # frozen_string_literal: true
require "rbconfig"
require "etc"
require "appsignal/cli/diagnose/utils"
require "appsignal/cli/diagnose/paths"
module Appsignal
class CLI
# Command line tool to run diagnostics on your project.
#
# This command line tool is useful when testing AppSignal on a system and
... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/cli/helpers.rb | Ruby | mit | 201 | main | 1,745 | # frozen_string_literal: true
require "appsignal/utils/rails_helper"
module Appsignal
class CLI
module Helpers
private
COLOR_CODES = {
:red => 31,
:green => 32,
:yellow => 33,
:blue => 34,
:pink => 35,
:default => 0
}.freeze
def coloring=... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/cli/diagnose/paths.rb | Ruby | mit | 201 | main | 3,337 | # frozen_string_literal: true
module Appsignal
class CLI
class Diagnose
class Paths
BYTES_TO_READ_FOR_FILES = 2 * 1024 * 1024 # 2 Mebibytes
def report
{}.tap do |hash|
paths.each do |filename, config|
hash[filename] = path_stat(config[:path])
... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/cli/diagnose/utils.rb | Ruby | mit | 201 | main | 1,152 | # frozen_string_literal: true
module Appsignal
class CLI
class Diagnose
class Utils
def self.username_for_uid(uid)
passwd_struct = Etc.getpwuid(uid)
return unless passwd_struct
passwd_struct.name
rescue ArgumentError # rubocop:disable Lint/SuppressedException
... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/helpers/instrumentation.rb | Ruby | mit | 201 | main | 34,316 | # frozen_string_literal: true
module Appsignal
module Helpers
module Instrumentation
# Monitor a block of code with AppSignal.
#
# This is a helper to create an AppSignal transaction, track any errors
# that may occur and complete the transaction.
#
# This helper is recommende... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/helpers/metrics.rb | Ruby | mit | 201 | main | 2,741 | # frozen_string_literal: true
module Appsignal
module Helpers
module Metrics
# Report a gauge metric.
#
# @since 2.6.0
# @param name [String, Symbol] The name of the metric.
# @param value [Integer, Float] The value of the metric.
# @param tags [Hash<String, Object>] The tags ... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/event_formatter/elastic_search/search_formatter.rb | Ruby | mit | 201 | main | 872 | # frozen_string_literal: true
module Appsignal
class EventFormatter
# @!visibility private
module ElasticSearch
class SearchFormatter
def format(payload)
[
"#{payload[:name]}: #{payload[:klass]}",
sanitized_search(payload[:search]).inspect
]
e... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/event_formatter/view_component/render_formatter.rb | Ruby | mit | 201 | main | 678 | # frozen_string_literal: true
module Appsignal
class EventFormatter
# @!visibility private
module ViewComponent
class RenderFormatter
BLANK = ""
def format(payload)
[payload[:name], payload[:identifier].sub(root_path, BLANK)]
end
def root_path
@root... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/event_formatter/active_record/instantiation_formatter.rb | Ruby | mit | 201 | main | 401 | # frozen_string_literal: true
module Appsignal
class EventFormatter
# @!visibility private
module ActiveRecord
class InstantiationFormatter
def format(payload)
[payload[:class_name], nil]
end
end
end
end
end
Appsignal::EventFormatter.register(
"instantiation.act... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/event_formatter/active_record/sql_formatter.rb | Ruby | mit | 201 | main | 392 | # frozen_string_literal: true
module Appsignal
class EventFormatter
# @!visibility private
module ActiveRecord
class SqlFormatter
def format(payload)
[payload[:name], payload[:sql], SQL_BODY_FORMAT]
end
end
end
end
end
Appsignal::EventFormatter.register(
"sql.ac... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/event_formatter/rom/sql_formatter.rb | Ruby | mit | 201 | main | 377 | # frozen_string_literal: true
module Appsignal
class EventFormatter
# @!visibility private
module Rom
class SqlFormatter
def format(payload)
["query.#{payload[:name]}", payload[:query], SQL_BODY_FORMAT]
end
end
end
end
end
Appsignal::EventFormatter.register(
"sq... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/event_formatter/mongo_ruby_driver/query_formatter.rb | Ruby | mit | 201 | main | 2,247 | # frozen_string_literal: true
module Appsignal
class EventFormatter
# @!visibility private
module MongoRubyDriver
class QueryFormatter
ALLOWED = {
"find" => {
"find" => :allow,
"filter" => :sanitize_document
},
"count" => {
"coun... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/event_formatter/action_view/render_formatter.rb | Ruby | mit | 201 | main | 718 | # frozen_string_literal: true
module Appsignal
class EventFormatter
# @!visibility private
module ActionView
class RenderFormatter
BLANK = ""
def format(payload)
return nil unless payload[:identifier]
[payload[:identifier].sub(root_path, BLANK), nil]
end
... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/event_formatter/faraday/request_formatter.rb | Ruby | mit | 201 | main | 562 | # frozen_string_literal: true
module Appsignal
class EventFormatter
# @!visibility private
module Faraday
class RequestFormatter
def format(payload)
http_method = payload[:method].to_s.upcase
uri = payload[:url]
[
"#{http_method} #{uri.scheme}://#{uri.h... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/event_formatter/sequel/sql_formatter.rb | Ruby | mit | 201 | main | 688 | # frozen_string_literal: true
module Appsignal
class EventFormatter
# @!visibility private
module Sequel
# Compatibility with the sequel-rails gem.
# The sequel-rails gem adds its own ActiveSupport::Notifications events
# that conflict with our own sequel instrumentor. Without this event
... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/extension/jruby.rb | Ruby | mit | 201 | main | 20,034 | # frozen_string_literal: true
require "ffi"
module Appsignal
class Extension
# JRuby extension wrapper
#
# Only loaded if the system is detected as JRuby.
#
# @api private
module Jruby
extend FFI::Library
# JRuby extension String helpers.
#
# Based on the make_appsig... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/utils/integration_memory_logger.rb | Ruby | mit | 201 | main | 1,381 | # frozen_string_literal: true
require "logger"
module Appsignal
module Utils
class IntegrationMemoryLogger
LEVELS = {
Logger::DEBUG => :DEBUG,
Logger::INFO => :INFO,
Logger::WARN => :WARN,
Logger::ERROR => :ERROR,
Logger::FATAL => :FATAL,
Logger::UNKNOWN => ... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/utils/sample_data_sanitizer.rb | Ruby | mit | 201 | main | 2,634 | # frozen_string_literal: true
module Appsignal
module Utils
class SampleDataSanitizer
FILTERED = "[FILTERED]"
RECURSIVE = "[RECURSIVE VALUE]"
class << self
def sanitize(value, filter_keys = [])
sanitize_value(value, filter_keys, [])
end
private
def s... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/utils/rails_helper.rb | Ruby | mit | 201 | main | 627 | # frozen_string_literal: true
module Appsignal
module Utils
module RailsHelper
def self.detected_rails_app_name
rails_class = Rails.application.class
if rails_class.respond_to? :module_parent_name # Rails 6
rails_class.module_parent_name
else # Older Rails versions
... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/utils/integration_logger.rb | Ruby | mit | 201 | main | 802 | # frozen_string_literal: true
module Appsignal
module Utils
class IntegrationLogger < ::Logger
MAX_MESSAGE_LENGTH = 2_000
def add(severity, message = nil, progname = nil)
if message.nil? && !block_given?
# When called as logger.error("msg"), the message is in progname
pro... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/utils/stdout_and_logger_message.rb | Ruby | mit | 201 | main | 439 | # frozen_string_literal: true
module Appsignal
module Utils
module StdoutAndLoggerMessage
def self.warning(message, logger = Appsignal.internal_logger)
Kernel.warn "appsignal WARNING: #{message}"
logger.warn message
end
def stdout_and_logger_warning(message, logger = Appsignal.... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/utils/ndjson.rb | Ruby | mit | 201 | main | 277 | # frozen_string_literal: true
module Appsignal
module Utils
class NDJSON
class << self
def generate(body)
body.map do |element|
Appsignal::Utils::JSON.generate(element)
end.join("\n")
end
end
end
end
end |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/utils/query_params_sanitizer.rb | Ruby | mit | 201 | main | 1,452 | # frozen_string_literal: true
module Appsignal
module Utils
class QueryParamsSanitizer
REPLACEMENT_KEY = "?"
module ClassMethods
def sanitize(params, only_top_level = false, key_sanitizer = nil)
case params
when Hash
sanitize_hash params, only_top_level, key_s... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/utils/data.rb | Ruby | mit | 201 | main | 2,423 | # frozen_string_literal: true
module Appsignal
module Utils
class Data
class << self
def generate(body)
if body.is_a?(Hash)
map_hash(body)
elsif body.is_a?(Array)
map_array(body)
else
raise TypeError, "Body of type #{body.class} shou... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/utils/json.rb | Ruby | mit | 201 | main | 839 | # frozen_string_literal: true
module Appsignal
module Utils
class JSON
class << self
def generate(body)
::JSON.generate(jsonify(body))
end
private
def jsonify(value)
case value
when String
encode_utf8(value)
when Numeric,... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/loaders/grape.rb | Ruby | mit | 201 | main | 215 | # frozen_string_literal: true
module Appsignal
module Loaders
class GrapeLoader < Loader
register :grape
def on_load
require "appsignal/rack/grape_middleware"
end
end
end
end |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/loaders/sinatra.rb | Ruby | mit | 201 | main | 577 | # frozen_string_literal: true
module Appsignal
module Loaders
class SinatraLoader < Loader
register :sinatra
def on_load
app_settings = ::Sinatra::Application.settings
register_config_defaults(
:root_path => app_settings.root,
:env => app_settings.environment
... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/loaders/padrino.rb | Ruby | mit | 201 | main | 2,285 | # frozen_string_literal: true
module Appsignal
module Loaders
class PadrinoLoader < Loader
register :padrino
def on_load
register_config_defaults(
:root_path => Padrino.mounted_root,
:env => Padrino.env
)
end
def on_start
require "appsignal/ra... |
github | appsignal/appsignal-ruby | https://github.com/appsignal/appsignal-ruby | lib/appsignal/loaders/hanami.rb | Ruby | mit | 201 | main | 1,265 | # frozen_string_literal: true
module Appsignal
module Loaders
class HanamiLoader < Loader
register :hanami
def on_load
hanami_app_config = ::Hanami.app.config
register_config_defaults(
:root_path => hanami_app_config.root.to_s,
:env => hanami_app_config.env,
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.