-
Notifications
You must be signed in to change notification settings - Fork 492
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
Open Telemetry : Adds query text in attribute #4664
base: master
Are you sure you want to change the base?
Conversation
2f7c8e7
to
e663af5
Compare
816b162
to
8e29f00
Compare
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.
Do we want to have an opt in to also capture parameter values attributes? This is described in the otel conventions, but we can always go back and add it if there's demand later.
Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/OpenTelemetryCoreRecorder.cs
Show resolved
Hide resolved
Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/OpenTelemetryRecorderFactory.cs
Outdated
Show resolved
Hide resolved
9b3858e
to
35201c3
Compare
Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/ShowQueryMode.cs
Outdated
Show resolved
Hide resolved
Microsoft.Azure.Cosmos/src/ChangeFeed/ChangeFeedIteratorCore.cs
Outdated
Show resolved
Hide resolved
Reqeustlevel override feels over engineering, Thoughts? |
It is taken from Java SDK and I believe, It will provide customers with the option to enable or disable the inclusion of query text in OpenTelemetry (OTel) traces for specific types of queries. |
6343391
to
23b13bf
Compare
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.
Nothing major from me. LGTM. just one nit. Everything else looks good.
Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/QueryTextMode.cs
Outdated
Show resolved
Hide resolved
5fd9ce8
to
b760982
Compare
Microsoft.Azure.Cosmos/src/RequestOptions/ChangeFeedRequestOptions.cs
Outdated
Show resolved
Hide resolved
/// Users have the option to enable printing parameterized or all queries, | ||
/// but has to beware that customer data may be shown when the later option is chosen. It's the user's responsibility to sanitize the queries if necessary. | ||
/// </summary> | ||
public QueryTextMode QueryTextMode { get; set; } = QueryTextMode.None; |
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.
Inconsistency, in-other request options nullable used
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.
what is the inconsistency, you are talking about here. All the telemetry options have some default value.
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.
This default value makes sense to me
Microsoft.Azure.Cosmos/src/Resource/FeedIterators/FeedIterator.cs
Outdated
Show resolved
Hide resolved
Microsoft.Azure.Cosmos/src/Resource/FeedIterators/FeedIterator{T}.cs
Outdated
Show resolved
Hide resolved
@@ -26,6 +26,7 @@ internal struct OpenTelemetryCoreRecorder : IDisposable | |||
private readonly OperationType operationType = OperationType.Invalid; | |||
private readonly string connectionModeCache = null; | |||
|
|||
private readonly QueryTextMode queryTextMode = QueryTextMode.None; |
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.
Mark it nullable for consistency and only apply default here?
@@ -245,6 +250,16 @@ OperationType operationType | |||
this.scope.AddAttribute(OpenTelemetryAttributeKeys.ActivityId, this.response.ActivityId); | |||
this.scope.AddAttribute(OpenTelemetryAttributeKeys.CorrelatedActivityId, this.response.CorrelatedActivityId); | |||
|
|||
if (this.response.QuerySpec is not null) |
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.
if (this.response.QuerySpec is not null) | |
if (this.response.QuerySpec.HasValue) |
Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/OpenTelemetryCoreRecorder.cs
Outdated
Show resolved
Hide resolved
(this.queryTextMode != QueryTextMode.None && this.response.QuerySpec.ShouldSerializeParameters() && | ||
this.queryTextMode == QueryTextMode.ParameterizedOnly)) | ||
{ | ||
this.scope.AddAttribute(OpenTelemetryAttributeKeys.QueryText, this.response.QuerySpec?.QueryText); |
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.
Expected semantics: Is below expectation correct? If so code needs to aligns with it.
- All: Full query text including parameterized with parameter values
- Paramaterized: Query with-out parameters?
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.
All => The entire query will be included, regardless of whether it is parameterized or not.
Parameterized Only => Only parameterized queries will be included. If the query contains any hardcoded information, it will also be included as is. It is the customer's responsibility to ensure that the query does not contain any sensitive information.
None => The query text will not be included.
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.
regardless of whether it is parameterized or not
Sounds like if it is parameterized, we won't "fill" the parameter with real values. I left a comment on this already, but putting it again here since it's relevant. Do we want to have an opt in to also capture parameter values attributes? This is described in the otel conventions, but we can always omit for now and add it if there's demand 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.
Adding parameter is kind of unlikely and in Java SDK never demanded for it, so I think we should be good as of now, if we see customers requesting for it, we can include it.
…{T}.cs Co-authored-by: Kiran Kumar Kolli <[email protected]>
Co-authored-by: Kiran Kumar Kolli <[email protected]>
…ryCoreRecorder.cs Co-authored-by: Kiran Kumar Kolli <[email protected]>
Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/QueryTextMode.cs
Outdated
Show resolved
Hide resolved
Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/QueryTextMode.cs
Outdated
Show resolved
Hide resolved
Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/QueryTextMode.cs
Outdated
Show resolved
Hide resolved
Microsoft.Azure.Cosmos/src/Telemetry/OpenTelemetry/QueryTextMode.cs
Outdated
Show resolved
Hide resolved
/// Users have the option to enable printing parameterized or all queries, | ||
/// but has to beware that customer data may be shown when the later option is chosen. It's the user's responsibility to sanitize the queries if necessary. | ||
/// </summary> | ||
public QueryTextMode QueryTextMode { get; set; } = QueryTextMode.None; |
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.
This default value makes sense to me
…de.cs Co-authored-by: Justine Cocchi <[email protected]>
…de.cs Co-authored-by: Justine Cocchi <[email protected]>
…de.cs Co-authored-by: Justine Cocchi <[email protected]>
…de.cs Co-authored-by: Justine Cocchi <[email protected]>
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.
LGTM
Description
db.query.text
attribute to record queries in Traces.ShowQueryMode
, which will have valid values asa)
NONE
:Do not show query.b)
PARAMETERIZED_ONLY
: Print parameterized query only.b)
ALL
CosmosClientTelemetryOptions
andRequestOptions
(i.e.QueryRequestOptions
andChangeFeedRequestOptions
)Type of change