MySql.Data.OpenTelemetry
Deps
1
Install Size
—
Vulns
✓ 0
Published
Jan 21, 2026
$ dotnet add package MySql.Data.OpenTelemetryMySQL provides connectivity for client applications developed in .NET compatible programming languages with MySQL Connector/NET through a series of packages.
MySql.Data.OpenTelemetry enables telemetry capabilities. It is compatible with .NET 6.0+ and must be used alongside the MySql.Data package. An OpenTelemetry SDK is required.
More information at [MySQL Connector/NET documentation] (https://dev.mysql.com/doc/connector-net/en/).
//create the tracer provider and add Connector/NET as a source from telemetry data.
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddConnectorNet()
.ConfigureResource(resource => resource.AddService("connector-net"))
.Build();
//use MySql.Data as usual, the internal implementation of OpenTelemetry is now enabled.
MySql.Data.MySqlClient.MySqlConnection myConnection;
string myConnectionString;
//set the correct values for your server, user, password and database name
myConnectionString = "server=127.0.0.1;uid=root;pwd=12345;database=test";
try
{
myConnection = new MySql.Data.MySqlClient.MySqlConnection(myConnectionString);
//open a connection
myConnection.Open();
// create a MySQL command and set the SQL statement with parameters
MySqlCommand myCommand = new MySqlCommand();
myCommand.Connection = myConnection;
myCommand.CommandText = @"SELECT * FROM clients WHERE client_id = @clientId;";
myCommand.Parameters.AddWithValue("@clientId", clientId);
// execute the command and read the results
using var myReader = myCommand.ExecuteReader()
{
while (myReader.Read())
{
var id = myReader.GetInt32("client_id");
var name = myReader.GetString("client_name");
// ...
}
}
myConnection.Close();
}
catch (MySql.Data.MySqlClient.MySqlException ex)
{
MessageBox.Show(ex.Message);
}
Please refer to files README and LICENSE, available in the Connector/NET GitHub repository, and Legal Notices in documentation for further details.
Oracle values the independent security research community and believes that responsible disclosure of security vulnerabilities helps us ensure the security and privacy of all our users. Please refer to the security guidelines document for additional information.
We greatly appreciate feedback from our users, including bug reports and code contributions. Your input helps us improve, and we thank you for any issues you report or code you contribute. Please refer to the contributing guidelines document for additional information.
#connectors channel on MySQL Community Slack (Sign-up required if you do not have an Oracle account.)For more information about this and other MySQL products, please visit MySQL Contact & Questions.