-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1028 from jbockler/redis-client-support
Add redis-client support
- Loading branch information
Showing
13 changed files
with
543 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
bump: "patch" | ||
type: "add" | ||
--- | ||
|
||
Add support for the `redis-client` gem, which is used by the redis gem since version 5. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -239,3 +239,5 @@ matrix: | |
- gem: "sinatra" | ||
- gem: "webmachine1" | ||
- gem: "webmachine2" | ||
- gem: "redis-4" | ||
- gem: "redis-5" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
source 'https://rubygems.org' | ||
|
||
gem 'redis', "~> 4.0" | ||
|
||
gemspec :path => '../' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
source 'https://rubygems.org' | ||
|
||
gem 'redis', '~> 5.0' | ||
gem 'hiredis-client' | ||
|
||
gemspec :path => '../' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
module Appsignal | ||
class Hooks | ||
# @api private | ||
class RedisClientHook < Appsignal::Hooks::Hook | ||
register :redis_client | ||
|
||
def dependencies_present? | ||
defined?(::RedisClient) && | ||
Appsignal.config && | ||
Appsignal.config[:instrument_redis] | ||
end | ||
|
||
def install | ||
require "appsignal/integrations/redis_client" | ||
::RedisClient::RubyConnection.prepend Appsignal::Integrations::RedisClientIntegration | ||
Appsignal::Environment.report_enabled("redis") | ||
|
||
return unless defined?(::RedisClient::HiredisConnection) | ||
|
||
::RedisClient::HiredisConnection.prepend Appsignal::Integrations::RedisClientIntegration | ||
Appsignal::Environment.report_enabled("hiredis") | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
module Appsignal | ||
module Integrations | ||
module RedisClientIntegration | ||
def write(command) | ||
sanitized_command = | ||
if command[0] == :eval | ||
"#{command[1]}#{" ?" * (command.size - 3)}" | ||
else | ||
"#{command[0]}#{" ?" * (command.size - 1)}" | ||
end | ||
|
||
Appsignal.instrument "query.redis", @config.id, sanitized_command do | ||
super | ||
end | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.