-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2da3c6e
commit 0d0201b
Showing
14 changed files
with
583 additions
and
186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/OpenTelemetry.Instrumentation.StackExchangeRedis/Implementation/RedisMetrics.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 MetricQueueDurationName = "redis.client.queue.duration"; | ||
internal const string MetricNetworkDurationName = "redis.client.network.duration"; | ||
|
||
internal static readonly Assembly Assembly = typeof(StackExchangeRedisInstrumentation).Assembly; | ||
internal static readonly AssemblyName AssemblyName = Assembly.GetName(); | ||
internal static readonly string InstrumentationName = AssemblyName.Name!; | ||
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>( | ||
MetricQueueDurationName, | ||
unit: "s", | ||
description: "Total time the redis request was waiting in queue before being sent to the server."); | ||
|
||
this.NetworkHistogram = this.meter.CreateHistogram<double>( | ||
MetricNetworkDurationName, | ||
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> NetworkHistogram { get; } | ||
|
||
public Histogram<double> RequestHistogram { get; } | ||
|
||
public bool Enabled => this.RequestHistogram.Enabled; | ||
|
||
public void Dispose() | ||
{ | ||
this.meter.Dispose(); | ||
} | ||
} |
Oops, something went wrong.