Skip to content

Commit

Permalink
code review
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagodaraujo committed Aug 27, 2024
1 parent d8abc88 commit 7350e77
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@
using System.Diagnostics.Metrics;
using System.Reflection;
using OpenTelemetry.Internal;
using OpenTelemetry.Trace;

namespace OpenTelemetry.Instrumentation.StackExchangeRedis.Implementation;

internal class RedisMetrics : IDisposable
{
internal const string DurationMetricName = "db.client.operation.duration";
internal const string QueueTimeMetricName = "db.client.operation.queue_time";
internal const string ServerTimeMetricName = "db.client.operation.server_time";

internal static readonly Assembly Assembly = typeof(StackExchangeRedisInstrumentation).Assembly;
internal static readonly AssemblyName AssemblyName = Assembly.GetName();
Expand All @@ -28,8 +25,7 @@ public RedisMetrics()
this.DurationHistogram = this.meter.CreateHistogram<double>(
DurationMetricName,
unit: "s",
description: "Total client request duration, including processing, queue and server duration.",
[new(SemanticConventions.AttributeDbSystem, "redis")]);
description: "Total client request duration, including processing, queue and server duration.");
}

public static RedisMetrics Instance { get; } = new RedisMetrics();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,14 @@ static bool GetCommandAndKey(
// Total:
// command.ElapsedTime; // 00:00:32.4988020

var flags = command.Flags.ToString();
activity?.SetTag(SemanticConventions.AttributeDbRedisFlagsKeyName, flags);
activity?.SetTag(SemanticConventions.AttributeDbRedisFlagsKeyName, command.Flags.ToString());

var operationName = command.Command ?? string.Empty;
meterTags?.Add(SemanticConventions.AttributeDbOperationName, operationName);
if (command.Command != null)
{
meterTags?.Add(SemanticConventions.AttributeDbOperationName, command.Command);
}

if (activity is not null)
if (activity != null)
{
if (options.SetVerboseDatabaseStatements)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ public class Program
.AddConsoleExporter()
.Build();

using var tracerProvider = Sdk.CreateMeterProviderBuilder()
.AddRedisInstrumentation()
using var meterProvider = Sdk.CreateMeterProviderBuilder()
.AddRedisInstrumentation(connection)
.AddConsoleExporter()
.Build();
}
Expand Down Expand Up @@ -101,8 +101,8 @@ using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddRedisInstrumentation(connection)
.Build();

using var tracerProvider = Sdk.CreateMeterProviderBuilder()
.AddRedisInstrumentation()
using var meterProvider = Sdk.CreateMeterProviderBuilder()
.AddRedisInstrumentation(connection)
.Build();
```

Expand Down

0 comments on commit 7350e77

Please sign in to comment.