Skip to content

Commit

Permalink
Feedback, remodel timing and counters
Browse files Browse the repository at this point in the history
  • Loading branch information
westin-m committed Dec 4, 2024
1 parent ebc0740 commit 09c3b49
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 87 deletions.
2 changes: 1 addition & 1 deletion build/dependencies.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<MicrosoftSourceLinkGitHubVersion>1.0.0</MicrosoftSourceLinkGitHubVersion>
<NetStandardVersion>2.0.3</NetStandardVersion>
<NewtonsoftVersion>13.0.3</NewtonsoftVersion>
<SystemDiagnosticSourceVersion>7.0.2</SystemDiagnosticSourceVersion>
<SystemDiagnosticSourceVersion>9.0.0</SystemDiagnosticSourceVersion>
<SystemMemoryVersion>4.5.5</SystemMemoryVersion>
<SystemSecurityCryptographyCngVersion>4.5.0</SystemSecurityCryptographyCngVersion>
<SystemTextJson>8.0.5</SystemTextJson>
Expand Down
2 changes: 1 addition & 1 deletion build/dependenciesTest.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<MicrosoftNETTestSdkVersion>17.11.1</MicrosoftNETTestSdkVersion>
<NetStandardVersion>2.0.3</NetStandardVersion>
<NewtonsoftVersion>13.0.3</NewtonsoftVersion>
<OpenTelemetryVersion>1.10.0</OpenTelemetryVersion>
<OpenTelemetryVersion>1.6.0</OpenTelemetryVersion>
<SystemNetHttp>4.3.4</SystemNetHttp>
<SystemSecurityClaimsVersion>4.3.0</SystemSecurityClaimsVersion>
<SystemTextJson>8.0.5</SystemTextJson>
Expand Down
10 changes: 5 additions & 5 deletions src/Microsoft.IdentityModel.Logging/IdentityModelTelemetry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@ internal class IdentityModelTelemetry
/// <summary>
/// The meter responsible for creating instruments.
/// </summary>
public static readonly Meter WilsonMeter = new(MeterName, "1.0.0");
public static readonly Meter IdentityModelMeter = new(MeterName, "1.0.0");

internal const string TotalDurationHistogramName = "IdentityModelConfigurationRequestTotalDurationInMS";

/// <summary>
/// Counter to capture requests to configuration manager.
/// </summary>
internal const string WilsonConfigurationManagerCounterName = "WilsonConfigurationManagerCounter";
internal const string WilsonConfigurationManagerCounterDescription = "Counter capturing configuration manager operations.";
internal static readonly Counter<long> ConfigurationManagerCounter = WilsonMeter.CreateCounter<long>(WilsonConfigurationManagerCounterName, description: WilsonConfigurationManagerCounterDescription);
internal const string IdentityModelConfigurationManagerCounterName = "WilsonConfigurationManagerCounter";
internal const string IdentityModelConfigurationManagerCounterDescription = "Counter capturing configuration manager operations.";
internal static readonly Counter<long> ConfigurationManagerCounter = IdentityModelMeter.CreateCounter<long>(IdentityModelConfigurationManagerCounterName, description: IdentityModelConfigurationManagerCounterDescription);

/// <summary>
/// Histogram to capture total duration of configuration manager operations in milliseconds.
/// </summary>
internal static readonly Histogram<long> TotalDurationHistogram = WilsonMeter.CreateHistogram<long>(
internal static readonly Histogram<long> TotalDurationHistogram = IdentityModelMeter.CreateHistogram<long>(
TotalDurationHistogramName,
unit: "ms",
description: "Performance of getting configuration calls total latency");
Expand Down
60 changes: 33 additions & 27 deletions src/Microsoft.IdentityModel.Logging/IdentityModelTelemetryUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
using System;
using System.Collections.Generic;
using System.Collections.Concurrent;
using System.Diagnostics;
using System.Reflection;
using System.Net.Http;
using System.Diagnostics;

namespace Microsoft.IdentityModel.Logging
{
Expand All @@ -25,19 +25,15 @@ public static class IdentityModelTelemetryUtil
};

// Static attribute tags
internal const string WilsonVersionTag = "WilsonVersion";
internal const string IdentityModelVersionTag = "IdentityModelVersion";
internal const string MetadataAddressTag = "MetadataAddress";
internal const string RefreshReasonTag = "RefreshReason";
internal const string OperationStatusTag = "OperationStatus";
internal const string ExceptionTypeTag = "ExceptionType";

// Validation result values
internal const string Success = "Success";
internal const string Failure = "Failure";

// Configuration manager refresh reasons
internal const string Requested = "Requested";
internal const string Scheduled = "Scheduled";
// Configuration manager refresh statuses
internal const string Automatic = "Automatic";
internal const string Direct = "Direct";
internal const string FirstRefresh = "FirstRefresh";
internal const string LKG = "LastKnownGood";

// Configuration manager exception types
Expand Down Expand Up @@ -159,40 +155,50 @@ internal static bool UpdateDefaultTelemetryData(string key, string value)
}

internal static void IncrementConfigurationManagerCounter(
string metadataAddress,
string refreshReason,
string operationStatus,
string exceptionType)
string operationStatus)
{
var tagList = new TagList()
{
{ WilsonVersionTag, ClientVer },
{ MetadataAddressTag, metadataAddress },
{ RefreshReasonTag, refreshReason},
{ OperationStatusTag, operationStatus },
{ ExceptionTypeTag, exceptionType }
{ IdentityModelVersionTag, ClientVer },
{ OperationStatusTag, operationStatus }
};

IdentityModelTelemetry.IncrementConfigurationManagerCounter(tagList);
}

internal static void RecordTotalDuration(
long durationInMs,
string metadataAddress,
string refreshReason,
internal static void IncrementConfigurationManagerCounter(
string operationStatus,
string exceptionType)
{
var tagList = new TagList()
{
{ WilsonVersionTag, ClientVer },
{ MetadataAddressTag, metadataAddress },
{ RefreshReasonTag, refreshReason},
{ IdentityModelVersionTag, ClientVer },
{ OperationStatusTag, operationStatus },
{ ExceptionTypeTag, exceptionType }
};

IdentityModelTelemetry.RecordTotalDurationHistogram(durationInMs, tagList);
IdentityModelTelemetry.IncrementConfigurationManagerCounter(tagList);
}

internal static void RecordTotalDuration(long totalMilliseconds)
{
var tagList = new TagList()
{
{ IdentityModelVersionTag, ClientVer }
};

IdentityModelTelemetry.RecordTotalDurationHistogram(totalMilliseconds, tagList);
}

internal static void RecordTotalDuration(long totalMilliseconds, string exception)
{
var tagList = new TagList()
{
{ IdentityModelVersionTag, ClientVer },
{ ExceptionTypeTag, exception }
};

IdentityModelTelemetry.RecordTotalDurationHistogram(totalMilliseconds, tagList);
}
}
}
22 changes: 11 additions & 11 deletions src/Microsoft.IdentityModel.Logging/InternalAPI.Unshipped.txt
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
const Microsoft.IdentityModel.Logging.IdentityModelTelemetry.IdentityModelConfigurationManagerCounterDescription = "Counter capturing configuration manager operations." -> string
const Microsoft.IdentityModel.Logging.IdentityModelTelemetry.IdentityModelConfigurationManagerCounterName = "WilsonConfigurationManagerCounter" -> string
const Microsoft.IdentityModel.Logging.IdentityModelTelemetry.MeterName = "MicrosoftIdentityModel_Meter" -> string
const Microsoft.IdentityModel.Logging.IdentityModelTelemetry.ServiceName = "MicrosoftIdentityModel" -> string
const Microsoft.IdentityModel.Logging.IdentityModelTelemetry.TotalDurationHistogramName = "IdentityModelConfigurationRequestTotalDurationInMS" -> string
const Microsoft.IdentityModel.Logging.IdentityModelTelemetry.WilsonConfigurationManagerCounterDescription = "Counter capturing configuration manager operations." -> string
const Microsoft.IdentityModel.Logging.IdentityModelTelemetry.WilsonConfigurationManagerCounterName = "WilsonConfigurationManagerCounter" -> string
const Microsoft.IdentityModel.Logging.IdentityModelTelemetryUtil.Automatic = "Automatic" -> string
const Microsoft.IdentityModel.Logging.IdentityModelTelemetryUtil.ConfigurationInvalid = "ConfigurationInvalid" -> string
const Microsoft.IdentityModel.Logging.IdentityModelTelemetryUtil.ConfigurationRetrievalFailed = "ConfigurationRetrievalFailed" -> string
const Microsoft.IdentityModel.Logging.IdentityModelTelemetryUtil.Direct = "Direct" -> string
const Microsoft.IdentityModel.Logging.IdentityModelTelemetryUtil.ExceptionTypeTag = "ExceptionType" -> string
const Microsoft.IdentityModel.Logging.IdentityModelTelemetryUtil.Failure = "Failure" -> string
const Microsoft.IdentityModel.Logging.IdentityModelTelemetryUtil.FirstRefresh = "FirstRefresh" -> string
const Microsoft.IdentityModel.Logging.IdentityModelTelemetryUtil.IdentityModelVersionTag = "IdentityModelVersion" -> string
const Microsoft.IdentityModel.Logging.IdentityModelTelemetryUtil.LKG = "LastKnownGood" -> string
const Microsoft.IdentityModel.Logging.IdentityModelTelemetryUtil.MetadataAddressTag = "MetadataAddress" -> string
const Microsoft.IdentityModel.Logging.IdentityModelTelemetryUtil.OperationStatusTag = "OperationStatus" -> string
const Microsoft.IdentityModel.Logging.IdentityModelTelemetryUtil.RefreshReasonTag = "RefreshReason" -> string
const Microsoft.IdentityModel.Logging.IdentityModelTelemetryUtil.Requested = "Requested" -> string
const Microsoft.IdentityModel.Logging.IdentityModelTelemetryUtil.Scheduled = "Scheduled" -> string
const Microsoft.IdentityModel.Logging.IdentityModelTelemetryUtil.Success = "Success" -> string
const Microsoft.IdentityModel.Logging.IdentityModelTelemetryUtil.WilsonVersionTag = "WilsonVersion" -> string
Microsoft.IdentityModel.Logging.IdentityModelTelemetry
Microsoft.IdentityModel.Logging.IdentityModelTelemetry.IdentityModelTelemetry() -> void
Microsoft.IdentityModel.Logging.WatchUtility
Microsoft.IdentityModel.Logging.WatchUtility.WatchUtility() -> void
static Microsoft.IdentityModel.Logging.IdentityModelTelemetry.IncrementConfigurationManagerCounter(in System.Diagnostics.TagList tagList) -> void
static Microsoft.IdentityModel.Logging.IdentityModelTelemetry.RecordTotalDurationHistogram(long requestDurationInMs, in System.Diagnostics.TagList tagList) -> void
static Microsoft.IdentityModel.Logging.IdentityModelTelemetryUtil.IncrementConfigurationManagerCounter(string metadataAddress, string refreshReason, string operationStatus, string exceptionType) -> void
static Microsoft.IdentityModel.Logging.IdentityModelTelemetryUtil.RecordTotalDuration(long durationInMs, string metadataAddress, string refreshReason, string operationStatus, string exceptionType) -> void
static Microsoft.IdentityModel.Logging.IdentityModelTelemetryUtil.IncrementConfigurationManagerCounter(string operationStatus) -> void
static Microsoft.IdentityModel.Logging.IdentityModelTelemetryUtil.IncrementConfigurationManagerCounter(string operationStatus, string exceptionType) -> void
static Microsoft.IdentityModel.Logging.IdentityModelTelemetryUtil.RecordTotalDuration(long totalMilliseconds) -> void
static Microsoft.IdentityModel.Logging.IdentityModelTelemetryUtil.RecordTotalDuration(long totalMilliseconds, string exception) -> void
static readonly Microsoft.IdentityModel.Logging.IdentityModelTelemetry.ConfigurationManagerCounter -> System.Diagnostics.Metrics.Counter<long>
static readonly Microsoft.IdentityModel.Logging.IdentityModelTelemetry.IdentityModelMeter -> System.Diagnostics.Metrics.Meter
static readonly Microsoft.IdentityModel.Logging.IdentityModelTelemetry.TotalDurationHistogram -> System.Diagnostics.Metrics.Histogram<long>
static readonly Microsoft.IdentityModel.Logging.IdentityModelTelemetry.WilsonMeter -> System.Diagnostics.Metrics.Meter
static readonly Microsoft.IdentityModel.Logging.WatchUtility.Watch -> System.Diagnostics.Stopwatch
15 changes: 0 additions & 15 deletions src/Microsoft.IdentityModel.Logging/WatchUtility.cs

This file was deleted.

Loading

0 comments on commit 09c3b49

Please sign in to comment.