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

feat: collect db.collection_name attribute - pg instrumentation #4

Merged
merged 3 commits into from
Jul 25, 2024

Conversation

hannahramadan
Copy link
Owner

No description provided.

Copy link

@kaylareopelle kaylareopelle left a comment

Choose a reason for hiding this comment

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

Great work! ✨ 🦖

@@ -86,11 +86,13 @@ def lru_cache
# module size limit! We can't win here unless we want to start
# abstracting things into a million pieces.
def span_attrs(kind, *args)
text = args[0]

Choose a reason for hiding this comment

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

I've received feedback before discouraging small refactors like this for object allocation concerns. I don't think you need to change anything, just a head's up.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Good to know thank you ◡̈

Comment on lines 109 to 110
collection_name = collection_name(text)
attrs['db.collection.name'] = collection_name unless collection_name.nil?

Choose a reason for hiding this comment

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

Same here. If collection_name is only used to set that value, you might have it recommended to write this as:

attrs['db.collection.name'] = collection_name(text)

Also, the key/value pairs with nil values will get removed on line 112 with attrs.compact!, so it's okay to set the key even if the return value is nil.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Great feedback! I didn't even realize compact! removes nil values.

},
{
"name": "insert_into",
"sql": "INSERT INTO X values('', 'a''b c',0, 1 , 'd''e f''s h')"

Choose a reason for hiding this comment

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

trippy!

# 1. Build the opentelemetry/opentelemetry-ruby-contrib image
# - docker-compose build
# 2. Bundle install
# - docker-compose run ex-instrumentation-pg-test bundle install
# 3. Run test suite
# - docker-compose run ex-instrumentation-pg-test bundle exec rake test
# 3. Install the Appraisal gem (https://github.com/thoughtbot/appraisal)

Choose a reason for hiding this comment

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

The apprasial gem should already be installed from step 2, maybe something like: "Install the dependencies for each Appraisal" or "Install the Appraisals"? I like your link to the gem :)

Copy link
Owner Author

Choose a reason for hiding this comment

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

Yes that is better!

name = test_case['name']
query = test_case['sql']

define_method(:"test_sql_obfuscation_#{name}") do

Choose a reason for hiding this comment

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

I think this might've been a copy-paste miss! Maybe "test_sql_table_name_" instead?

@hannahramadan hannahramadan merged commit 2044213 into main Jul 25, 2024
54 checks passed
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