From a10c077caa08ed08e6be5718ab8689425c8a96ee Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Wed, 10 May 2023 14:49:55 -0700 Subject: [PATCH 1/2] Modernize the StackExchangeRedis project. --- .../.publicApi/net462/PublicAPI.Shipped.txt | 1 + .../.publicApi/net462/PublicAPI.Unshipped.txt | 8 +- .../netstandard2.0/PublicAPI.Shipped.txt | 1 + .../netstandard2.0/PublicAPI.Unshipped.txt | 8 +- .../CHANGELOG.md | 5 + .../RedisProfilerEntryToActivityConverter.cs | 18 ++- ....Instrumentation.StackExchangeRedis.csproj | 5 +- .../StackExchangeRedisCallsInstrumentation.cs | 11 +- ...xchangeRedisCallsInstrumentationOptions.cs | 3 +- .../TracerProviderBuilderExtensions.cs | 122 +++++++++++++----- src/Shared/ActivityInstrumentationHelper.cs | 4 + src/Shared/DiagnosticSourceListener.cs | 4 + src/Shared/DiagnosticSourceSubscriber.cs | 5 + src/Shared/InstrumentationEventSource.cs | 4 + src/Shared/MultiTypePropertyFetcher.cs | 4 + src/Shared/PropertyFetcher.cs | 4 + ...kExchangeRedisCallsInstrumentationTests.cs | 5 +- 17 files changed, 151 insertions(+), 61 deletions(-) diff --git a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/net462/PublicAPI.Shipped.txt b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/net462/PublicAPI.Shipped.txt index e69de29bb2..7dc5c58110 100644 --- a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/net462/PublicAPI.Shipped.txt +++ b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/net462/PublicAPI.Shipped.txt @@ -0,0 +1 @@ +#nullable enable diff --git a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/net462/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/net462/PublicAPI.Unshipped.txt index 7d34433831..09483f805d 100644 --- a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/net462/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/net462/PublicAPI.Unshipped.txt @@ -1,5 +1,5 @@ OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisCallsInstrumentationOptions -OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisCallsInstrumentationOptions.Enrich.get -> System.Action +OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisCallsInstrumentationOptions.Enrich.get -> System.Action? OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisCallsInstrumentationOptions.Enrich.set -> void OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisCallsInstrumentationOptions.FlushInterval.get -> System.TimeSpan OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisCallsInstrumentationOptions.FlushInterval.set -> void @@ -9,4 +9,8 @@ OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisCallsInstrume OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisCallsInstrumentationOptions.EnrichActivityWithTimingEvents.get -> bool OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisCallsInstrumentationOptions.EnrichActivityWithTimingEvents.set -> void OpenTelemetry.Trace.TracerProviderBuilderExtensions -static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder builder, StackExchange.Redis.IConnectionMultiplexer connection = null, System.Action configure = null) -> OpenTelemetry.Trace.TracerProviderBuilder +static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder) -> OpenTelemetry.Trace.TracerProviderBuilder! +static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder, StackExchange.Redis.IConnectionMultiplexer! connection) -> OpenTelemetry.Trace.TracerProviderBuilder! +static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder, StackExchange.Redis.IConnectionMultiplexer! connection, System.Action! configure) -> OpenTelemetry.Trace.TracerProviderBuilder! +static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder, string? name, StackExchange.Redis.IConnectionMultiplexer? connection, System.Action? configure) -> OpenTelemetry.Trace.TracerProviderBuilder! +static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder, System.Action! configure) -> OpenTelemetry.Trace.TracerProviderBuilder! diff --git a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/netstandard2.0/PublicAPI.Shipped.txt b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/netstandard2.0/PublicAPI.Shipped.txt index e69de29bb2..7dc5c58110 100644 --- a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/netstandard2.0/PublicAPI.Shipped.txt +++ b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/netstandard2.0/PublicAPI.Shipped.txt @@ -0,0 +1 @@ +#nullable enable diff --git a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt index 7d34433831..09483f805d 100644 --- a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/netstandard2.0/PublicAPI.Unshipped.txt @@ -1,5 +1,5 @@ OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisCallsInstrumentationOptions -OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisCallsInstrumentationOptions.Enrich.get -> System.Action +OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisCallsInstrumentationOptions.Enrich.get -> System.Action? OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisCallsInstrumentationOptions.Enrich.set -> void OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisCallsInstrumentationOptions.FlushInterval.get -> System.TimeSpan OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisCallsInstrumentationOptions.FlushInterval.set -> void @@ -9,4 +9,8 @@ OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisCallsInstrume OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisCallsInstrumentationOptions.EnrichActivityWithTimingEvents.get -> bool OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisCallsInstrumentationOptions.EnrichActivityWithTimingEvents.set -> void OpenTelemetry.Trace.TracerProviderBuilderExtensions -static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder builder, StackExchange.Redis.IConnectionMultiplexer connection = null, System.Action configure = null) -> OpenTelemetry.Trace.TracerProviderBuilder +static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder) -> OpenTelemetry.Trace.TracerProviderBuilder! +static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder, StackExchange.Redis.IConnectionMultiplexer! connection) -> OpenTelemetry.Trace.TracerProviderBuilder! +static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder, StackExchange.Redis.IConnectionMultiplexer! connection, System.Action! configure) -> OpenTelemetry.Trace.TracerProviderBuilder! +static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder, string? name, StackExchange.Redis.IConnectionMultiplexer? connection, System.Action? configure) -> OpenTelemetry.Trace.TracerProviderBuilder! +static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder, System.Action! configure) -> OpenTelemetry.Trace.TracerProviderBuilder! diff --git a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/CHANGELOG.md index 3f4f5845c2..368601ba6f 100644 --- a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/CHANGELOG.md @@ -2,6 +2,11 @@ ## Unreleased +* Added a dependency on `OpenTelemetry.Api.ProviderBuilderExtensions` and + updated `TracerProviderBuilder.AddRedisInstrumentation` to support named + options. + ([#XXXX](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/XXXX)) + ## 1.0.0-rc9.8 Released 2023-Feb-27 diff --git a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/Implementation/RedisProfilerEntryToActivityConverter.cs b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/Implementation/RedisProfilerEntryToActivityConverter.cs index 1b7a432db8..c4bca0e8ef 100644 --- a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/Implementation/RedisProfilerEntryToActivityConverter.cs +++ b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/Implementation/RedisProfilerEntryToActivityConverter.cs @@ -14,8 +14,6 @@ // limitations under the License. // -using System; -using System.Collections.Generic; using System.Diagnostics; using System.Net; using System.Reflection; @@ -27,7 +25,7 @@ namespace OpenTelemetry.Instrumentation.StackExchangeRedis.Implementation; internal static class RedisProfilerEntryToActivityConverter { - private static readonly Lazy> MessageDataGetter = new(() => + private static readonly Lazy> MessageDataGetter = new(() => { var redisAssembly = typeof(IProfiledCommand).Assembly; Type profiledCommandType = redisAssembly.GetType("StackExchange.Redis.Profiling.ProfiledCommand"); @@ -39,10 +37,10 @@ internal static class RedisProfilerEntryToActivityConverter if (messageDelegate == null) { - return new Func(source => (null, null)); + return new Func(source => (null, null)); } - return new Func(source => + return new Func(source => { if (source == null) { @@ -55,10 +53,10 @@ internal static class RedisProfilerEntryToActivityConverter return (null, null); } - string script = null; + string? script = null; if (message.GetType() == scriptMessageType) { - script = scriptDelegate.Invoke(message); + script = scriptDelegate?.Invoke(message); } if (commandAndKeyFetcher.TryFetch(message, out var value)) @@ -70,7 +68,7 @@ internal static class RedisProfilerEntryToActivityConverter }); }); - public static Activity ProfilerCommandToActivity(Activity parentActivity, IProfiledCommand command, StackExchangeRedisCallsInstrumentationOptions options) + public static Activity? ProfilerCommandToActivity(Activity? parentActivity, IProfiledCommand command, StackExchangeRedisCallsInstrumentationOptions options) { var name = command.Command; // Example: SET; if (string.IsNullOrEmpty(name)) @@ -176,7 +174,7 @@ public static Activity ProfilerCommandToActivity(Activity parentActivity, IProfi return activity; } - public static void DrainSession(Activity parentActivity, IEnumerable sessionCommands, StackExchangeRedisCallsInstrumentationOptions options) + public static void DrainSession(Activity? parentActivity, IEnumerable sessionCommands, StackExchangeRedisCallsInstrumentationOptions options) { foreach (var command in sessionCommands) { @@ -188,7 +186,7 @@ public static void DrainSession(Activity parentActivity, IEnumerable - private static Func CreateFieldGetter(Type classType, string fieldName, BindingFlags flags) + private static Func? CreateFieldGetter(Type classType, string fieldName, BindingFlags flags) { FieldInfo field = classType.GetField(fieldName, flags); if (field != null) diff --git a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/OpenTelemetry.Instrumentation.StackExchangeRedis.csproj b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/OpenTelemetry.Instrumentation.StackExchangeRedis.csproj index 45aa8b140d..36b3af1092 100644 --- a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/OpenTelemetry.Instrumentation.StackExchangeRedis.csproj +++ b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/OpenTelemetry.Instrumentation.StackExchangeRedis.csproj @@ -7,6 +7,9 @@ true true Instrumentation.StackExchangeRedis- + enable + true + true @@ -15,7 +18,7 @@ - + diff --git a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/StackExchangeRedisCallsInstrumentation.cs b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/StackExchangeRedisCallsInstrumentation.cs index 8d451142cd..63872364a0 100644 --- a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/StackExchangeRedisCallsInstrumentation.cs +++ b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/StackExchangeRedisCallsInstrumentation.cs @@ -14,11 +14,8 @@ // limitations under the License. // -using System; using System.Collections.Concurrent; -using System.Collections.Generic; using System.Diagnostics; -using System.Threading; using OpenTelemetry.Instrumentation.StackExchangeRedis.Implementation; using OpenTelemetry.Internal; using OpenTelemetry.Trace; @@ -38,9 +35,9 @@ internal class StackExchangeRedisCallsInstrumentation : IDisposable internal static readonly string ActivityName = ActivitySourceName + ".Execute"; internal static readonly Version Version = typeof(StackExchangeRedisCallsInstrumentation).Assembly.GetName().Version; internal static readonly ActivitySource ActivitySource = new(ActivitySourceName, Version.ToString()); - internal static readonly IEnumerable> CreationTags = new[] + internal static readonly IEnumerable> CreationTags = new[] { - new KeyValuePair(SemanticConventions.AttributeDbSystem, "redis"), + new KeyValuePair(SemanticConventions.AttributeDbSystem, "redis"), }; internal readonly ConcurrentDictionary<(ActivityTraceId TraceId, ActivitySpanId SpanId), (Activity Activity, ProfilingSession Session)> Cache @@ -77,7 +74,7 @@ public StackExchangeRedisCallsInstrumentation(IConnectionMultiplexer connection, /// Returns session for the Redis calls recording. /// /// Session associated with the current span context to record Redis calls. - public Func GetProfilerSessionsFactory() + public Func GetProfilerSessionsFactory() { return () => { @@ -86,7 +83,7 @@ public Func GetProfilerSessionsFactory() return null; } - Activity parent = Activity.Current; + var parent = Activity.Current; // If no parent use the default session. if (parent == null || parent.IdFormat != ActivityIdFormat.W3C) diff --git a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/StackExchangeRedisCallsInstrumentationOptions.cs b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/StackExchangeRedisCallsInstrumentationOptions.cs index 4b9e7c99f3..0e27e838d5 100644 --- a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/StackExchangeRedisCallsInstrumentationOptions.cs +++ b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/StackExchangeRedisCallsInstrumentationOptions.cs @@ -14,7 +14,6 @@ // limitations under the License. // -using System; using System.Diagnostics; using OpenTelemetry.Trace; using StackExchange.Redis.Profiling; @@ -43,7 +42,7 @@ public class StackExchangeRedisCallsInstrumentationOptions /// : the activity being enriched. /// : the profiled redis command from which additional information can be extracted to enrich the activity. /// - public Action Enrich { get; set; } + public Action? Enrich { get; set; } /// /// Gets or sets a value indicating whether or not the should enrich Activity with entries about the Redis command processing/lifetime. Defaults to true. diff --git a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/TracerProviderBuilderExtensions.cs b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/TracerProviderBuilderExtensions.cs index 22c7e56494..3bd9947930 100644 --- a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/TracerProviderBuilderExtensions.cs +++ b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/TracerProviderBuilderExtensions.cs @@ -14,7 +14,8 @@ // limitations under the License. // -using System; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; using OpenTelemetry.Instrumentation.StackExchangeRedis; using OpenTelemetry.Internal; using StackExchange.Redis; @@ -26,6 +27,71 @@ namespace OpenTelemetry.Trace; /// public static class TracerProviderBuilderExtensions { + /// + /// Enables automatic data collection of outgoing requests to Redis. + /// + /// + /// Note: A will be resolved using the + /// application . + /// + /// being configured. + /// The instance of to chain the calls. + public static TracerProviderBuilder AddRedisInstrumentation( + this TracerProviderBuilder builder) + => AddRedisInstrumentation(builder, name: null, connection: null, configure: null); + + /// + /// Enables automatic data collection of outgoing requests to Redis. + /// + /// being configured. + /// to instrument. + /// The instance of to chain the calls. + public static TracerProviderBuilder AddRedisInstrumentation( + this TracerProviderBuilder builder, + IConnectionMultiplexer connection) + { + Guard.ThrowIfNull(connection); + + return AddRedisInstrumentation(builder, name: null, connection, configure: null); + } + + /// + /// Enables automatic data collection of outgoing requests to Redis. + /// + /// + /// Note: A will be resolved using the + /// application . + /// + /// being configured. + /// Callback to configure options. + /// The instance of to chain the calls. + public static TracerProviderBuilder AddRedisInstrumentation( + this TracerProviderBuilder builder, + Action configure) + { + Guard.ThrowIfNull(configure); + + return AddRedisInstrumentation(builder, name: null, connection: null, configure); + } + + /// + /// Enables automatic data collection of outgoing requests to Redis. + /// + /// being configured. + /// to instrument. + /// Callback to configure options. + /// The instance of to chain the calls. + public static TracerProviderBuilder AddRedisInstrumentation( + this TracerProviderBuilder builder, + IConnectionMultiplexer connection, + Action configure) + { + Guard.ThrowIfNull(connection); + Guard.ThrowIfNull(configure); + + return AddRedisInstrumentation(builder, name: null, connection, configure); + } + /// /// Enables automatic data collection of outgoing requests to Redis. /// @@ -35,55 +101,41 @@ public static class TracerProviderBuilderExtensions /// resolved using the application . /// /// being configured. + /// Optional name which is used when retrieving options. /// Optional to instrument. /// Optional callback to configure options. /// The instance of to chain the calls. public static TracerProviderBuilder AddRedisInstrumentation( this TracerProviderBuilder builder, - IConnectionMultiplexer connection = null, - Action configure = null) + string? name, + IConnectionMultiplexer? connection, + Action? configure) { Guard.ThrowIfNull(builder); - if (builder is not IDeferredTracerProviderBuilder deferredTracerProviderBuilder) - { - if (connection == null) - { - throw new NotSupportedException($"StackExchange.Redis {nameof(IConnectionMultiplexer)} must be supplied when dependency injection is unavailable - to enable dependency injection use the OpenTelemetry.Extensions.Hosting package"); - } + name ??= Options.DefaultName; - return AddRedisInstrumentation(builder, connection, new StackExchangeRedisCallsInstrumentationOptions(), configure); + if (configure != null) + { + builder.ConfigureServices(services => services.Configure(name, configure)); } - return deferredTracerProviderBuilder.Configure((sp, builder) => - { - if (connection == null) + return builder + .AddSource(StackExchangeRedisCallsInstrumentation.ActivitySourceName) + .AddInstrumentation(sp => { - connection = (IConnectionMultiplexer)sp.GetService(typeof(IConnectionMultiplexer)); if (connection == null) { - throw new InvalidOperationException($"StackExchange.Redis {nameof(IConnectionMultiplexer)} could not be resolved through application {nameof(IServiceProvider)}"); + connection = sp.GetService(); + if (connection == null) + { + throw new InvalidOperationException($"StackExchange.Redis {nameof(IConnectionMultiplexer)} could not be resolved through application {nameof(IServiceProvider)}"); + } } - } - AddRedisInstrumentation( - builder, - connection, - sp.GetOptions(), - configure); - }); - } - - private static TracerProviderBuilder AddRedisInstrumentation( - TracerProviderBuilder builder, - IConnectionMultiplexer connection, - StackExchangeRedisCallsInstrumentationOptions options, - Action configure) - { - configure?.Invoke(options); - - return builder - .AddInstrumentation(() => new StackExchangeRedisCallsInstrumentation(connection, options)) - .AddSource(StackExchangeRedisCallsInstrumentation.ActivitySourceName); + return new StackExchangeRedisCallsInstrumentation( + connection, + sp.GetRequiredService>().Get(name)); + }); } } diff --git a/src/Shared/ActivityInstrumentationHelper.cs b/src/Shared/ActivityInstrumentationHelper.cs index 1ba9636dfa..1c2f97ce70 100644 --- a/src/Shared/ActivityInstrumentationHelper.cs +++ b/src/Shared/ActivityInstrumentationHelper.cs @@ -14,9 +14,13 @@ // limitations under the License. // +#nullable disable + +#pragma warning disable IDE0005 // Using directive is unnecessary. using System; using System.Diagnostics; using System.Linq.Expressions; +#pragma warning restore IDE0005 // Using directive is unnecessary. namespace OpenTelemetry.Instrumentation; diff --git a/src/Shared/DiagnosticSourceListener.cs b/src/Shared/DiagnosticSourceListener.cs index 9dc3f74a7b..38a6ee2410 100644 --- a/src/Shared/DiagnosticSourceListener.cs +++ b/src/Shared/DiagnosticSourceListener.cs @@ -14,10 +14,14 @@ // limitations under the License. // +#nullable disable + +#pragma warning disable IDE0005 // Using directive is unnecessary. using System; using System.Collections.Generic; using System.Diagnostics; using OpenTelemetry.Internal; +#pragma warning restore IDE0005 // Using directive is unnecessary. namespace OpenTelemetry.Instrumentation; diff --git a/src/Shared/DiagnosticSourceSubscriber.cs b/src/Shared/DiagnosticSourceSubscriber.cs index 99a25bbf7f..5435b90a3f 100644 --- a/src/Shared/DiagnosticSourceSubscriber.cs +++ b/src/Shared/DiagnosticSourceSubscriber.cs @@ -13,11 +13,16 @@ // See the License for the specific language governing permissions and // limitations under the License. // + +#nullable disable + +#pragma warning disable IDE0005 // Using directive is unnecessary. using System; using System.Collections.Generic; using System.Diagnostics; using System.Threading; using OpenTelemetry.Internal; +#pragma warning restore IDE0005 // Using directive is unnecessary. namespace OpenTelemetry.Instrumentation; diff --git a/src/Shared/InstrumentationEventSource.cs b/src/Shared/InstrumentationEventSource.cs index 07f9f56057..4321679472 100644 --- a/src/Shared/InstrumentationEventSource.cs +++ b/src/Shared/InstrumentationEventSource.cs @@ -14,9 +14,13 @@ // limitations under the License. // +#nullable disable + +#pragma warning disable IDE0005 // Using directive is unnecessary. using System; using System.Diagnostics.Tracing; using OpenTelemetry.Internal; +#pragma warning restore IDE0005 // Using directive is unnecessary. namespace OpenTelemetry.Instrumentation; diff --git a/src/Shared/MultiTypePropertyFetcher.cs b/src/Shared/MultiTypePropertyFetcher.cs index 122d40743f..4c8fb3fb0c 100644 --- a/src/Shared/MultiTypePropertyFetcher.cs +++ b/src/Shared/MultiTypePropertyFetcher.cs @@ -14,10 +14,14 @@ // limitations under the License. // +#nullable disable + +#pragma warning disable IDE0005 // Using directive is unnecessary. using System; using System.Collections.Concurrent; using System.Linq; using System.Reflection; +#pragma warning restore IDE0005 // Using directive is unnecessary. namespace OpenTelemetry.Instrumentation; diff --git a/src/Shared/PropertyFetcher.cs b/src/Shared/PropertyFetcher.cs index 8aab31e0be..4549699132 100644 --- a/src/Shared/PropertyFetcher.cs +++ b/src/Shared/PropertyFetcher.cs @@ -14,9 +14,13 @@ // limitations under the License. // +#nullable disable + +#pragma warning disable IDE0005 // Using directive is unnecessary. using System; using System.Linq; using System.Reflection; +#pragma warning restore IDE0005 // Using directive is unnecessary. namespace OpenTelemetry.Instrumentation; diff --git a/test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/StackExchangeRedisCallsInstrumentationTests.cs b/test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/StackExchangeRedisCallsInstrumentationTests.cs index 0539a93d4e..55cdb58011 100644 --- a/test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/StackExchangeRedisCallsInstrumentationTests.cs +++ b/test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/StackExchangeRedisCallsInstrumentationTests.cs @@ -13,6 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. // + using System; using System.Diagnostics; using System.Net; @@ -304,13 +305,13 @@ public async Task ProfilerSessionsHandleMultipleSpans() public void StackExchangeRedis_BadArgs() { TracerProviderBuilder builder = null; - Assert.Throws(() => builder.AddRedisInstrumentation(null)); + Assert.Throws(() => builder.AddRedisInstrumentation(connection: null)); var activityProcessor = new Mock>(); var exception = Assert.Throws(() => Sdk.CreateTracerProviderBuilder() .AddProcessor(activityProcessor.Object) - .AddRedisInstrumentation(null) + .AddRedisInstrumentation(name: null, connection: null, configure: null) .Build()); Assert.Equal("StackExchange.Redis IConnectionMultiplexer could not be resolved through application IServiceProvider", exception.Message); } From 6abddee50887044e97c6e933eccbc2b367dcc860 Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Wed, 10 May 2023 14:55:08 -0700 Subject: [PATCH 2/2] CHANGELOG patch. --- .../CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/CHANGELOG.md index 368601ba6f..4ee8f6ee7b 100644 --- a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/CHANGELOG.md @@ -5,7 +5,7 @@ * Added a dependency on `OpenTelemetry.Api.ProviderBuilderExtensions` and updated `TracerProviderBuilder.AddRedisInstrumentation` to support named options. - ([#XXXX](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/XXXX)) + ([#1183](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1183)) ## 1.0.0-rc9.8