Skip to content

Commit c9913e8

Browse files
[EFCore] Extend known providers (#3025)
1 parent fc91ba7 commit c9913e8

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed

src/OpenTelemetry.Instrumentation.EntityFrameworkCore/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
conventions when opted into using the `OTEL_SEMCONV_STABILITY_OPT_IN` environment
1313
variable.
1414
([#3011](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/3011))
15+
* Extend `db.system.name` values to identity additional providers related to Couchbase,
16+
DB2, MongoDB, MySQL, Oracle, PostgreSQL and SQLite.
17+
([#3025](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/3025))
1518

1619
## 1.12.0-beta.2
1720

src/OpenTelemetry.Instrumentation.EntityFrameworkCore/Implementation/EntityFrameworkDiagnosticListener.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ internal static (string Old, string New) GetDbSystemNames(string? providerOrComm
286286
"Devart.Data.MySql.MySqlCommand" or
287287
"MySql.Data.EntityFrameworkCore" or
288288
"MySql.Data.MySqlClient.MySqlCommand" or
289+
"MySql.EntityFrameworkCore" or
289290
"Pomelo.EntityFrameworkCore.MySql"
290291
=> (DbSystems.Mysql, DbSystemNames.Mysql),
291292
"Npgsql.EntityFrameworkCore.PostgreSQL" or
@@ -307,6 +308,15 @@ internal static (string Old, string New) GetDbSystemNames(string? providerOrComm
307308
"Teradata.Client.Provider.TdCommand" or
308309
"Teradata.EntityFrameworkCore"
309310
=> (DbSystems.Teradata, DbSystemNames.Teradata),
311+
"MongoDB.EntityFrameworkCore"
312+
=> (DbSystems.Mongodb, DbSystemNames.Mongodb),
313+
"Couchbase.EntityFrameworkCore" or
314+
"Couchbase.EntityFrameworkCore.Storage.Internal"
315+
=> (DbSystems.Couchbase, DbSystemNames.Couchbase),
316+
"IBM.EntityFrameworkCore" or
317+
"IBM.EntityFrameworkCore-lnx" or
318+
"IBM.EntityFrameworkCore-osx"
319+
=> (DbSystems.Db2, DbSystemNames.IbmDb2),
310320
//// These names are custom and are retained for backwards compatibility
311321
"EFCore.Snowflake" or
312322
"EFCore.Snowflake.Storage" or
@@ -367,9 +377,12 @@ private static class DbSystemNames
367377
{
368378
public const string OtherSql = "other_sql";
369379
public const string AzureCosmosDb = "azure.cosmosdb";
380+
public const string Couchbase = "couchbase";
370381
public const string Firebirdsql = "firebirdsql";
371382
public const string GcpSpanner = "gcp.spanner";
383+
public const string IbmDb2 = "ibm.db2";
372384
public const string MicrosoftSqlServer = "microsoft.sql_server";
385+
public const string Mongodb = "mongodb";
373386
public const string Mysql = "mysql";
374387
public const string OracleDb = "oracle.db";
375388
public const string Postgresql = "postgresql";
@@ -384,7 +397,10 @@ private static class DbSystems
384397
{
385398
public const string OtherSql = "other_sql";
386399
public const string Cosmosdb = "cosmosdb";
400+
public const string Couchbase = "couchbase";
401+
public const string Db2 = "db2";
387402
public const string Firebird = "firebird";
403+
public const string Mongodb = "mongodb";
388404
public const string Mssql = "mssql";
389405
public const string Mysql = "mysql";
390406
public const string Oracle = "oracle";

test/OpenTelemetry.Instrumentation.EntityFrameworkCore.Tests/EntityFrameworkDiagnosticListenerTests.cs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,36 @@ public static TheoryData<string, string, string> DbSystemTestCases()
3737
{ "FileContextCore", "filecontextcore", "filecontextcore" },
3838
{ "Microsoft.EntityFrameworkCore.Cosmos", "cosmosdb", "azure.cosmosdb" },
3939
{ "Microsoft.EntityFrameworkCore.InMemory", "efcoreinmemory", "efcoreinmemory" },
40+
{ "MongoDB.EntityFrameworkCore", "mongodb", "mongodb" },
4041
};
4142

42-
// Firebird
43+
// Couchbase
4344
string[] names =
45+
[
46+
"Couchbase.EntityFrameworkCore",
47+
"Couchbase.EntityFrameworkCore.Storage.Internal",
48+
];
49+
50+
foreach (string name in names)
51+
{
52+
testCases.Add(name, "couchbase", "couchbase");
53+
}
54+
55+
// DB2
56+
names =
57+
[
58+
"IBM.EntityFrameworkCore",
59+
"IBM.EntityFrameworkCore-lnx",
60+
"IBM.EntityFrameworkCore-osx",
61+
];
62+
63+
foreach (string name in names)
64+
{
65+
testCases.Add(name, "db2", "ibm.db2");
66+
}
67+
68+
// Firebird
69+
names =
4470
[
4571
"FirebirdSql.Data.FirebirdClient.FbCommand",
4672
"FirebirdSql.EntityFrameworkCore.Firebird",
@@ -82,6 +108,7 @@ public static TheoryData<string, string, string> DbSystemTestCases()
82108
"Devart.Data.MySql.MySqlCommand",
83109
"MySql.Data.EntityFrameworkCore",
84110
"MySql.Data.MySqlClient.MySqlCommand",
111+
"MySql.EntityFrameworkCore",
85112
"Pomelo.EntityFrameworkCore.MySql",
86113
];
87114

0 commit comments

Comments
 (0)