-
Notifications
You must be signed in to change notification settings - Fork 305
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
a38b2f0
commit 33d9561
Showing
14 changed files
with
584 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,12 @@ | |
|
||
## Unreleased | ||
|
||
* Add `OpenTelemetry.Instrumentation.StackExchangeRedis` meter. Supported metrics: | ||
* `redis.client.request.duration`, | ||
* `redis.client.queue.duration`, | ||
* `redis.client.network.duration`. | ||
([#1982](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1982)) | ||
Check failure on line 9 in src/OpenTelemetry.Instrumentation.StackExchangeRedis/CHANGELOG.md GitHub Actions / lint-md / run-markdownlintTrailing spaces
Check failure on line 9 in src/OpenTelemetry.Instrumentation.StackExchangeRedis/CHANGELOG.md GitHub Actions / lint-md / run-markdownlintLine length
|
||
|
||
## 1.9.0-beta.1 | ||
|
||
Released 2024-Jul-23 | ||
|
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.