-
Notifications
You must be signed in to change notification settings - Fork 179
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: Support prepend SQL comment for PG instrumentation #690
Changes from 2 commits
676425c
d9bf281
031fdca
ca71e53
063ccad
515df0d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,7 +111,9 @@ def span_attrs(kind, *args) | |
|
||
def extract_operation(sql) | ||
# From: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/9244a08a8d014afe26b82b91cf86e407c2599d73/plugins/node/opentelemetry-instrumentation-pg/src/utils.ts#L35 | ||
sql.to_s.split[0].to_s.upcase | ||
# Ignores prepend comment | ||
comment_regex = %r{\A\/\*.*?\*\/}m | ||
sql.to_s.sub(comment_regex, '').split[0].to_s.upcase | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To confirm, we are only interested in removing the first set of long form comments (without newlines) like those generated in SQL Commenter format. We are also not concerned about inline comments Is that correct? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's my understanding since the goal of this method is to grab the operation (ex. |
||
end | ||
|
||
def span_name(operation) | ||
|
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.
Would it make sense to move this into constant?
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 concur with @simi
@keiko713 Please extract this regex into a constant to avoid allocating it for every query.
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.
TIL Ruby freezes Regexes like it freezes strings.
Running a file named
foo.rb
with the following ruby code:has this result:
So I'm going to merge this in without moving it to a constant.