From a745c8ba75f3696c82e69717c95b0ca2c46fcd10 Mon Sep 17 00:00:00 2001 From: Vera Reynolds Date: Fri, 16 Jul 2021 09:14:46 -0600 Subject: [PATCH] Add redis instrumentation (#66) --- .../Honeycomb.OpenTelemetry.csproj | 1 + src/Honeycomb.OpenTelemetry/HoneycombOptions.cs | 8 +++++++- .../TracerProviderBuilderExtensions.cs | 5 +++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Honeycomb.OpenTelemetry/Honeycomb.OpenTelemetry.csproj b/src/Honeycomb.OpenTelemetry/Honeycomb.OpenTelemetry.csproj index 68c3df3..e2de09e 100644 --- a/src/Honeycomb.OpenTelemetry/Honeycomb.OpenTelemetry.csproj +++ b/src/Honeycomb.OpenTelemetry/Honeycomb.OpenTelemetry.csproj @@ -35,6 +35,7 @@ + diff --git a/src/Honeycomb.OpenTelemetry/HoneycombOptions.cs b/src/Honeycomb.OpenTelemetry/HoneycombOptions.cs index 5981e27..77b0e53 100644 --- a/src/Honeycomb.OpenTelemetry/HoneycombOptions.cs +++ b/src/Honeycomb.OpenTelemetry/HoneycombOptions.cs @@ -1,5 +1,6 @@ using Microsoft.Extensions.Configuration; using OpenTelemetry.Trace; +using StackExchange.Redis; using System.Reflection; using System.Collections.Generic; @@ -59,6 +60,11 @@ public class HoneycombOptions /// public string ServiceVersion { get; set; } = s_defaultServiceVersion; + /// + /// Redis connection to enable Redis instrumentation. + /// + public IConnectionMultiplexer RedisConnection { get; set; } + private static Dictionary CommandLineSwitchMap = new Dictionary { {"--honeycomb-apikey", "apikey"}, @@ -93,4 +99,4 @@ public static HoneycombOptions FromConfiguration(IConfiguration configuration) .Get(); } } -} +} \ No newline at end of file diff --git a/src/Honeycomb.OpenTelemetry/TracerProviderBuilderExtensions.cs b/src/Honeycomb.OpenTelemetry/TracerProviderBuilderExtensions.cs index 0a0d394..10c6c2d 100644 --- a/src/Honeycomb.OpenTelemetry/TracerProviderBuilderExtensions.cs +++ b/src/Honeycomb.OpenTelemetry/TracerProviderBuilderExtensions.cs @@ -65,6 +65,11 @@ public static TracerProviderBuilder UseHoneycomb(this TracerProviderBuilder buil .AddHttpClientInstrumentation() .AddSqlClientInstrumentation(); + if (options.RedisConnection != null) + { + builder.AddRedisInstrumentation(options.RedisConnection); + } + #if NETSTANDARD2_1 builder.AddGrpcClientInstrumentation(); #endif