-
Notifications
You must be signed in to change notification settings - Fork 3
NH-94970: dbo integration for psql #170
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
13ef6f2
NH-94970: pg trace context injection
xuan-cao-swi c7e394f
Merge branch 'main' of github.com:solarwinds/apm-ruby into NH-94970
xuan-cao-swi ff8a004
NH-94970: init commit for dbo psql
xuan-cao-swi 77162dd
Merge branch 'main' of github.com:solarwinds/apm-ruby into NH-94970
xuan-cao-swi 2eb54f6
NH-94970: remove marginalia code and add psql patch for dbo
xuan-cao-swi f437a0d
Update CONFIGURATION.md
xuan-cao-swi 8dee21c
revision
xuan-cao-swi cf57a1b
Merge branch 'NH-94970' of github.com:solarwinds/apm-ruby into NH-94970
xuan-cao-swi bf25205
replace link check tool to linkspector
xuan-cao-swi 8c3d3b1
Update lib/solarwinds_apm/patch/tag_sql/sw_pg_patch.rb
xuan-cao-swi bb94f93
add test for block case
xuan-cao-swi 2b20db6
Merge branch 'NH-94970' of github.com:solarwinds/apm-ruby into NH-94970
xuan-cao-swi 879e8ee
lint
xuan-cao-swi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright The OpenTelemetry Authors | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
module SolarWindsAPM | ||
module Patch | ||
module TagSql | ||
module SWODboUtils | ||
def self.annotate_span_and_sql(sql) | ||
return sql if sql.to_s.empty? | ||
|
||
current_span = ::OpenTelemetry::Trace.current_span | ||
|
||
annotated_sql = '' | ||
if current_span.context.trace_flags.sampled? | ||
traceparent = SolarWindsAPM::Utils.traceparent_from_context(current_span.context) | ||
annotated_traceparent = "/*traceparent='#{traceparent}'*/" | ||
current_span.add_attributes({ 'sw.query_tag' => annotated_traceparent }) | ||
annotated_sql = "#{sql} #{annotated_traceparent}" | ||
cheempz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
else | ||
annotated_sql = sql | ||
end | ||
|
||
SolarWindsAPM.logger.debug { "[#{self.class}/#{__method__}] annotated_sql: #{annotated_sql}" } | ||
annotated_sql | ||
rescue StandardError => e | ||
SolarWindsAPM.logger.error { "[#{self.class}/#{__method__}] Failed to annotated sql. Error: #{e.message}" } | ||
sql | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright The OpenTelemetry Authors | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
module SolarWindsAPM | ||
module Patch | ||
module TagSql | ||
module SWOPgPatch | ||
cheempz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# We target operations covered by the upstream pg instrumentation. | ||
# These are all alike in that they will have a SQL | ||
xuan-cao-swi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# statement as the first parameter, and they are all | ||
# non-prepared statement execute. | ||
EXEC_ISH_METHODS = %i[ | ||
exec | ||
query | ||
sync_exec | ||
async_exec | ||
exec_params | ||
async_exec_params | ||
sync_exec_params | ||
].freeze | ||
|
||
EXEC_ISH_METHODS.each do |method| | ||
define_method method do |*args| | ||
annotated_sql = ::SolarWindsAPM::Patch::TagSql::SWODboUtils.annotate_span_and_sql(args[0]) | ||
args[0] = annotated_sql | ||
super(*args) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
# need to prepend before pg instrumentation patch itself | ||
# upstream instrumentation -> our patch -> original function | ||
PG::Connection.prepend(SolarWindsAPM::Patch::TagSql::SWOPgPatch) if defined?(PG::Connection) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.