oracle / dotnet-db-samples

.NET code samples for Oracle database developers #OracleDotNet
http://otn.oracle.com/dotnet
MIT License
408 stars 190 forks source link

How to use OpenTelemetry with entity framework core? #344

Closed mihaimyh closed 6 months ago

mihaimyh commented 6 months ago

In our application, we are using the ef core oracle driver. How can we use open telemetry with ef core? The OTL samples only shows how we can use it directly with the OracleConnetion object.

alexkeh commented 6 months ago

You can use OpenTelemetry.Instrumentation.EntityFrameworkCore instrumentation library for EF Core OpenTelemetry.

The EF Core team has an open feature request to improve OpenTelemetry tracing as well.

If your intent is to trace EF Core itself, there shouldn't be a need to add any ODP.NET-specific code.

If you want to trace ODP.NET operations in addition, you will need to reference ODP.NET's OpenTelemetry provider by adding some variation of the existing ODP.NET OpenTelemetry sample.