From ca0bb3395327248e394e3714ab87c95830c9848e Mon Sep 17 00:00:00 2001 From: Kahbazi Date: Fri, 1 Dec 2023 20:15:29 +0330 Subject: [PATCH 01/11] Support Redis instrumentation for keyed service --- .../.publicApi/PublicAPI.Unshipped.txt | 1 + ....Instrumentation.StackExchangeRedis.csproj | 6 +- .../TracerProviderBuilderExtensions.cs | 45 ++++++++-- ...kExchangeRedisCallsInstrumentationTests.cs | 85 +++++++++++-------- 4 files changed, 94 insertions(+), 43 deletions(-) diff --git a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/PublicAPI.Unshipped.txt index c76bae94e0..d3ed6c2137 100644 --- a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/PublicAPI.Unshipped.txt @@ -17,6 +17,7 @@ static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddRedisInstrumentati 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, string? name, StackExchange.Redis.IConnectionMultiplexer? connection, System.Action? configure, object? serviceKey) -> OpenTelemetry.Trace.TracerProviderBuilder! static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder, System.Action! configure) -> OpenTelemetry.Trace.TracerProviderBuilder! static OpenTelemetry.Trace.TracerProviderBuilderExtensions.ConfigureRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder, System.Action! configure) -> OpenTelemetry.Trace.TracerProviderBuilder! static OpenTelemetry.Trace.TracerProviderBuilderExtensions.ConfigureRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder, System.Action! configure) -> OpenTelemetry.Trace.TracerProviderBuilder! diff --git a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/OpenTelemetry.Instrumentation.StackExchangeRedis.csproj b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/OpenTelemetry.Instrumentation.StackExchangeRedis.csproj index 53c2f8edcf..24505d46ed 100644 --- a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/OpenTelemetry.Instrumentation.StackExchangeRedis.csproj +++ b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/OpenTelemetry.Instrumentation.StackExchangeRedis.csproj @@ -25,7 +25,11 @@ - + + + + + diff --git a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/TracerProviderBuilderExtensions.cs b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/TracerProviderBuilderExtensions.cs index ccd7391b21..262d4f55c7 100644 --- a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/TracerProviderBuilderExtensions.cs +++ b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/TracerProviderBuilderExtensions.cs @@ -26,7 +26,7 @@ public static class TracerProviderBuilderExtensions /// The instance of to chain the calls. public static TracerProviderBuilder AddRedisInstrumentation( this TracerProviderBuilder builder) - => AddRedisInstrumentation(builder, name: null, connection: null, configure: null); + => AddRedisInstrumentation(builder, name: null, connection: null, configure: null, serviceKey: null); /// /// Enables automatic data collection of outgoing requests to Redis. @@ -40,7 +40,7 @@ public static TracerProviderBuilder AddRedisInstrumentation( { Guard.ThrowIfNull(connection); - return AddRedisInstrumentation(builder, name: null, connection, configure: null); + return AddRedisInstrumentation(builder, name: null, connection, configure: null, serviceKey: null); } /// @@ -59,7 +59,7 @@ public static TracerProviderBuilder AddRedisInstrumentation( { Guard.ThrowIfNull(configure); - return AddRedisInstrumentation(builder, name: null, connection: null, configure); + return AddRedisInstrumentation(builder, name: null, connection: null, configure, serviceKey: null); } /// @@ -77,7 +77,7 @@ public static TracerProviderBuilder AddRedisInstrumentation( Guard.ThrowIfNull(connection); Guard.ThrowIfNull(configure); - return AddRedisInstrumentation(builder, name: null, connection, configure); + return AddRedisInstrumentation(builder, name: null, connection, configure, null); } /// @@ -98,6 +98,30 @@ public static TracerProviderBuilder AddRedisInstrumentation( string? name, IConnectionMultiplexer? connection, Action? configure) + { + return builder.AddRedisInstrumentation(name, connection, configure, null); + } + + /// + /// Enables automatic data collection of outgoing requests to Redis. + /// + /// + /// Note: If an is not supplied + /// using the parameter it will be + /// resolved using the application . + /// + /// being configured. + /// Optional name which is used when retrieving options. + /// Optional to instrument. + /// Optional callback to configure options. + /// The service key to get . + /// The instance of to chain the calls. + public static TracerProviderBuilder AddRedisInstrumentation( + this TracerProviderBuilder builder, + string? name, + IConnectionMultiplexer? connection, + Action? configure, + object? serviceKey) { Guard.ThrowIfNull(builder); @@ -119,7 +143,18 @@ public static TracerProviderBuilder AddRedisInstrumentation( { var instrumentation = sp.GetRequiredService(); - connection ??= sp.GetService(); + if (connection is not null) + { + if (serviceKey is null) + { + connection = sp.GetService(); + } + else + { + connection = sp.GetKeyedService(serviceKey); + } + } + if (connection != null) { diff --git a/test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/StackExchangeRedisCallsInstrumentationTests.cs b/test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/StackExchangeRedisCallsInstrumentationTests.cs index 0ee6e264bc..c7b5c15ed6 100644 --- a/test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/StackExchangeRedisCallsInstrumentationTests.cs +++ b/test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/StackExchangeRedisCallsInstrumentationTests.cs @@ -85,8 +85,9 @@ public void SuccessfulCommandTestWithKey(string value) [Trait("CategoryName", "RedisIntegrationTests")] [SkipUnlessEnvVarFoundTheory(RedisEndPointEnvVarName)] - [InlineData("value1")] - public void SuccessfulCommandTest(string value) + [InlineData("value1", null)] + [InlineData("value1", "serviceKey")] + public void SuccessfulCommandTest(string value, string? serviceKey) { var connectionOptions = new ConfigurationOptions { @@ -100,14 +101,24 @@ public void SuccessfulCommandTest(string value) using (Sdk.CreateTracerProviderBuilder() .ConfigureServices(services => { - services.TryAddSingleton(sp => + if (serviceKey is null) + { + services.TryAddSingleton(sp => + { + return connection = ConnectionMultiplexer.Connect(connectionOptions); + }); + } + else { - return connection = ConnectionMultiplexer.Connect(connectionOptions); - }); + services.TryAddKeyedSingleton(serviceKey, (sp, key) => + { + return connection = ConnectionMultiplexer.Connect(connectionOptions); + }); + } }) .AddInMemoryExporter(exportedItems) .SetSampler(sampler) - .AddRedisInstrumentation(c => c.SetVerboseDatabaseStatements = false) + .AddRedisInstrumentation(null, null, c => c.SetVerboseDatabaseStatements = false, serviceKey) .Build()) { Assert.NotNull(connection); @@ -301,37 +312,37 @@ public async Task ProfilerSessionsHandleMultipleSpans() Assert.Same(profiler0, profiles3); } - [Fact] - public void StackExchangeRedis_DependencyInjection_Success() - { - bool connectionMultiplexerPickedFromDI = false; - bool optionsPickedFromDI = false; - - var connectionOptions = new ConfigurationOptions - { - AbortOnConnectFail = false, - }; - connectionOptions.EndPoints.Add("localhost"); - - var services = new ServiceCollection(); - services.AddSingleton((sp) => - { - connectionMultiplexerPickedFromDI = true; - return ConnectionMultiplexer.Connect(connectionOptions); - }); - services.Configure(options => - { - optionsPickedFromDI = true; - }); - services.AddOpenTelemetry().WithTracing(builder => builder.AddRedisInstrumentation()); - - using var serviceProvider = services.BuildServiceProvider(); - - var tracerProvider = serviceProvider.GetRequiredService(); - - Assert.True(connectionMultiplexerPickedFromDI); - Assert.True(optionsPickedFromDI); - } + //[Fact] + //public void StackExchangeRedis_DependencyInjection_Success() + //{ + // bool connectionMultiplexerPickedFromDI = false; + // bool optionsPickedFromDI = false; + + // var connectionOptions = new ConfigurationOptions + // { + // AbortOnConnectFail = false, + // }; + // connectionOptions.EndPoints.Add("localhost"); + + // var services = new ServiceCollection(); + // services.AddSingleton((sp) => + // { + // connectionMultiplexerPickedFromDI = true; + // return ConnectionMultiplexer.Connect(connectionOptions); + // }); + // services.Configure(options => + // { + // optionsPickedFromDI = true; + // }); + // services.AddOpenTelemetry().WithTracing(builder => builder.AddRedisInstrumentation()); + + // using var serviceProvider = services.BuildServiceProvider(); + + // var tracerProvider = serviceProvider.GetRequiredService(); + + // Assert.True(connectionMultiplexerPickedFromDI); + // Assert.True(optionsPickedFromDI); + //} [Fact] public void StackExchangeRedis_StackExchangeRedisInstrumentation_Test() From cadebce9712f63ec13e792b19c343376695c92bd Mon Sep 17 00:00:00 2001 From: Kahbazi Date: Fri, 8 Dec 2023 18:50:39 +0330 Subject: [PATCH 02/11] Address review feedback --- .../.publicApi/PublicAPI.Unshipped.txt | 2 + .../.publicApi/net8.0/PublicAPI.Shipped.txt | 1 + .../.publicApi/net8.0/PublicAPI.Unshipped.txt | 0 .../CHANGELOG.md | 2 + ....Instrumentation.StackExchangeRedis.csproj | 8 +- .../TracerProviderBuilderExtensions.cs | 79 ++++++++++--------- 6 files changed, 50 insertions(+), 42 deletions(-) create mode 100644 src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/net8.0/PublicAPI.Shipped.txt create mode 100644 src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/net8.0/PublicAPI.Unshipped.txt diff --git a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/PublicAPI.Unshipped.txt index d3ed6c2137..3c0ad1e327 100644 --- a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/PublicAPI.Unshipped.txt @@ -14,6 +14,8 @@ OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentati OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentationOptions.StackExchangeRedisInstrumentationOptions() -> void OpenTelemetry.Trace.TracerProviderBuilderExtensions static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder) -> OpenTelemetry.Trace.TracerProviderBuilder! +static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder, object! serviceKey) -> OpenTelemetry.Trace.TracerProviderBuilder! +static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder, object! serviceKey, System.Action! configure) -> 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! diff --git a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/net8.0/PublicAPI.Shipped.txt b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/net8.0/PublicAPI.Shipped.txt new file mode 100644 index 0000000000..7dc5c58110 --- /dev/null +++ b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/net8.0/PublicAPI.Shipped.txt @@ -0,0 +1 @@ +#nullable enable diff --git a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/net8.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/net8.0/PublicAPI.Unshipped.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/CHANGELOG.md index e63e226fb9..fbe7e587f6 100644 --- a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/CHANGELOG.md @@ -23,6 +23,8 @@ Released 2024-Jan-03 * Update `OpenTelemetry.Api.ProviderBuilderExtensions` version to `1.7.0`. ([#1486](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1486)) +* Add support for instrumenting `IConnectionMultiplexer` which is added with service key. + ## 1.0.0-rc9.12 Released 2023-Nov-01 diff --git a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/OpenTelemetry.Instrumentation.StackExchangeRedis.csproj b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/OpenTelemetry.Instrumentation.StackExchangeRedis.csproj index 24505d46ed..b6ebdf43b8 100644 --- a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/OpenTelemetry.Instrumentation.StackExchangeRedis.csproj +++ b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/OpenTelemetry.Instrumentation.StackExchangeRedis.csproj @@ -1,7 +1,7 @@ - net6.0;netstandard2.0;net462 + net8.0;net6.0;netstandard2.0;net462 StackExchange.Redis instrumentation for OpenTelemetry .NET $(PackageTags);distributed-tracing;Redis;StackExchange.Redis Instrumentation.StackExchangeRedis- @@ -22,14 +22,10 @@ - + - - - - diff --git a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/TracerProviderBuilderExtensions.cs b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/TracerProviderBuilderExtensions.cs index 262d4f55c7..d62d3e8a96 100644 --- a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/TracerProviderBuilderExtensions.cs +++ b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/TracerProviderBuilderExtensions.cs @@ -46,60 +46,71 @@ public static TracerProviderBuilder AddRedisInstrumentation( /// /// Enables automatic data collection of outgoing requests to Redis. /// - /// - /// Note: A will be resolved using the - /// application . - /// /// being configured. - /// Callback to configure options. + /// Optional service key used to retrieve the to instrument from the . /// The instance of to chain the calls. public static TracerProviderBuilder AddRedisInstrumentation( this TracerProviderBuilder builder, - Action configure) + object serviceKey) { - Guard.ThrowIfNull(configure); + Guard.ThrowIfNull(serviceKey); - return AddRedisInstrumentation(builder, name: null, connection: null, configure, serviceKey: null); + return AddRedisInstrumentation(builder, name: null, connection: null, configure: null, serviceKey); } /// /// Enables automatic data collection of outgoing requests to Redis. /// /// being configured. - /// to instrument. + /// Optional service key used to retrieve the to instrument from the . /// Callback to configure options. /// The instance of to chain the calls. public static TracerProviderBuilder AddRedisInstrumentation( this TracerProviderBuilder builder, - IConnectionMultiplexer connection, + object serviceKey, Action configure) { - Guard.ThrowIfNull(connection); + Guard.ThrowIfNull(serviceKey); Guard.ThrowIfNull(configure); - return AddRedisInstrumentation(builder, name: null, connection, configure, null); + return AddRedisInstrumentation(builder, name: null, connection: null, configure, serviceKey); } /// /// Enables automatic data collection of outgoing requests to Redis. /// /// - /// Note: If an is not supplied - /// using the parameter it will be - /// resolved using the application . + /// Note: A will be resolved using the + /// application . /// /// being configured. - /// Optional name which is used when retrieving options. - /// Optional to instrument. - /// Optional callback to configure options. + /// 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, serviceKey: null); + } + + /// + /// 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, - string? name, - IConnectionMultiplexer? connection, - Action? configure) + IConnectionMultiplexer connection, + Action configure) { - return builder.AddRedisInstrumentation(name, connection, configure, null); + Guard.ThrowIfNull(connection); + Guard.ThrowIfNull(configure); + + return AddRedisInstrumentation(builder, name: null, connection, configure, serviceKey: null); } /// @@ -114,7 +125,7 @@ public static TracerProviderBuilder AddRedisInstrumentation( /// Optional name which is used when retrieving options. /// Optional to instrument. /// Optional callback to configure options. - /// The service key to get . + /// Optional service key used to retrieve the to instrument from the . /// The instance of to chain the calls. public static TracerProviderBuilder AddRedisInstrumentation( this TracerProviderBuilder builder, @@ -143,19 +154,15 @@ public static TracerProviderBuilder AddRedisInstrumentation( { var instrumentation = sp.GetRequiredService(); - if (connection is not null) - { - if (serviceKey is null) - { - connection = sp.GetService(); - } - else - { - connection = sp.GetKeyedService(serviceKey); - } - } - - +#if NET8_0_OR_GREATER + connection ??= serviceKey == null + ? sp.GetService() + : sp.GetKeyedService(serviceKey); +#else + connection ??= serviceKey == null + ? sp.GetService() + : throw new InvalidOperationException(); +#endif if (connection != null) { instrumentation.AddConnection(name, connection); From 362581b40ea2f58c5ef9f77b2c9fbf4275d0a611 Mon Sep 17 00:00:00 2001 From: Kahbazi Date: Sun, 21 Jan 2024 04:38:09 -1200 Subject: [PATCH 03/11] Address the feedback --- .../.publicApi/net8.0/PublicAPI.Unshipped.txt | 24 +++++++++++++++++++ .../TracerProviderBuilderExtensions.cs | 6 +++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/net8.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/net8.0/PublicAPI.Unshipped.txt index e69de29bb2..55fcd0c858 100644 --- a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/net8.0/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/net8.0/PublicAPI.Unshipped.txt @@ -0,0 +1,24 @@ +OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentation +OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentation.AddConnection(StackExchange.Redis.IConnectionMultiplexer! connection) -> System.IDisposable! +OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentation.AddConnection(string! name, StackExchange.Redis.IConnectionMultiplexer! connection) -> System.IDisposable! +OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentation.Dispose() -> void +OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentationOptions +OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentationOptions.Enrich.get -> System.Action? +OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentationOptions.Enrich.set -> void +OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentationOptions.EnrichActivityWithTimingEvents.get -> bool +OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentationOptions.EnrichActivityWithTimingEvents.set -> void +OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentationOptions.FlushInterval.get -> System.TimeSpan +OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentationOptions.FlushInterval.set -> void +OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentationOptions.SetVerboseDatabaseStatements.get -> bool +OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentationOptions.SetVerboseDatabaseStatements.set -> void +OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentationOptions.StackExchangeRedisInstrumentationOptions() -> void +OpenTelemetry.Trace.TracerProviderBuilderExtensions +static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder) -> OpenTelemetry.Trace.TracerProviderBuilder! +static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder, object! serviceKey) -> 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, object! serviceKey, 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, object? serviceKey) -> OpenTelemetry.Trace.TracerProviderBuilder! +static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder, System.Action! configure) -> OpenTelemetry.Trace.TracerProviderBuilder! +static OpenTelemetry.Trace.TracerProviderBuilderExtensions.ConfigureRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder, System.Action! configure) -> OpenTelemetry.Trace.TracerProviderBuilder! +static OpenTelemetry.Trace.TracerProviderBuilderExtensions.ConfigureRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder, System.Action! configure) -> OpenTelemetry.Trace.TracerProviderBuilder! diff --git a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/TracerProviderBuilderExtensions.cs b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/TracerProviderBuilderExtensions.cs index d62d3e8a96..ca40a838e0 100644 --- a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/TracerProviderBuilderExtensions.cs +++ b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/TracerProviderBuilderExtensions.cs @@ -62,18 +62,20 @@ public static TracerProviderBuilder AddRedisInstrumentation( /// Enables automatic data collection of outgoing requests to Redis. /// /// being configured. + /// Optional name which is used when retrieving options. /// Optional service key used to retrieve the to instrument from the . /// Callback to configure options. /// The instance of to chain the calls. public static TracerProviderBuilder AddRedisInstrumentation( this TracerProviderBuilder builder, + string? name, object serviceKey, Action configure) { Guard.ThrowIfNull(serviceKey); Guard.ThrowIfNull(configure); - return AddRedisInstrumentation(builder, name: null, connection: null, configure, serviceKey); + return AddRedisInstrumentation(builder, name: name, connection: null, configure, serviceKey); } /// @@ -161,7 +163,7 @@ public static TracerProviderBuilder AddRedisInstrumentation( #else connection ??= serviceKey == null ? sp.GetService() - : throw new InvalidOperationException(); + : throw new InvalidOperationException("Redis instrumentation with service key is supported in .NET 8.0 and above."); #endif if (connection != null) { From 71e896a18e4a08587d64a26572857782e82f5bb7 Mon Sep 17 00:00:00 2001 From: Kahbazi Date: Sun, 21 Jan 2024 05:16:21 -1200 Subject: [PATCH 04/11] Fix tests --- ....Instrumentation.StackExchangeRedis.csproj | 2 +- ...umentation.StackExchangeRedis.Tests.csproj | 1 + ...kExchangeRedisCallsInstrumentationTests.cs | 62 +++++++++---------- 3 files changed, 33 insertions(+), 32 deletions(-) diff --git a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/OpenTelemetry.Instrumentation.StackExchangeRedis.csproj b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/OpenTelemetry.Instrumentation.StackExchangeRedis.csproj index b6ebdf43b8..dd93f7635f 100644 --- a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/OpenTelemetry.Instrumentation.StackExchangeRedis.csproj +++ b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/OpenTelemetry.Instrumentation.StackExchangeRedis.csproj @@ -22,7 +22,7 @@ - + diff --git a/test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests.csproj b/test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests.csproj index 12b74df91b..509921488d 100644 --- a/test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests.csproj +++ b/test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests.csproj @@ -18,6 +18,7 @@ + diff --git a/test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/StackExchangeRedisCallsInstrumentationTests.cs b/test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/StackExchangeRedisCallsInstrumentationTests.cs index c7b5c15ed6..ef2b4d51a9 100644 --- a/test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/StackExchangeRedisCallsInstrumentationTests.cs +++ b/test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/StackExchangeRedisCallsInstrumentationTests.cs @@ -312,37 +312,37 @@ public async Task ProfilerSessionsHandleMultipleSpans() Assert.Same(profiler0, profiles3); } - //[Fact] - //public void StackExchangeRedis_DependencyInjection_Success() - //{ - // bool connectionMultiplexerPickedFromDI = false; - // bool optionsPickedFromDI = false; - - // var connectionOptions = new ConfigurationOptions - // { - // AbortOnConnectFail = false, - // }; - // connectionOptions.EndPoints.Add("localhost"); - - // var services = new ServiceCollection(); - // services.AddSingleton((sp) => - // { - // connectionMultiplexerPickedFromDI = true; - // return ConnectionMultiplexer.Connect(connectionOptions); - // }); - // services.Configure(options => - // { - // optionsPickedFromDI = true; - // }); - // services.AddOpenTelemetry().WithTracing(builder => builder.AddRedisInstrumentation()); - - // using var serviceProvider = services.BuildServiceProvider(); - - // var tracerProvider = serviceProvider.GetRequiredService(); - - // Assert.True(connectionMultiplexerPickedFromDI); - // Assert.True(optionsPickedFromDI); - //} + [Fact] + public void StackExchangeRedis_DependencyInjection_Success() + { + bool connectionMultiplexerPickedFromDI = false; + bool optionsPickedFromDI = false; + + var connectionOptions = new ConfigurationOptions + { + AbortOnConnectFail = false, + }; + connectionOptions.EndPoints.Add("localhost"); + + var services = new ServiceCollection(); + services.AddSingleton((sp) => + { + connectionMultiplexerPickedFromDI = true; + return ConnectionMultiplexer.Connect(connectionOptions); + }); + services.Configure(options => + { + optionsPickedFromDI = true; + }); + services.AddOpenTelemetry().WithTracing(builder => builder.AddRedisInstrumentation()); + + using var serviceProvider = services.BuildServiceProvider(); + + var tracerProvider = serviceProvider.GetRequiredService(); + + Assert.True(connectionMultiplexerPickedFromDI); + Assert.True(optionsPickedFromDI); + } [Fact] public void StackExchangeRedis_StackExchangeRedisInstrumentation_Test() From 70fa4a33ad33dd879f9cb9f90c422c4042a23c07 Mon Sep 17 00:00:00 2001 From: Kahbazi Date: Thu, 8 Feb 2024 15:01:21 +0330 Subject: [PATCH 05/11] Fix CI pipeline errors --- .../.publicApi/PublicAPI.Unshipped.txt | 5 ++--- .../CHANGELOG.md | 1 + ...metry.Instrumentation.StackExchangeRedis.csproj | 2 +- .../TracerProviderBuilderExtensions.cs | 14 +++++++------- .../StackExchangeRedisCallsInstrumentationTests.cs | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/PublicAPI.Unshipped.txt index 3c0ad1e327..a8e6e1c363 100644 --- a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/PublicAPI.Unshipped.txt @@ -15,11 +15,10 @@ OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentati OpenTelemetry.Trace.TracerProviderBuilderExtensions static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder) -> OpenTelemetry.Trace.TracerProviderBuilder! static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder, object! serviceKey) -> OpenTelemetry.Trace.TracerProviderBuilder! -static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder, object! serviceKey, System.Action! configure) -> 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, string? name, StackExchange.Redis.IConnectionMultiplexer? connection, System.Action? configure, object? serviceKey) -> OpenTelemetry.Trace.TracerProviderBuilder! +static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder, string? name, object! serviceKey, System.Action! configure) -> OpenTelemetry.Trace.TracerProviderBuilder! +static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder, string? name, StackExchange.Redis.IConnectionMultiplexer? connection, object? serviceKey, System.Action? configure) -> OpenTelemetry.Trace.TracerProviderBuilder! static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder, System.Action! configure) -> OpenTelemetry.Trace.TracerProviderBuilder! static OpenTelemetry.Trace.TracerProviderBuilderExtensions.ConfigureRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder, System.Action! configure) -> OpenTelemetry.Trace.TracerProviderBuilder! static OpenTelemetry.Trace.TracerProviderBuilderExtensions.ConfigureRedisInstrumentation(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 fbe7e587f6..607f250da9 100644 --- a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/CHANGELOG.md @@ -15,6 +15,7 @@ Released 2024-Apr-05 ([#1635](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1635)) * `ActivitySource.Version` is set to NuGet package version. ([#1624](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1624)) +* Support instrumenting `IConnectionMultiplexer` which is added with service key. ## 1.0.0-rc9.13 diff --git a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/OpenTelemetry.Instrumentation.StackExchangeRedis.csproj b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/OpenTelemetry.Instrumentation.StackExchangeRedis.csproj index dd93f7635f..42a6a24cfd 100644 --- a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/OpenTelemetry.Instrumentation.StackExchangeRedis.csproj +++ b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/OpenTelemetry.Instrumentation.StackExchangeRedis.csproj @@ -25,7 +25,7 @@ - + diff --git a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/TracerProviderBuilderExtensions.cs b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/TracerProviderBuilderExtensions.cs index ca40a838e0..a98cc86005 100644 --- a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/TracerProviderBuilderExtensions.cs +++ b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/TracerProviderBuilderExtensions.cs @@ -55,7 +55,7 @@ public static TracerProviderBuilder AddRedisInstrumentation( { Guard.ThrowIfNull(serviceKey); - return AddRedisInstrumentation(builder, name: null, connection: null, configure: null, serviceKey); + return AddRedisInstrumentation(builder, name: null, connection: null, serviceKey, configure: null); } /// @@ -75,7 +75,7 @@ public static TracerProviderBuilder AddRedisInstrumentation( Guard.ThrowIfNull(serviceKey); Guard.ThrowIfNull(configure); - return AddRedisInstrumentation(builder, name: name, connection: null, configure, serviceKey); + return AddRedisInstrumentation(builder, name: name, connection: null, serviceKey, configure); } /// @@ -94,7 +94,7 @@ public static TracerProviderBuilder AddRedisInstrumentation( { Guard.ThrowIfNull(configure); - return AddRedisInstrumentation(builder, name: null, connection: null, configure, serviceKey: null); + return AddRedisInstrumentation(builder, name: null, connection: null, serviceKey: null, configure); } /// @@ -112,7 +112,7 @@ public static TracerProviderBuilder AddRedisInstrumentation( Guard.ThrowIfNull(connection); Guard.ThrowIfNull(configure); - return AddRedisInstrumentation(builder, name: null, connection, configure, serviceKey: null); + return AddRedisInstrumentation(builder, name: null, connection, serviceKey: null, configure); } /// @@ -126,15 +126,15 @@ public static TracerProviderBuilder AddRedisInstrumentation( /// being configured. /// Optional name which is used when retrieving options. /// Optional to instrument. - /// Optional callback to configure options. /// Optional service key used to retrieve the to instrument from the . + /// Optional callback to configure options. /// The instance of to chain the calls. public static TracerProviderBuilder AddRedisInstrumentation( this TracerProviderBuilder builder, string? name, IConnectionMultiplexer? connection, - Action? configure, - object? serviceKey) + object? serviceKey, + Action? configure) { Guard.ThrowIfNull(builder); diff --git a/test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/StackExchangeRedisCallsInstrumentationTests.cs b/test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/StackExchangeRedisCallsInstrumentationTests.cs index ef2b4d51a9..101db075ca 100644 --- a/test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/StackExchangeRedisCallsInstrumentationTests.cs +++ b/test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/StackExchangeRedisCallsInstrumentationTests.cs @@ -118,7 +118,7 @@ public void SuccessfulCommandTest(string value, string? serviceKey) }) .AddInMemoryExporter(exportedItems) .SetSampler(sampler) - .AddRedisInstrumentation(null, null, c => c.SetVerboseDatabaseStatements = false, serviceKey) + .AddRedisInstrumentation(null, null, serviceKey, c => c.SetVerboseDatabaseStatements = false) .Build()) { Assert.NotNull(connection); From 656bddc57d9360d57dffa56a39571a698b945fd4 Mon Sep 17 00:00:00 2001 From: Kahbazi Date: Thu, 13 Jun 2024 11:58:05 +0330 Subject: [PATCH 06/11] Update change log --- .../CHANGELOG.md | 5 ++--- ...Telemetry.Instrumentation.StackExchangeRedis.Tests.csproj | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/CHANGELOG.md index 607f250da9..62d3b3c693 100644 --- a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/CHANGELOG.md @@ -7,6 +7,8 @@ * Update `Microsoft.Extensions.Options` to `8.0.0`. ([#1830](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1830)) +* Add support for instrumenting `IConnectionMultiplexer` which is added with service key. + ## 1.0.0-rc9.14 Released 2024-Apr-05 @@ -15,7 +17,6 @@ Released 2024-Apr-05 ([#1635](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1635)) * `ActivitySource.Version` is set to NuGet package version. ([#1624](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1624)) -* Support instrumenting `IConnectionMultiplexer` which is added with service key. ## 1.0.0-rc9.13 @@ -24,8 +25,6 @@ Released 2024-Jan-03 * Update `OpenTelemetry.Api.ProviderBuilderExtensions` version to `1.7.0`. ([#1486](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1486)) -* Add support for instrumenting `IConnectionMultiplexer` which is added with service key. - ## 1.0.0-rc9.12 Released 2023-Nov-01 diff --git a/test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests.csproj b/test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests.csproj index 509921488d..95b195687b 100644 --- a/test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests.csproj +++ b/test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests.csproj @@ -18,7 +18,7 @@ - + From c2a4f374a9d1d91a9026369398b087d36c2016e8 Mon Sep 17 00:00:00 2001 From: Kahbazi Date: Thu, 13 Jun 2024 14:27:56 +0330 Subject: [PATCH 07/11] Address pr feedback --- .../.publicApi/net8.0/PublicAPI.Shipped.txt | 1 - .../.publicApi/net8.0/PublicAPI.Unshipped.txt | 24 ------------------- .../CHANGELOG.md | 1 + ....Instrumentation.StackExchangeRedis.csproj | 3 ++- .../TracerProviderBuilderExtensions.cs | 7 +----- ...umentation.StackExchangeRedis.Tests.csproj | 1 - 6 files changed, 4 insertions(+), 33 deletions(-) delete mode 100644 src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/net8.0/PublicAPI.Shipped.txt delete mode 100644 src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/net8.0/PublicAPI.Unshipped.txt diff --git a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/net8.0/PublicAPI.Shipped.txt b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/net8.0/PublicAPI.Shipped.txt deleted file mode 100644 index 7dc5c58110..0000000000 --- a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/net8.0/PublicAPI.Shipped.txt +++ /dev/null @@ -1 +0,0 @@ -#nullable enable diff --git a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/net8.0/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/net8.0/PublicAPI.Unshipped.txt deleted file mode 100644 index 55fcd0c858..0000000000 --- a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/.publicApi/net8.0/PublicAPI.Unshipped.txt +++ /dev/null @@ -1,24 +0,0 @@ -OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentation -OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentation.AddConnection(StackExchange.Redis.IConnectionMultiplexer! connection) -> System.IDisposable! -OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentation.AddConnection(string! name, StackExchange.Redis.IConnectionMultiplexer! connection) -> System.IDisposable! -OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentation.Dispose() -> void -OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentationOptions -OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentationOptions.Enrich.get -> System.Action? -OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentationOptions.Enrich.set -> void -OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentationOptions.EnrichActivityWithTimingEvents.get -> bool -OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentationOptions.EnrichActivityWithTimingEvents.set -> void -OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentationOptions.FlushInterval.get -> System.TimeSpan -OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentationOptions.FlushInterval.set -> void -OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentationOptions.SetVerboseDatabaseStatements.get -> bool -OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentationOptions.SetVerboseDatabaseStatements.set -> void -OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentationOptions.StackExchangeRedisInstrumentationOptions() -> void -OpenTelemetry.Trace.TracerProviderBuilderExtensions -static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder) -> OpenTelemetry.Trace.TracerProviderBuilder! -static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder, object! serviceKey) -> 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, object! serviceKey, 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, object? serviceKey) -> OpenTelemetry.Trace.TracerProviderBuilder! -static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder, System.Action! configure) -> OpenTelemetry.Trace.TracerProviderBuilder! -static OpenTelemetry.Trace.TracerProviderBuilderExtensions.ConfigureRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder, System.Action! configure) -> OpenTelemetry.Trace.TracerProviderBuilder! -static OpenTelemetry.Trace.TracerProviderBuilderExtensions.ConfigureRedisInstrumentation(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 62d3b3c693..d20e3083f7 100644 --- a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/CHANGELOG.md @@ -8,6 +8,7 @@ ([#1830](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1830)) * Add support for instrumenting `IConnectionMultiplexer` which is added with service key. + ([#1885](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1885)) ## 1.0.0-rc9.14 diff --git a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/OpenTelemetry.Instrumentation.StackExchangeRedis.csproj b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/OpenTelemetry.Instrumentation.StackExchangeRedis.csproj index 42a6a24cfd..63aadcbd89 100644 --- a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/OpenTelemetry.Instrumentation.StackExchangeRedis.csproj +++ b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/OpenTelemetry.Instrumentation.StackExchangeRedis.csproj @@ -1,7 +1,7 @@ - net8.0;net6.0;netstandard2.0;net462 + net6.0;netstandard2.0;net462 StackExchange.Redis instrumentation for OpenTelemetry .NET $(PackageTags);distributed-tracing;Redis;StackExchange.Redis Instrumentation.StackExchangeRedis- @@ -22,6 +22,7 @@ + diff --git a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/TracerProviderBuilderExtensions.cs b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/TracerProviderBuilderExtensions.cs index a98cc86005..b7624e846f 100644 --- a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/TracerProviderBuilderExtensions.cs +++ b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/TracerProviderBuilderExtensions.cs @@ -156,15 +156,10 @@ public static TracerProviderBuilder AddRedisInstrumentation( { var instrumentation = sp.GetRequiredService(); -#if NET8_0_OR_GREATER connection ??= serviceKey == null ? sp.GetService() : sp.GetKeyedService(serviceKey); -#else - connection ??= serviceKey == null - ? sp.GetService() - : throw new InvalidOperationException("Redis instrumentation with service key is supported in .NET 8.0 and above."); -#endif + if (connection != null) { instrumentation.AddConnection(name, connection); diff --git a/test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests.csproj b/test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests.csproj index 95b195687b..12b74df91b 100644 --- a/test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests.csproj +++ b/test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests.csproj @@ -18,7 +18,6 @@ - From 6a6ba27158e906e0cc2ab4601ea7760f12b2672d Mon Sep 17 00:00:00 2001 From: Kahbazi Date: Thu, 13 Jun 2024 14:54:13 +0330 Subject: [PATCH 08/11] Remove package reference --- .../OpenTelemetry.Instrumentation.StackExchangeRedis.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/OpenTelemetry.Instrumentation.StackExchangeRedis.csproj b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/OpenTelemetry.Instrumentation.StackExchangeRedis.csproj index 63aadcbd89..53c2f8edcf 100644 --- a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/OpenTelemetry.Instrumentation.StackExchangeRedis.csproj +++ b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/OpenTelemetry.Instrumentation.StackExchangeRedis.csproj @@ -22,7 +22,6 @@ - From c27f2c399d9eb1f79612be884447fa170c85aba4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Kie=C5=82kowicz?= Date: Mon, 24 Jun 2024 12:01:57 +0200 Subject: [PATCH 09/11] Fix changelog --- .../CHANGELOG.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/CHANGELOG.md index 9f14dadab7..b29dc8322a 100644 --- a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/CHANGELOG.md @@ -1,6 +1,9 @@ # Changelog ## Unreleased + +* Add support for instrumenting `IConnectionMultiplexer` which is added with service key. + ([#1885](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1885)) ## 1.0.0-rc9.15 @@ -11,9 +14,6 @@ Released 2024-Jun-18 * Updated OpenTelemetry core component version(s) to `1.9.0`. ([#1888](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1888)) - -* Add support for instrumenting `IConnectionMultiplexer` which is added with service key. - ([#1885](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1885)) ## 1.0.0-rc9.14 From 06c118f474336f102e1d2a558c166869e91c358e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Kie=C5=82kowicz?= Date: Mon, 24 Jun 2024 12:16:31 +0200 Subject: [PATCH 10/11] Update CHANGELOG.md --- .../CHANGELOG.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/CHANGELOG.md index b29dc8322a..031a6df25c 100644 --- a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/CHANGELOG.md @@ -1,8 +1,9 @@ # Changelog ## Unreleased - -* Add support for instrumenting `IConnectionMultiplexer` which is added with service key. + +* Add support for instrumenting `IConnectionMultiplexer` + which is added with service key. ([#1885](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1885)) ## 1.0.0-rc9.15 From fcb34ce84c52f3d55ebfd42690cfb3bfcf7de45a Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Fri, 28 Jun 2024 10:00:00 -0700 Subject: [PATCH 11/11] Update src/OpenTelemetry.Instrumentation.StackExchangeRedis/TracerProviderBuilderExtensions.cs --- .../TracerProviderBuilderExtensions.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/TracerProviderBuilderExtensions.cs b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/TracerProviderBuilderExtensions.cs index b7624e846f..d9a450a2a6 100644 --- a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/TracerProviderBuilderExtensions.cs +++ b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/TracerProviderBuilderExtensions.cs @@ -89,8 +89,8 @@ public static TracerProviderBuilder AddRedisInstrumentation( /// Callback to configure options. /// The instance of to chain the calls. public static TracerProviderBuilder AddRedisInstrumentation( - this TracerProviderBuilder builder, - Action configure) + this TracerProviderBuilder builder, + Action configure) { Guard.ThrowIfNull(configure);