Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[redis] Append options name to the background thread #1205

Merged
merged 3 commits into from
May 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
`TracerProvider` has been created.
([#1193](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1193))

* When using named options the name will now be applied to the background thread
created for each instrumented connection in the format
`OpenTelemetry.Redis{OPTIONS_NAME_HERE}`.
([#1205](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1205))

## 1.0.0-rc9.8

Released 2023-Feb-27
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,20 @@ internal sealed class StackExchangeRedisConnectionInstrumentation : IDisposable
/// Initializes a new instance of the <see cref="StackExchangeRedisConnectionInstrumentation"/> class.
/// </summary>
/// <param name="connection"><see cref="IConnectionMultiplexer"/> to instrument.</param>
/// <param name="name">Optional name for the connection.</param>
/// <param name="options">Configuration options for redis instrumentation.</param>
public StackExchangeRedisConnectionInstrumentation(IConnectionMultiplexer connection, StackExchangeRedisInstrumentationOptions options)
public StackExchangeRedisConnectionInstrumentation(
IConnectionMultiplexer connection,
string? name,
StackExchangeRedisInstrumentationOptions options)
{
Guard.ThrowIfNull(connection);

this.options = options ?? new StackExchangeRedisInstrumentationOptions();

this.drainThread = new Thread(this.DrainEntries)
{
Name = "OpenTelemetry.Redis",
Name = string.IsNullOrWhiteSpace(name) ? "OpenTelemetry.Redis" : $"OpenTelemetry.Redis{{{name}}}",
IsBackground = true,
};
this.drainThread.Start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public IDisposable AddConnection(string name, IConnectionMultiplexer connection)

lock (this.InstrumentedConnections)
{
var instrumentation = new StackExchangeRedisConnectionInstrumentation(connection, options);
var instrumentation = new StackExchangeRedisConnectionInstrumentation(connection, name, options);

this.InstrumentedConnections.Add(instrumentation);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public async void ProfilerSessionUsesTheSameDefault()

var connection = ConnectionMultiplexer.Connect(connectionOptions);

using var instrumentation = new StackExchangeRedisConnectionInstrumentation(connection, new StackExchangeRedisInstrumentationOptions());
using var instrumentation = new StackExchangeRedisConnectionInstrumentation(connection, name: null, new StackExchangeRedisInstrumentationOptions());
var profilerFactory = instrumentation.GetProfilerSessionsFactory();
var first = profilerFactory();
var second = profilerFactory();
Expand Down Expand Up @@ -236,7 +236,7 @@ public void CheckCacheIsFlushedProperly()

var connection = ConnectionMultiplexer.Connect(connectionOptions);

using var instrumentation = new StackExchangeRedisConnectionInstrumentation(connection, new StackExchangeRedisInstrumentationOptions());
using var instrumentation = new StackExchangeRedisConnectionInstrumentation(connection, name: null, new StackExchangeRedisInstrumentationOptions());
var profilerFactory = instrumentation.GetProfilerSessionsFactory();

// start a root level activity
Expand Down Expand Up @@ -276,7 +276,7 @@ public async Task ProfilerSessionsHandleMultipleSpans()

var connection = ConnectionMultiplexer.Connect(connectionOptions);

using var instrumentation = new StackExchangeRedisConnectionInstrumentation(connection, new StackExchangeRedisInstrumentationOptions());
using var instrumentation = new StackExchangeRedisConnectionInstrumentation(connection, name: null, new StackExchangeRedisInstrumentationOptions());
var profilerFactory = instrumentation.GetProfilerSessionsFactory();

// start a root level activity
Expand Down