Skip to content

Commit

Permalink
Fix SqlClientInitializer
Browse files Browse the repository at this point in the history
  • Loading branch information
Kielek committed Dec 9, 2024
1 parent 787ffe0 commit cfd92bc
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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);
}
}
}

0 comments on commit cfd92bc

Please sign in to comment.