From 787ffe0c3621b718c0d24cf78d888ce8c446fab9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Kie=C5=82kowicz?= Date: Mon, 9 Dec 2024 12:14:51 +0100 Subject: [PATCH 1/2] Bump OpenTelemetry.Instrumentation.SqlClient to 1.10.0-beta.1 --- CHANGELOG.md | 1 + docs/plugins.md | 2 +- src/Directory.Packages.props | 2 +- .../netfx_assembly_redirection.h | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) 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} }, From cfd92bc9cb1e28350836c064003d97c30eac3ca4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Kie=C5=82kowicz?= Date: Mon, 9 Dec 2024 12:56:50 +0100 Subject: [PATCH 2/2] Fix SqlClientInitializer Handles changes from https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/2305 --- .../Loading/Initializers/SqlClientInitializer.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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); + } } }