Commit Graph

12 Commits

Author SHA1 Message Date
Nimrod Shlagman 37d85f0745
Sanitize redis db_statement by default (#1776)
Co-authored-by: Srikanth Chekuri <srikanth.chekuri92@gmail.com>
Co-authored-by: Shalev Roda <65566801+shalevr@users.noreply.github.com>
2023-06-13 12:37:55 +00:00
danielwiltshire 0417141a70
Add support for enabling Redis sanitization from environment variable (#1690)
* Add support for enabling Redis sanitization from environment variable

* add sanitization environment variable docs

* strip environment variable

* update changelog

* lint

* lint

* lint - hopefully the last time

---------

Co-authored-by: Srikanth Chekuri <srikanth.chekuri92@gmail.com>
2023-02-25 01:27:31 +00:00
Tom de Bruijn 2b6f913790
Add Redis instrumentation query sanitization (#1572)
* Add Redis instrumentation query sanitization

Add a query sanitizer to the Redis instrumentation. This can be disabled
with the `sanitize_query = False` config option.

Given the query `SET key value`, the sanitized query becomes `SET ? ?`.
Both the keys and values are sanitized, as both can contain PII data.

The Redis queries are sanitized by default. This changes the default
behavior of this instrumentation. Previously it reported unsanitized
Redis queries.

This was previously discussed in the previous implementation of this PR
in PR #1571

Closes #1548

* Update Redis sanitize_query option documentation

Changes suggested in
https://github.com/open-telemetry/opentelemetry-python-contrib/pull/1572#discussion_r1066069584

* Remove uninstrument & instrument from test setup

The Redis test that performs the tests with the default options, doesn't
need to uninstrument and then instrument the instrumentor. This commit
removes the unnecessary setup code. The setup code is already present at
the top of the file.

* Fix code style formatting

* Update Redis functional tests

- Update the sanitizer to also account for a max `db.statement`
  attribute value length. No longer than 1000 characters.
- Update the functional tests to assume the queries are sanitized by
  default.
- Add new tests that test the behavior with sanitization turned off.
  Only for the tests in the first test class. I don't think it's needed
  to duplicate this test for the clustered and async setup combinations.

* Test Redis unsanitized queries by default

Change the Redis functional tests so that they test the unsanitized
query by default, and test the sanitized query results in the separate
test functions.

This is a partial revert of the previous commit
8d56c2f72e

* Fix formatting issue in Redis utils

* Disable Redis query sanitization by default

Update the Redis instrumentation library to not change the default
behavior for the Redis instrumentation. This can be enabled at a later
time when the spec discussion about this topic has concluded.

https://github.com/open-telemetry/opentelemetry-specification/issues/3104

* Fix pylint issue

Remove else statement.

* Update changelog about Redis query sanitization default

[ci skip]

Co-authored-by: Srikanth Chekuri <srikanth.chekuri92@gmail.com>

* Fix potential error on Redis args being 0

Check the length of the args array and return an empty string if there
are no args.

That way it won't cause an IndexError if the args array is empty and it
tries to fetch the first element, which should be the Redis command.

---------

Co-authored-by: Srikanth Chekuri <srikanth.chekuri92@gmail.com>
2023-02-04 14:22:23 +00:00
avzis 43d0c6cae3
fix the instantiation of NoOpTracerProvider (#1577) 2023-01-12 17:16:03 +00:00
avzis 494bf0999c
add a test for redis using NoOpTracerProvider (#1559) 2023-01-09 09:15:00 +00:00
Srikanth Chekuri d75194aed7
Sync with sdk setup from setUpClass to setUp (#1193) 2022-07-19 02:02:13 +05:30
ItayGibel-heliosphere db636a462c
adding response_hook to redis instrumentor (#669) 2021-09-14 13:47:12 -07:00
Owais Lone f436514554
Replaced Tracer.use_span() with opentelemetry.trace.use_span() (#364) 2021-03-08 09:33:49 -08:00
Srikanth Chekuri ee90c7e50c Update redis instrumentation to follow semantic conventions 2020-11-15 02:10:34 +05:30
Leighton Chen dfb0621a9b Use is_recording flag in aiopg, asyncpg, dbapi, psycopg2, pymemcache, pymongo, redis, sqlalchemy instrumentations (#1212) 2020-10-21 22:05:37 -07:00
Alec Koumjian aa9f54e769 instrumentation/redis: Change Redis instrument to use SpanKind.CLIENT (#965) 2020-10-21 22:05:37 -07:00
Leighton Chen 2e237cf760 Rename db framework packages from "ext" to "instrumentation" (#966) 2020-10-21 22:05:37 -07:00