Skip to content

Commit

Permalink
Tweaks and trim warning cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeBlanch committed Nov 7, 2024
1 parent e265c83 commit 3e11aac
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ namespace OpenTelemetry.Instrumentation.SqlClient;
/// <summary>
/// SqlClient instrumentation.
/// </summary>
#if NET
[RequiresUnreferencedCode(SqlClientTrimmingUnsupportedMessage)]
#endif
internal sealed class SqlClientInstrumentation : IDisposable
{
public static readonly SqlClientInstrumentation Instance = new SqlClientInstrumentation();
Expand Down Expand Up @@ -42,9 +45,6 @@ internal sealed class SqlClientInstrumentation : IDisposable
/// <summary>
/// Initializes a new instance of the <see cref="SqlClientInstrumentation"/> class.
/// </summary>
#if NET
[RequiresUnreferencedCode(SqlClientTrimmingUnsupportedMessage)]
#endif
private SqlClientInstrumentation()
{
#if NETFRAMEWORK
Expand All @@ -61,6 +61,8 @@ private SqlClientInstrumentation()

public static SqlClientTraceInstrumentationOptions TracingOptions { get; set; } = new SqlClientTraceInstrumentationOptions();

public static IDisposable AddTracingHandle() => new TracingHandle();

/// <inheritdoc/>
public void Dispose()
{
Expand All @@ -71,7 +73,10 @@ public void Dispose()
#endif
}

internal class TracingHandle : IDisposable
#if NET
[RequiresUnreferencedCode(SqlClientTrimmingUnsupportedMessage)]
#endif
private sealed class TracingHandle : IDisposable
{
private bool disposed;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public static TracerProviderBuilder AddSqlClientInstrumentation(
#if NET
[RequiresUnreferencedCode(SqlClientInstrumentation.SqlClientTrimmingUnsupportedMessage)]
#endif

public static TracerProviderBuilder AddSqlClientInstrumentation(
this TracerProviderBuilder builder,
string? name,
Expand All @@ -71,7 +70,7 @@ public static TracerProviderBuilder AddSqlClientInstrumentation(
{
var sqlOptions = sp.GetRequiredService<IOptionsMonitor<SqlClientTraceInstrumentationOptions>>().Get(name);
SqlClientInstrumentation.TracingOptions = sqlOptions;
return new SqlClientInstrumentation.TracingHandle();
return SqlClientInstrumentation.AddTracingHandle();
});

builder.AddSource(SqlActivitySourceHelper.ActivitySourceName);
Expand Down

0 comments on commit 3e11aac

Please sign in to comment.