-
Notifications
You must be signed in to change notification settings - Fork 291
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 e8ce71c
Showing
12 changed files
with
523 additions
and
154 deletions.
There are no files selected for viewing
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 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; | ||
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 => RequestHistogram.Enabled; | ||
|
||
public void Dispose() | ||
{ | ||
this.meter.Dispose(); | ||
} | ||
} |
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
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
Oops, something went wrong.