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 "Application Name" connection string setting #547

Closed
bgrainger opened this issue Aug 14, 2018 · 9 comments
Closed

Add "Application Name" connection string setting #547

bgrainger opened this issue Aug 14, 2018 · 9 comments

Comments

@bgrainger
Copy link
Member

@bgrainger bgrainger commented Aug 14, 2018

SqlClient supports a Application Name connection string option that is visible in various server monitoring tools.

MySQL Workbench supports showing an application name via the program_name connection attribute.

We could add a connection string setting (default null) that, if set, is used to initialise that attribute.

Example requests for such a setting:

@bgrainger
Copy link
Member Author

@bgrainger bgrainger commented Aug 15, 2018

Npgsql also uses Application Name.

@bgrainger
Copy link
Member Author

@bgrainger bgrainger commented Aug 15, 2018

MySQL/J uses connectionAttributes=program_name:YOUR_NAME.

My inclination is not to support a Connection Attributes setting that allows the client to send arbitrary values to the server (and bear the burden of escaping them properly), but instead to add single-purpose settings (that may end up setting a connection attribute).

@bgrainger bgrainger self-assigned this Aug 21, 2018
@bgrainger
Copy link
Member Author

@bgrainger bgrainger commented Aug 21, 2018

Added in 0.44.0.

@firephantomassasin
Copy link

@firephantomassasin firephantomassasin commented May 3, 2020

How to use this in the connection string?

@firephantomassasin
Copy link

@firephantomassasin firephantomassasin commented May 3, 2020

Is there a way to put this in the c# code level? Like we want to set it based on the current executable assembly name (since we have multiple web projs and services)

@bgrainger
Copy link
Member Author

@bgrainger bgrainger commented May 3, 2020

Use MySqlConnectionStringBuilder.ApplicationName.

@firephantomassasin
Copy link

@firephantomassasin firephantomassasin commented May 3, 2020

@bgrainger how can we use that? This is how we instantiate and create our connection:

MySqlConnection connection = new MySqlConnection(ConnectionString);

@firephantomassasin
Copy link

@firephantomassasin firephantomassasin commented May 5, 2020

@bgrainger we have tried using this on our code:

MySqlConnectionStringBuilder connStringSb = new MySqlConnectionStringBuilder(ConnectionString);

connStringSb.ApplicationName = "";

connection = new MySqlConnection(connStringSb.ToString());

Would this be okay? Would there be any performance issue? Every DB calls uses this method and it creates new instance of MySqlConnectionStringBuilder, setting the application name and creating new string via the ToString(), and create the new MySqlConnection,

@bgrainger
Copy link
Member Author

@bgrainger bgrainger commented May 5, 2020

Firstly, I assume you're not actually setting ApplicationName to an empty string, as that accomplishes nothing.

Secondly, this is very unlikely to cause a performance problem, but the only way to know for sure is to run a performance profiler on your code with your input and measure it.

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

No branches or pull requests

2 participants