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!: obfuscation for mysql2, dalli and postgresql as default option for db_statement #682

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions instrumentation/dalli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,22 @@ OpenTelemetry::SDK.configure do |c|
end
```

### Configuration options

```ruby
OpenTelemetry::SDK.configure do |c|
c.use 'OpenTelemetry::Instrumentation::Dalli', {
# You may optionally set a value for 'peer.service', which
# will be included on all spans from this instrumentation:
peer_service: '',

# The obfuscation of query in the db.statement attribute is enabled by default.
# To disable, set db_statement to :include; to omit the query completely, set db_statement to :omit
db_statement: :include,
}
end
```

## How can I get involved?

The `opentelemetry-instrumentation-dalli` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Instrumentation < OpenTelemetry::Instrumentation::Base
end

option :peer_service, default: nil, validate: :string
option :db_statement, default: :include, validate: %I[omit obfuscate include]
option :db_statement, default: :obfuscate, validate: %I[omit obfuscate include]

private

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

describe 'tracing' do
before do
instrumentation.install
instrumentation.install(db_statement: :include)
end

it 'accepts peer service name from config' do
Expand Down
6 changes: 3 additions & 3 deletions instrumentation/mysql2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ end
```ruby
OpenTelemetry::SDK.configure do |c|
c.use 'OpenTelemetry::Instrumentation::Mysql2', {
# The obfuscation of SQL in the db.statement attribute is disabled by default.
# To enable, set db_statement to :obfuscate.
db_statement: :obfuscate,
# The obfuscation of SQL in the db.statement attribute is enabled by default.
# To disable, set db_statement to :include; to omit the query completely, set db_statement to :omit
db_statement: :include,
}
end
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Instrumentation < OpenTelemetry::Instrumentation::Base
end

option :peer_service, default: nil, validate: :string
option :db_statement, default: :include, validate: %I[omit include obfuscate]
option :db_statement, default: :obfuscate, validate: %I[omit include obfuscate]
option :span_name, default: :statement_type, validate: %I[statement_type db_name db_operation_and_name]
option :obfuscation_limit, default: 2000, validate: :integer

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
let(:instrumentation) { OpenTelemetry::Instrumentation::Mysql2::Instrumentation.instance }
let(:exporter) { EXPORTER }
let(:span) { exporter.finished_spans.first }
let(:config) { {} }
let(:config) { { db_statement: :include } }

before do
exporter.reset
Expand Down
4 changes: 2 additions & 2 deletions instrumentation/pg/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ OpenTelemetry::SDK.configure do |c|
# will be included on all spans from this instrumentation:
peer_service: 'postgres:readonly',

# By default, this instrumentation includes the executed SQL as the `db.statement`
# By default, this instrumentation obfuscate/sanitize the executed SQL as the `db.statement`
# semantic attribute. Optionally, you may disable the inclusion of this attribute entirely by
# setting this option to :omit or sanitize the attribute by setting to :obfuscate
# setting this option to :omit or disbale sanitization the attribute by setting to :include
db_statement: :include,
}
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Instrumentation < OpenTelemetry::Instrumentation::Base
end

option :peer_service, default: nil, validate: :string
option :db_statement, default: :include, validate: %I[omit include obfuscate]
option :db_statement, default: :obfuscate, validate: %I[omit include obfuscate]
option :obfuscation_limit, default: 2000, validate: :integer

private
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
let(:user) { ENV.fetch('TEST_POSTGRES_USER', 'postgres') }
let(:dbname) { ENV.fetch('TEST_POSTGRES_DB', 'postgres') }
let(:password) { ENV.fetch('TEST_POSTGRES_PASSWORD', 'postgres') }

let(:config) { { db_statement: :include } }
before do
instrumentation.install(config)
end
Expand Down
Loading