diff --git a/CHANGELOG.md b/CHANGELOG.md index 1886b6f1d5..9aaff3a6e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ This component adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.h - `OpenTelemetry.Instrumentation.Process` from `0.5.0-beta.7` to `1.10.0-beta.1`, - `OpenTelemetry.Instrumentation.Quartz` from `1.0.0-beta.3` to `1.10.0-beta.1`, - `OpenTelemetry.Instrumentation.Runtime` from `1.9.0` to `1.10.0`, + - `OpenTelemetry.Instrumentation.SqlClient` from `1.9.0-beta.1` to `1.10.0-beta.1`, - `OpenTelemetry.Instrumentation.Wcf` from `1.0.0-rc.18` to `1.10.0-beta.1`, - `OpenTelemetry.Resources.Azure` from `1.0.0-beta.9` to `1.10.0-beta.1`, - `OpenTelemetry.Resources.Container` from `1.0.0-beta.9` to `1.10.0-beta.1`, diff --git a/docs/plugins.md b/docs/plugins.md index b514504fab..ddd6b7edea 100644 --- a/docs/plugins.md +++ b/docs/plugins.md @@ -123,7 +123,7 @@ public class MyPlugin | OpenTelemetry.Instrumentation.GrpcNetClient.GrpcClientTraceInstrumentationOptions | OpenTelemetry.Instrumentation.GrpcNetClient | 1.10.0-beta.1 | | OpenTelemetry.Instrumentation.Http.HttpClientTraceInstrumentationOptions | OpenTelemetry.Instrumentation.Http | 1.10.0 | | OpenTelemetry.Instrumentation.Quartz.QuartzInstrumentationOptions | OpenTelemetry.Instrumentation.Quartz | 1.10.0-beta.1 | -| OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions | OpenTelemetry.Instrumentation.SqlClient | 1.9.0-beta.1 | +| OpenTelemetry.Instrumentation.SqlClient.SqlClientTraceInstrumentationOptions | OpenTelemetry.Instrumentation.SqlClient | 1.10.0-beta.1 | | OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentationOptions | OpenTelemetry.Instrumentation.StackExchangeRedis | 1.10.0-beta.1 | | OpenTelemetry.Instrumentation.Wcf.WcfInstrumentationOptions | OpenTelemetry.Instrumentation.Wcf | 1.10.0-beta.1 | diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index d406396f8f..29b28e17cc 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -23,7 +23,7 @@ - + diff --git a/src/OpenTelemetry.AutoInstrumentation.Native/netfx_assembly_redirection.h b/src/OpenTelemetry.AutoInstrumentation.Native/netfx_assembly_redirection.h index 967ec689db..1703aada6a 100644 --- a/src/OpenTelemetry.AutoInstrumentation.Native/netfx_assembly_redirection.h +++ b/src/OpenTelemetry.AutoInstrumentation.Native/netfx_assembly_redirection.h @@ -52,7 +52,7 @@ void CorProfiler::InitNetFxAssemblyRedirectsMap() { L"OpenTelemetry.Instrumentation.Process", {1, 10, 0, 265} }, { L"OpenTelemetry.Instrumentation.Quartz", {1, 10, 0, 266} }, { L"OpenTelemetry.Instrumentation.Runtime", {1, 10, 0, 257} }, - { L"OpenTelemetry.Instrumentation.SqlClient", {1, 9, 0, 43} }, + { L"OpenTelemetry.Instrumentation.SqlClient", {1, 10, 0, 267} }, { L"OpenTelemetry.Instrumentation.Wcf", {1, 10, 0, 269} }, { L"OpenTelemetry.Resources.Azure", {1, 10, 0, 270} }, { L"OpenTelemetry.Resources.Host", {1, 10, 0, 272} }, diff --git a/src/OpenTelemetry.AutoInstrumentation/Loading/Initializers/SqlClientInitializer.cs b/src/OpenTelemetry.AutoInstrumentation/Loading/Initializers/SqlClientInitializer.cs index 08bdbdac9a..887b4fe87a 100644 --- a/src/OpenTelemetry.AutoInstrumentation/Loading/Initializers/SqlClientInitializer.cs +++ b/src/OpenTelemetry.AutoInstrumentation/Loading/Initializers/SqlClientInitializer.cs @@ -1,6 +1,7 @@ // Copyright The OpenTelemetry Authors // SPDX-License-Identifier: Apache-2.0 +using System.Reflection; using OpenTelemetry.AutoInstrumentation.Configurations; using OpenTelemetry.AutoInstrumentation.Plugins; @@ -41,8 +42,14 @@ private void InitializeOnFirstCall(ILifespanManager lifespanManager) }; _pluginManager.ConfigureTracesOptions(options); - var instrumentation = Activator.CreateInstance(instrumentationType, options)!; + var propertyInfo = instrumentationType.GetProperty("TracingOptions", BindingFlags.Static | BindingFlags.Public); + propertyInfo?.SetValue(null, options); - lifespanManager.Track(instrumentation); + var instrumentation = instrumentationType.InvokeMember("AddTracingHandle", BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Static, Type.DefaultBinder, null, []); + + if (instrumentation != null) + { + lifespanManager.Track(instrumentation); + } } }