-
Notifications
You must be signed in to change notification settings - Fork 226
feat: Instrument PG connect #1763
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
Conversation
d2fc214 to
6d32bf7
Compare
* feat: add instrumentation for connecting to PG
37a50d7 to
950b70a
Compare
arielvalentin
left a comment
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.
Thank you for your contribution. I have left some comments for you to review.
instrumentation/pg/lib/opentelemetry/instrumentation/pg/patches/connection.rb
Show resolved
Hide resolved
instrumentation/pg/lib/opentelemetry/instrumentation/pg/patches/connection.rb
Outdated
Show resolved
Hide resolved
93e6b17 to
ff5c0f4
Compare
ff5c0f4 to
1608d41
Compare
kaylareopelle
left a comment
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.
Thank you for this contribution, @kirs! There's one Rubocop failure on the PG suite to address:
lib/opentelemetry/instrumentation/pg/patches/connection.rb:15:9:
C: Style/Documentation: Missing top-level documentation comment for module
OpenTelemetry::Instrumentation::PG::Patches::ConnectionHelper.
module ConnectionHelper
^^^^^^^^^^^^^^^^^^^^^^^
1608d41 to
4542f03
Compare
|
fixed, thank you! |
| config = OpenTelemetry::Instrumentation::PG::Instrumentation.instance.config | ||
|
|
||
| tracer.in_span('connect', kind: :client) do |span| | ||
| if block_given? |
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.
Just wanted to confirm that there wasn't a way to simply this.
Does the block not get forwarded when calling super?
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.
It does get forwarded, but we want a special path for block_given? to be able to set span attributes.
conn = super
ConnectionHelper.set_connection_attributes(span, conn, config)
conn
^ the above only returns conn when there's no block given. When the block is given, it doesn't "leak" the connection object outside of the block.
4542f03 to
ef9bf74
Compare
It's surprising that we don't do this for PG while we do this for Trilogy. Without this, it's impossible to attribute any time spent establishing the connection.