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

Add abilty to hide db.statement in opentelemetry_redix #189

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

tomtaylor
Copy link
Contributor

It's not always necessary/desired to include this attribute, especially as in some cases it can be very long.

@andrewhr
Copy link
Contributor

andrewhr commented Aug 7, 2023

This is defined on documentation as a recommended attribute. Do you have examples of other libraries (java, node, ruby etc) that could optionally remove it?

Also, is this causing issues? For example, Ecto statements tends to be even bigger than (most) Redis, still there is no configuration to opt-out this attribute.

Sorry to push back a bit like that, just want to understand more the use case and keep as consistent as possible with prior art from OTEL community.

Thanks in advance @tomtaylor!

@tsloughter
Copy link
Member

The docs actually say it should only be collected if the statement is sanitized.

I forget where we are at with Ecto but it should not be collected by default because we do not sanitize.

@tsloughter
Copy link
Member

Ah right, its in, #166

@tomtaylor
Copy link
Contributor Author

I’m away at the moment without my laptop, but a cursory look showed me that the Ecto instrumentation supports a custom sanitiser as mentioned in #166. The Ruby Redis library supports something similar.

Our example is that we do a KEYS request for a lot of very long patterns at a regular interval, and this is logged verbatim.

Happy to turn this PR into a custom sanitiser if that’s what’s commonly implemented across multiple languages and there’s prior art in Elixir. Does that seem like a better approach?

@tsloughter
Copy link
Member

@tomtaylor yup, that'd be great

@andrewhr
Copy link
Contributor

@tomtaylor @tsloughter just a heads up, I'm on finishing points with a mongo instrumentation and following that same pattern, with a :disabled, :plain, :obfuscated (basic sanitization) and custom fun options.

Sounds like a good plan to me!

@tsloughter
Copy link
Member

@tomtaylor any update on the switch to a function from a boolean?

@tomtaylor
Copy link
Contributor Author

I haven't had time to dig into this yet. Happy for someone else to chip it in, or I'll try and get to it when I've got a bit of time.

It's not always necessary/desired to include this attribute, especially as in
some cases it can be very long.
This has introduced a breaking change, by moving from a boolean config to
`:enabled`, `:disabled`, `function/1` as the config options for `db_statement`.
@tomtaylor tomtaylor force-pushed the redix-ability-to-hide-db-statement branch from f6b7993 to bd2ec4d Compare April 22, 2024 13:12
@tomtaylor
Copy link
Contributor Author

@tsloughter I've just sorted this and moved from a boolean config option to :enabled, :disabled or a single arity function, to mimics how the Ecto instrumentation behaves.


You may also supply the following options:

* `db_statement` - `:enabled`, `:disabled` or a single arity function. If
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit:

Suggested change
* `db_statement` - `:enabled`, `:disabled` or a single arity function. If
* `:db_statement` - `:enabled`, `:disabled` or a single arity function. If

@@ -27,19 +27,30 @@ defmodule OpentelemetryRedix do

@doc """
Initializes and configures the telemetry handlers.

You may also supply the following options:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My suggestion: I would either go with :sanitized_and_logged | :not_logged | fun, or just true | false | fun.

* `db_statement` - `:enabled`, `:disabled` or a single arity function. If
`:enabled`, the DB statement is sanitized of sensitive values, such as
AUTH crendentials, but otherwise logged. If `:disabled`, the statement is
not logged. If you pass in a single arity function, the list of commands
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My suggestion is to have a type for the function to point to and document better. For example:

@type db_statement_fun() :: (Redix.command() -> String.t())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants