-
Notifications
You must be signed in to change notification settings - Fork 651
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
DBAPI: Add param to control capturing of db.statement.parameters #1247
Closed
stschenk
wants to merge
9
commits into
open-telemetry:master
from
stschenk:dbapi-skip-params-by-default
Closed
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
0031952
add param to control capturing of db.statement.parameters
stschenk 0d838bd
update change log
stschenk b8268c5
Merge branch 'master' into dbapi-skip-params-by-default
stschenk 097eaf2
Merge branch 'master' into dbapi-skip-params-by-default
stschenk cc1902e
Add parameter to disable collection of db.statement.parameters for DBAPI
stschenk 4a6293a
Set DBAPI default capture of db.statement.parameters to False
stschenk 7373a20
Set DBApiIntegration capture of db.statement.parameters to False
stschenk 32d34bb
Merge branch 'master' into dbapi-skip-params-by-default
stschenk 684ab0b
Merge branch 'master' into dbapi-skip-params-by-default
stschenk 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 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 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 |
---|---|---|
|
@@ -62,6 +62,7 @@ def trace_integration( | |
database_type: str = "", | ||
connection_attributes: typing.Dict = None, | ||
tracer_provider: typing.Optional[TracerProvider] = None, | ||
capture_parameters: bool = False, | ||
): | ||
"""Integrate with DB API library. | ||
https://www.python.org/dev/peps/pep-0249/ | ||
|
@@ -76,6 +77,7 @@ def trace_integration( | |
user in Connection object. | ||
tracer_provider: The :class:`opentelemetry.trace.TracerProvider` to | ||
use. If ommited the current configured one is used. | ||
capture_parameters: Configure if db.statement.parameters should be captured. | ||
""" | ||
wrap_connect( | ||
__name__, | ||
|
@@ -86,6 +88,7 @@ def trace_integration( | |
connection_attributes, | ||
version=__version__, | ||
tracer_provider=tracer_provider, | ||
capture_parameters=capture_parameters, | ||
) | ||
|
||
|
||
|
@@ -98,6 +101,7 @@ def wrap_connect( | |
connection_attributes: typing.Dict = None, | ||
version: str = "", | ||
tracer_provider: typing.Optional[TracerProvider] = None, | ||
capture_parameters: bool = True, | ||
): | ||
"""Integrate with DB API library. | ||
https://www.python.org/dev/peps/pep-0249/ | ||
|
@@ -111,6 +115,8 @@ def wrap_connect( | |
database_type: The Database type. For any SQL database, "sql". | ||
connection_attributes: Attribute names for database, port, host and | ||
user in Connection object. | ||
capture_parameters: Configure if db.statement.parameters should be captured. | ||
|
||
""" | ||
|
||
# pylint: disable=unused-argument | ||
|
@@ -127,6 +133,7 @@ def wrap_connect_( | |
connection_attributes=connection_attributes, | ||
version=version, | ||
tracer_provider=tracer_provider, | ||
capture_parameters=capture_parameters, | ||
) | ||
return db_integration.wrapped_connection(wrapped, args, kwargs) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. makes sense. |
||
|
@@ -211,6 +218,7 @@ def __init__( | |
connection_attributes=None, | ||
version: str = "", | ||
tracer_provider: typing.Optional[TracerProvider] = None, | ||
capture_parameters: bool = True, | ||
): | ||
self.connection_attributes = connection_attributes | ||
if self.connection_attributes is None: | ||
|
@@ -223,6 +231,7 @@ def __init__( | |
self._name = name | ||
self._version = version | ||
self._tracer_provider = tracer_provider | ||
self.capture_parameters = capture_parameters | ||
self.database_component = database_component | ||
self.database_type = database_type | ||
self.connection_props = {} | ||
|
@@ -327,7 +336,7 @@ def _populate_span( | |
) in self._db_api_integration.span_attributes.items(): | ||
span.set_attribute(attribute_key, attribute_value) | ||
|
||
if len(args) > 1: | ||
if self._db_api_integration.capture_parameters and len(args) > 1: | ||
span.set_attribute("db.statement.parameters", str(args[1])) | ||
|
||
def traced_execution( | ||
|
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default should be
False
for all instrumentations that usedbapi
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok