Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
marcotc committed Aug 9, 2024
1 parent 8caeadc commit 7739bc9
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 30 deletions.
6 changes: 3 additions & 3 deletions docs/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,7 @@ client.query("SELECT * FROM users WHERE group='x'")
| `service_name` | `DD_TRACE_MYSQL2_SERVICE_NAME` | `String` | Name of application running the `mysql2` instrumentation. May be overridden by `global_default_service_name`. [See _Additional Configuration_ for more details](#additional-configuration) | `mysql2` |
| `peer_service` | `DD_TRACE_MYSQL2_PEER_SERVICE` | `String` | Name of external service the application connects to | `nil` |
| `comment_propagation` | `DD_DBM_PROPAGATION_MODE` | `String` | SQL comment propagation mode for database monitoring. <br />(example: `disabled` \| `service`\| `full`). <br /><br />**Important**: _Note that enabling SQL comment propagation results in potentially confidential data (service names) being stored in the databases which can then be accessed by other third parties that have been granted access to the database._ | `'disabled'` |
| `append_propagation` | | `Bool` | Appends the SQL comment propagation to the query string. Prepends the comment if `false`. For long query strings, the appended propagation comment might be truncated, causing loss of correlation between the query and trace. | `false` |
| `append_comment` | | `Bool` | Appends the SQL comment propagation to the query string. Prepends the comment if `false`. For long query strings, the appended propagation comment might be truncated, causing loss of correlation between the query and trace. | `false` |
| `on_error` | | `Proc` | Custom error handler invoked when MySQL raises an error. Provided `span` and `error` as arguments. Sets error on the span by default. Useful for ignoring errors that are handled at the application level. | `proc { \|span, error\| span.set_error(error) unless span.nil? }` |
### Net/HTTP
Expand Down Expand Up @@ -1273,7 +1273,7 @@ end
| `service_name` | `DD_TRACE_PG_SERVICE_NAME` | `String` | Name of application running the `pg` instrumentation. May be overridden by `global_default_service_name`. [See _Additional Configuration_ for more details](#additional-configuration) | `pg` |
| `peer_service` | `DD_TRACE_PG_PEER_SERVICE` | `String` | Name of external service the application connects to | `nil` |
| `comment_propagation` | `DD_DBM_PROPAGATION_MODE` | `String` | SQL comment propagation mode for database monitoring. <br />(example: `disabled` \| `service`\| `full`). <br /><br />**Important**: _Note that enabling sql comment propagation results in potentially confidential data (service names) being stored in the databases which can then be accessed by other 3rd parties that have been granted access to the database._ | `'disabled'` |
| `append_propagation` | | `Bool` | Appends the SQL comment propagation to the query string. Prepends the comment if `false`. For long query strings, the appended propagation comment might be truncated, causing loss of correlation between the query and trace. | `false` |
| `append_comment` | | `Bool` | Appends the SQL comment propagation to the query string. Prepends the comment if `false`. For long query strings, the appended propagation comment might be truncated, causing loss of correlation between the query and trace. | `false` |
| `on_error` | | `Proc` | Custom error handler invoked when PG raises an error. Provided `span` and `error` as arguments. Sets error on the span by default. Useful for ignoring errors from Postgres that are handled at the application level. | `proc { \|span, error\| span.set_error(error) unless span.nil? }` |
### Presto
Expand Down Expand Up @@ -1993,7 +1993,7 @@ client.query("SELECT * FROM users WHERE group='x'")
| `service_name` | `DD_TRACE_TRILOGY_SERVICE_NAME` | `String` | Name of application running the `trilogy` instrumentation. May be overridden by `global_default_service_name`. [See _Additional Configuration_ for more details](#additional-configuration) | `trilogy` |
| `peer_service` | `DD_TRACE_TRILOGY_PEER_SERVICE` | `String` | Name of external service the application connects to | `nil` |
| `comment_propagation` | `DD_DBM_PROPAGATION_MODE` | `String` | SQL comment propagation mode for database monitoring. <br />(example: `disabled` \| `service`\| `full`). <br /><br />**Important**: _Note that enabling SQL comment propagation results in potentially confidential data (service names) being stored in the databases which can then be accessed by other third parties that have been granted access to the database._ | `'disabled'` |
| `append_propagation` | | `Bool` | Appends the SQL comment propagation to the query string. Prepends the comment if `false`. For long query strings, the appended propagation comment might be truncated, causing loss of correlation between the query and trace. | `false` |
| `append_comment` | | `Bool` | Appends the SQL comment propagation to the query string. Prepends the comment if `false`. For long query strings, the appended propagation comment might be truncated, causing loss of correlation between the query and trace. | `false` |
| `on_error` | | `Proc` | Custom error handler invoked when MySQL raises an error. Provided `span` and `error` as arguments. Sets error on the span by default. Useful for ignoring errors that are handled at the application level. | `proc { \|span, error\| span.set_error(error) unless span.nil? }` |

## Additional configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Settings < Contrib::Configuration::Settings
o.default Contrib::Propagation::SqlComment::Ext::DISABLED
end

option :append do |o|
option :append_comment do |o|
o.type :bool
o.default false
end
Expand Down
2 changes: 1 addition & 1 deletion lib/datadog/tracing/contrib/mysql2/instrumentation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def query(sql, options = {})
def inject_propagation(span, sql, trace_op)
propagation_mode = Contrib::Propagation::SqlComment::Mode.new(
datadog_configuration[:comment_propagation],
datadog_configuration[:append]
datadog_configuration[:append_comment]
)

Contrib::Propagation::SqlComment.annotate!(span, propagation_mode)
Expand Down
2 changes: 1 addition & 1 deletion lib/datadog/tracing/contrib/pg/configuration/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Settings < Contrib::Configuration::Settings
o.default Contrib::Propagation::SqlComment::Ext::DISABLED
end

option :append do |o|
option :append_comment do |o|
o.type :bool
o.default false
end
Expand Down
2 changes: 1 addition & 1 deletion lib/datadog/tracing/contrib/pg/instrumentation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def trace(name, sql: nil, statement_name: nil, block: nil)
if sql
propagation_mode = Contrib::Propagation::SqlComment::Mode.new(
comment_propagation,
datadog_configuration[:append]
datadog_configuration[:append_comment]
)
Contrib::Propagation::SqlComment.annotate!(span, propagation_mode)
propagated_sql_statement = Contrib::Propagation::SqlComment.prepend_comment(
Expand Down
4 changes: 0 additions & 4 deletions lib/datadog/tracing/contrib/propagation/sql_comment/mode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ def full?
mode == Ext::FULL
end

def prepend?
!append
end

def append?
append
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Settings < Contrib::Configuration::Settings
o.default Contrib::Propagation::SqlComment::Ext::DISABLED
end

option :append do |o|
option :append_comment do |o|
o.type :bool
o.default false
end
Expand Down
2 changes: 1 addition & 1 deletion lib/datadog/tracing/contrib/trilogy/instrumentation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def query(sql)
Contrib::SpanAttributeSchema.set_peer_service!(span, Ext::PEER_SERVICE_SOURCES)

propagation_mode = Contrib::Propagation::SqlComment::Mode.new(
comment_propagation, datadog_configuration[:append]
comment_propagation, datadog_configuration[:append_comment]
)

Contrib::Propagation::SqlComment.annotate!(span, propagation_mode)
Expand Down
12 changes: 0 additions & 12 deletions spec/datadog/tracing/contrib/propagation/sql_comment/mode_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,6 @@
end
end

describe '#prepend?' do
[
[false, true],
[true, false]
].each do |value, result|
context "when given `#{value}`" do
subject { described_class.new('full', value).prepend? }
it { is_expected.to be result }
end
end
end

describe '#append?' do
[
[false, false],
Expand Down
6 changes: 3 additions & 3 deletions spec/datadog/tracing/contrib/propagation/sql_comment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

RSpec.describe Datadog::Tracing::Contrib::Propagation::SqlComment do
let(:propagation_mode) { Datadog::Tracing::Contrib::Propagation::SqlComment::Mode.new(mode, append) }
let(:append) { false }
let(:append_comment) { false }

describe '.annotate!' do
let(:span_op) { Datadog::Tracing::SpanOperation.new('sql_comment_propagation_span', service: 'db_service') }
Expand Down Expand Up @@ -47,7 +47,7 @@
end

let(:sql_statement) { 'SELECT 1' }
let(:append) { false }
let(:append_comment) { false }

context 'when tracing is enabled' do
before do
Expand Down Expand Up @@ -156,7 +156,7 @@
end

context 'when append is true' do
let(:append) { true }
let(:append_comment) { true }

it 'appends the comment after the sql statement' do
is_expected.to eq("#{sql_statement} /*dde='dev',ddps='api',ddpv='1.2',dddbs='db_service'*/")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
end

RSpec.shared_examples_for 'propagates with sql comment' do |mode:, span_op_name:, error: nil|
let(:append) { false }
let(:append_comment) { false }

it "propagates with mode: #{mode}" do
expect(Datadog::Tracing::Contrib::Propagation::SqlComment::Mode)
Expand Down Expand Up @@ -75,7 +75,7 @@
end

context 'in append mode' do
let(:append) { true }
let(:append_comment) { true }
let(:configuration_options) { super().merge(append: append) }

it 'appends sql comment to the sql statement' do
Expand Down

0 comments on commit 7739bc9

Please sign in to comment.