-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Instrument sequel gem #414
Conversation
b9bf65b
to
e2a0337
Compare
Signed-off-by: arjun-rajappa <[email protected]>
Signed-off-by: arjun-rajappa <[email protected]>
Signed-off-by: arjun-rajappa <[email protected]>
Signed-off-by: arjun-rajappa <[email protected]>
Signed-off-by: arjun-rajappa <[email protected]>
Signed-off-by: arjun-rajappa <[email protected]>
Signed-off-by: arjun-rajappa <[email protected]>
Signed-off-by: arjun-rajappa <[email protected]>
e2a0337
to
9eacd24
Compare
lib/instana/activators/sequel.rb
Outdated
@@ -0,0 +1,21 @@ | |||
# (c) Copyright IBM Corp. 2021 | |||
# (c) Copyright Instana Inc. 2021 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need Instana Inc.
anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed!
lib/instana/activators/sequel.rb
Outdated
@@ -0,0 +1,21 @@ | |||
# (c) Copyright IBM Corp. 2021 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2024
!!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed!
module Activators | ||
class Sequel < Activator | ||
def can_instrument? | ||
defined?(::Sequel::Database) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, tha added option in config.rb
, would be used here already. In fact I don't see anywhere in production code that you read config[:sequel]
.
module Instrumentation | ||
module Sequel | ||
IGNORED_SQL = %w[BEGIN COMMIT SET].freeze | ||
SANITIZE_REGEXP = /('[\s\S][^']*'|\d*\.\d+|\d+|NULL)/i.freeze |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why [\s\S]
over just .
? Do we expect a linebreak here?
In general why is it needed? Why not just the [^']*'
?
Why does NULL
need to be sanitized?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This regex is present in active record. So i copied the same. We sanitise sql so that the ppl viewing the logs might not get the information like PII etc etc. So NULL can be used to filter data. Hence i think we are sanitising NULL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am familiar with the purpose of sanitation. My point is that the string NULL
alone is not a secret, so without further reason, it makes no sense to sanitize it.
And I have also noticed, that active record has this pattern, and I don't think we should randomly copy code without understanding it.
Signed-off-by: Arjun Rajappa <[email protected]>
Signed-off-by: Arjun Rajappa <[email protected]>
Signed-off-by: Arjun Rajappa <[email protected]>
lib/instana/config.rb
Outdated
@@ -73,6 +73,7 @@ def initialize(logger: ::Instana.logger, agent_host: ENV['INSTANA_AGENT_HOST'], | |||
@config[:'resque-client'] = { :enabled => true, :propagate => true } | |||
@config[:'resque-worker'] = { :enabled => true, :'setup-fork' => true } | |||
@config[:'rest-client'] = { :enabled => true } | |||
@config[:sequel] = { :enabled => true } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we align the indentation here?
Signed-off-by: Arjun Rajappa <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. If you can then please fix the indentation in config.rb
and use the new config in the activator.
Instrument sequel gem