Skip to content

Commit

Permalink
feat: Add StackExchangeRedis Meter
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagodaraujo committed Jul 31, 2024
1 parent 2da3c6e commit d161623
Show file tree
Hide file tree
Showing 14 changed files with 584 additions and 186 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentati
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.StackExchangeRedisInstrumentationExtensions
OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentationOptions
OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentationOptions.Enrich.get -> System.Action<System.Diagnostics.Activity!, StackExchange.Redis.Profiling.IProfiledCommand!>?
OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentationOptions.Enrich.set -> void
Expand All @@ -12,13 +13,18 @@ OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentati
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<OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentationOptions!>! configure) -> OpenTelemetry.Trace.TracerProviderBuilder!
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder, string? name, object! serviceKey, System.Action<OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentationOptions!>! configure) -> OpenTelemetry.Trace.TracerProviderBuilder!
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder, string? name, StackExchange.Redis.IConnectionMultiplexer? connection, object? serviceKey, System.Action<OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentationOptions!>? configure) -> OpenTelemetry.Trace.TracerProviderBuilder!
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder, System.Action<OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentationOptions!>! configure) -> OpenTelemetry.Trace.TracerProviderBuilder!
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.ConfigureRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder, System.Action<OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentation!>! configure) -> OpenTelemetry.Trace.TracerProviderBuilder!
static OpenTelemetry.Trace.TracerProviderBuilderExtensions.ConfigureRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder, System.Action<System.IServiceProvider!, OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentation!>! configure) -> OpenTelemetry.Trace.TracerProviderBuilder!
OpenTelemetry.Metrics.StackExchangeRedisMeterProviderBuilderExtensions
OpenTelemetry.Trace.StackExchangeRedisTracerProviderBuilderExtensions
static OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentationExtensions.ConfigureRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder, System.Action<OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentation!>! configure) -> OpenTelemetry.Trace.TracerProviderBuilder!
static OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentationExtensions.ConfigureRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder, System.Action<System.IServiceProvider!, OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentation!>! configure) -> OpenTelemetry.Trace.TracerProviderBuilder!
static OpenTelemetry.Metrics.StackExchangeRedisMeterProviderBuilderExtensions.AddRedisInstrumentation(this OpenTelemetry.Metrics.MeterProviderBuilder! builder) -> OpenTelemetry.Metrics.MeterProviderBuilder!
static OpenTelemetry.Metrics.StackExchangeRedisMeterProviderBuilderExtensions.AddRedisInstrumentation(this OpenTelemetry.Metrics.MeterProviderBuilder! builder, object! serviceKey) -> OpenTelemetry.Metrics.MeterProviderBuilder!
static OpenTelemetry.Metrics.StackExchangeRedisMeterProviderBuilderExtensions.AddRedisInstrumentation(this OpenTelemetry.Metrics.MeterProviderBuilder! builder, StackExchange.Redis.IConnectionMultiplexer! connection) -> OpenTelemetry.Metrics.MeterProviderBuilder!
static OpenTelemetry.Metrics.StackExchangeRedisMeterProviderBuilderExtensions.AddRedisInstrumentation(this OpenTelemetry.Metrics.MeterProviderBuilder! builder, string? name, StackExchange.Redis.IConnectionMultiplexer? connection, object? serviceKey) -> OpenTelemetry.Metrics.MeterProviderBuilder!
static OpenTelemetry.Trace.StackExchangeRedisTracerProviderBuilderExtensions.AddRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder) -> OpenTelemetry.Trace.TracerProviderBuilder!
static OpenTelemetry.Trace.StackExchangeRedisTracerProviderBuilderExtensions.AddRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder, object! serviceKey) -> OpenTelemetry.Trace.TracerProviderBuilder!
static OpenTelemetry.Trace.StackExchangeRedisTracerProviderBuilderExtensions.AddRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder, StackExchange.Redis.IConnectionMultiplexer! connection) -> OpenTelemetry.Trace.TracerProviderBuilder!
static OpenTelemetry.Trace.StackExchangeRedisTracerProviderBuilderExtensions.AddRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder, StackExchange.Redis.IConnectionMultiplexer! connection, System.Action<OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentationOptions!>! configure) -> OpenTelemetry.Trace.TracerProviderBuilder!
static OpenTelemetry.Trace.StackExchangeRedisTracerProviderBuilderExtensions.AddRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder, string? name, object! serviceKey, System.Action<OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentationOptions!>! configure) -> OpenTelemetry.Trace.TracerProviderBuilder!
static OpenTelemetry.Trace.StackExchangeRedisTracerProviderBuilderExtensions.AddRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder, string? name, StackExchange.Redis.IConnectionMultiplexer? connection, object? serviceKey, System.Action<OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentationOptions!>? configure) -> OpenTelemetry.Trace.TracerProviderBuilder!
static OpenTelemetry.Trace.StackExchangeRedisTracerProviderBuilderExtensions.AddRedisInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder, System.Action<OpenTelemetry.Instrumentation.StackExchangeRedis.StackExchangeRedisInstrumentationOptions!>! configure) -> OpenTelemetry.Trace.TracerProviderBuilder!
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## Unreleased

* Add `OpenTelemetry.Instrumentation.StackExchangeRedis` Meter
([#1982](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1982))
* New Metrics: `redis.client.request.duration`,
`redis.client.request.waiting_response`, `redis.client.request.time_in_queue`

## 1.9.0-beta.1

Released 2024-Jul-23
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

using System.Diagnostics.Metrics;
using System.Reflection;
using OpenTelemetry.Internal;

namespace OpenTelemetry.Instrumentation.StackExchangeRedis.Implementation;

internal class RedisMetrics : IDisposable
{
internal const string MetricRequestDurationName = "redis.client.request.duration";
internal const string MetricWaitingResponseName = "redis.client.request.waiting_response";
internal const string MetricTimeInQueueName = "redis.client.request.time_in_queue";

internal static readonly Assembly Assembly = typeof(StackExchangeRedisInstrumentation).Assembly;
internal static readonly AssemblyName AssemblyName = Assembly.GetName();
internal static readonly string InstrumentationName = AssemblyName.Name;

Check failure on line 18 in src/OpenTelemetry.Instrumentation.StackExchangeRedis/Implementation/RedisMetrics.cs

View workflow job for this annotation

GitHub Actions / build-test-instrumentation-stackexchangeredis / build-test (ubuntu-latest, net6.0)

Possible null reference assignment.
internal static readonly string InstrumentationVersion = Assembly.GetPackageVersion();

private readonly Meter meter;

public RedisMetrics()
{
this.meter = new Meter(InstrumentationName, InstrumentationVersion);

this.QueueHistogram = this.meter.CreateHistogram<double>(
MetricTimeInQueueName,
unit: "s",
description: "Total time the redis request was waiting in queue before being sent to the server.");

this.WaitingResponseHistogram = this.meter.CreateHistogram<double>(
MetricWaitingResponseName,
unit: "s",
description: "Duration of redis requests since sent the request to receive the response.");

this.RequestHistogram = this.meter.CreateHistogram<double>(
MetricRequestDurationName,
unit: "s",
description: "Total client request duration, including processing, queue and server duration.");
}

public static RedisMetrics Instance { get; } = new RedisMetrics();

public Histogram<double> QueueHistogram { get; }

public Histogram<double> WaitingResponseHistogram { get; }

public Histogram<double> RequestHistogram { get; }

public bool Enabled => this.RequestHistogram.Enabled;

public void Dispose()
{
this.meter.Dispose();
}
}
Loading

0 comments on commit d161623

Please sign in to comment.