Skip to content
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

Merged
merged 12 commits into from
Sep 5, 2024
Merged

Instrument sequel gem #414

merged 12 commits into from
Sep 5, 2024

Conversation

arjun-rajappa
Copy link
Contributor

Instrument sequel gem

@@ -0,0 +1,21 @@
# (c) Copyright IBM Corp. 2021
# (c) Copyright Instana Inc. 2021
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed!

@@ -0,0 +1,21 @@
# (c) Copyright IBM Corp. 2021
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2024!!!

Copy link
Contributor Author

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)
Copy link
Contributor

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
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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]>
@@ -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 }
Copy link
Contributor

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]>
Copy link
Contributor

@Ferenc- Ferenc- left a 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.

@arjun-rajappa arjun-rajappa merged commit b8e2bdb into master Sep 5, 2024
223 of 224 checks passed
@arjun-rajappa arjun-rajappa deleted the instrument-sequel-gem branch September 5, 2024 08:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants