-
Notifications
You must be signed in to change notification settings - Fork 170
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: create span for mysql2 execute #1221
Open
xuan-cao-swi
wants to merge
2
commits into
open-telemetry:main
Choose a base branch
from
xuan-cao-swi:mysql2-execute-span
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+67
−0
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
44 changes: 44 additions & 0 deletions
44
instrumentation/mysql2/lib/opentelemetry/instrumentation/mysql2/patches/statement.rb
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright The OpenTelemetry Authors | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
module OpenTelemetry | ||
module Instrumentation | ||
module Mysql2 | ||
module Patches | ||
# Module to prepend to Mysql2::Client for instrumentation | ||
module Statement | ||
def execute(*args, **kwargs) | ||
tracer.in_span( | ||
'execute', | ||
attributes: _otel_execute_attributes(args, kwargs), | ||
kind: :client | ||
) do | ||
super | ||
end | ||
end | ||
|
||
private | ||
|
||
def _otel_execute_attributes(args, kwargs) | ||
if config[:db_statement] == :include | ||
{'args' => args.to_s, 'kwargs' => kwargs.to_s} | ||
else | ||
{} | ||
end | ||
end | ||
|
||
def tracer | ||
Mysql2::Instrumentation.instance.tracer | ||
end | ||
|
||
def config | ||
Mysql2::Instrumentation.instance.config | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
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
Oops, something went wrong.
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.
I do agree that we should amend all attributes without using explicit mappings for semantic conventions especially if it opens up a risk to exposing sensitive data.
E.g. auth token or password would be exposed through telemetry collection, with a safeguards to remove them.
I do realize we allow this to happen today with our existing
include
statement but I am leaning more and more each day to deleting that option all together and only allowingsanitized
,obfuscate
, oromit
in the future.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.
Does
sanitized
mean specifically removing the sensitive data (e.g. token, password, ssn, health_id, etc.), but not other binding parameters such as address?I believe most password stored in table should be hashed.
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.
I think our current instrumentation uses the wrong vocabulary to describe what it does. Our current instrumentations use the word
obfuscate
, when I think we really mean is tosanitize
, i.e. remove all user provided values.I do not mean only targeting specific sensitive attributes when I use the word
sanitize
.I now think of
obfuscation
as meaning that the entire query is hashed as opposed to just the parameters or values.I brought up a request to change our vocabulary at a SIG meeting and the result #1194
Related to this topic, there was a recent OTEP submitted to around sensitive data redaction but I have not taken the time to digest it all just yet:
open-telemetry/oteps#255