Skip to content
This repository was archived by the owner on Jul 5, 2020. It is now read-only.

Adding a flag to enable/disable collection of SQL Command text#1285

Closed
stebet wants to merge 6 commits intomicrosoft:developfrom
stebet:addFlagToDisableSqlCommandText
Closed

Adding a flag to enable/disable collection of SQL Command text#1285
stebet wants to merge 6 commits intomicrosoft:developfrom
stebet:addFlagToDisableSqlCommandText

Conversation

@stebet
Copy link
Copy Markdown

@stebet stebet commented Oct 4, 2019

Adding a boolean flag to the DependencyTrackingTelemetryModule which instructs the SQL processors to enable/disable collecting SQL command text.

Also added tests to verify the functionality.

Perhaps there is a better place for that flag than on the module itself since it's propagated down to the other classes, but it made sense to put it there.

This relates to https://github.com/microsoft/ApplicationInsights-aspnetcore/issues/980 as well as
#1282

  • I ran Unit Tests locally.

/// <summary>
/// Gets or sets a value indicating whether to track the SQL command text in SQL dependencies.
/// </summary>
public bool EnableSqlCommandTextInstrumentation { get; set; } = true;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Need better messaging and possibly link to doc. Else customers might that this flag alone will give full sql query.
https://docs.microsoft.com/en-us/azure/azure-monitor/app/asp-net-dependencies#advanced-sql-tracking-to-get-full-sql-query

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we should default to False. In .NET Core we are true by default (with no option to turn it off). This is a bug and sql query collection should be always opt-in, to address privacy concerns
cc: @Dmitry-Matveev

Copy link
Copy Markdown
Author

@stebet stebet Oct 7, 2019

Choose a reason for hiding this comment

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

Yeah I'll update the description and try to make it more clear. I'll also default it to false, but people that are maybe counting on it today would need to be made aware that this default behavior is changing then. Perhaps a post in the applicationinsights-announcements repo would be good to explain the reasoning.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Agree its a breaking change. But I could think of the original behavior as a "bug" and we are now fixing it.
Yes I can surely do a post in announcements repo to make .net core customers aware of the need to opt-in. Will do this in changelog.md for aspnetcore repo as well.

@stebet stebet changed the title Adding an flag to disable collection of SQL Command text Adding a flag to enable/disable collection of SQL Command text Oct 7, 2019
Defaulting the sql collection flag to false.
Updating Changelog to make it clear what this change means.
@cijothomas
Copy link
Copy Markdown
Contributor

@Dmitry-Matveev @SergeyKanzhelev I am fine with this PR changes. I could use one of your review as well especially on the part where we are changing SQL Text to be opt-in for .net core customers now.

@lmolkova
Copy link
Copy Markdown

lmolkova commented Oct 7, 2019

LGTM.

regarding defaults, I suggest

  • keep collecting SQL command test for existing scenarios: (for System.Data.SqlClient) by default
  • stop collecting command text for Microsoft.Data.SqlClient by default

@lmolkova lmolkova closed this Oct 7, 2019
@lmolkova lmolkova reopened this Oct 7, 2019
@Dmitry-Matveev
Copy link
Copy Markdown
Member

Looks good. Regarding defaults, can you please check with Dave? It may very well be a privacy requirement to have it opt-in only anyway (reqs recently were updated for several privacy considerations), in this case, yes, we're fixing a bug.

@stebet
Copy link
Copy Markdown
Author

stebet commented Oct 7, 2019

Distinguishing between the libraries in the collection logic would make it a bit more complicated as well, instead of just treating both libraries the same. Will look into it though if you want to split the default logic between the old and new library.

@TimothyMothra
Copy link
Copy Markdown

Adding a reminder here, we need to inform the support teams about this change.
Although it's a bug, we're changing the default behavior and this may negatively impact customers.

@stebet
Copy link
Copy Markdown
Author

stebet commented Oct 9, 2019

Is there anything else needed from me on this PR? Any changes required?

@cijothomas
Copy link
Copy Markdown
Contributor

@stebet nothing needed from you. We are discussing internally about the default setting. Will be back with finding here. (about whether we want sqltext ON by default or OFF by default)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants