Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 34 additions & 4 deletions src/Orleans.Core/Diagnostics/Metrics/CatalogInstruments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,46 @@ namespace Orleans.Runtime;

internal static class CatalogInstruments
{
internal const string ActivationOutcomeCanceled = "canceled";
internal const string ActivationOutcomeDuplicate = "duplicate";
internal const string ActivationOutcomeFailure = "failure";
internal const string ActivationOutcomeSuccess = "success";

internal const string DeactivationViaCollection = "collection";
internal const string DeactivationViaDeactivateOnIdle = "deactivateOnIdle";
internal const string DeactivationViaDeactivateStuckActivation = "deactivateStuckActivation";
internal const string DeactivationViaMigration = "migration";
internal const string DeactivationViaUnknown = "unknown";

internal static Counter<int> ActivationFailedToActivate = Instruments.Meter.CreateCounter<int>(InstrumentNames.CATALOG_ACTIVATION_FAILED_TO_ACTIVATE);

internal static Counter<int> ActivationCollections = Instruments.Meter.CreateCounter<int>(InstrumentNames.CATALOG_ACTIVATION_COLLECTION_NUMBER_OF_COLLECTIONS);

internal static Counter<int> ActivationShutdown = Instruments.Meter.CreateCounter<int>(InstrumentNames.CATALOG_ACTIVATION_SHUTDOWN);

internal static void ActivationShutdownViaCollection() => ActivationShutdown.Add(1, new KeyValuePair<string, object>("via", "collection"));
internal static void ActivationShutdownViaDeactivateOnIdle() => ActivationShutdown.Add(1, new KeyValuePair<string, object>("via", "deactivateOnIdle"));
internal static void ActivationShutdownViaMigration() => ActivationShutdown.Add(1, new KeyValuePair<string, object>("via", "migration"));
internal static void ActivationShutdownViaDeactivateStuckActivation() => ActivationShutdown.Add(1, new KeyValuePair<string, object>("via", "deactivateStuckActivation"));
internal static void ActivationShutdownViaCollection() => ActivationShutdown.Add(1, new KeyValuePair<string, object>("via", DeactivationViaCollection));
internal static void ActivationShutdownViaDeactivateOnIdle() => ActivationShutdown.Add(1, new KeyValuePair<string, object>("via", DeactivationViaDeactivateOnIdle));
internal static void ActivationShutdownViaMigration() => ActivationShutdown.Add(1, new KeyValuePair<string, object>("via", DeactivationViaMigration));
internal static void ActivationShutdownViaDeactivateStuckActivation() => ActivationShutdown.Add(1, new KeyValuePair<string, object>("via", DeactivationViaDeactivateStuckActivation));

internal static Histogram<double> ActivationLatency = Instruments.Meter.CreateHistogram<double>(InstrumentNames.CATALOG_ACTIVATION_LATENCY, "ms");
internal static Histogram<double> DeactivationLatency = Instruments.Meter.CreateHistogram<double>(InstrumentNames.CATALOG_DEACTIVATION_LATENCY, "ms");

internal static void OnActivationCompleted(TimeSpan latency, string outcome)
{
if (ActivationLatency.Enabled)
{
ActivationLatency.Record(latency.TotalMilliseconds, new KeyValuePair<string, object>("outcome", outcome));
}
}

internal static void OnDeactivationCompleted(TimeSpan latency, string via)
{
if (DeactivationLatency.Enabled)
{
DeactivationLatency.Record(latency.TotalMilliseconds, new KeyValuePair<string, object>("via", via));
}
}

internal static Counter<int> NonExistentActivations = Instruments.Meter.CreateCounter<int>(InstrumentNames.CATALOG_ACTIVATION_NON_EXISTENT_ACTIVATIONS);

Expand Down
2 changes: 2 additions & 0 deletions src/Orleans.Core/Diagnostics/Metrics/InstrumentNames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ internal static class InstrumentNames
public const string CATALOG_ACTIVATION_WORKING_SET = "orleans-catalog-activation-working-set";
public const string CATALOG_ACTIVATION_CREATED = "orleans-catalog-activation-created";
public const string CATALOG_ACTIVATION_DESTROYED = "orleans-catalog-activation-destroyed";
public const string CATALOG_ACTIVATION_LATENCY = "orleans-catalog-activation-latency";
public const string CATALOG_DEACTIVATION_LATENCY = "orleans-catalog-deactivation-latency";
public const string CATALOG_ACTIVATION_FAILED_TO_ACTIVATE = "orleans-catalog-activation-failed-to-activate";
public const string CATALOG_ACTIVATION_COLLECTION_NUMBER_OF_COLLECTIONS = "orleans-catalog-activation-collections";
public const string CATALOG_ACTIVATION_SHUTDOWN = "orleans-catalog-activation-shutdown";
Expand Down
Loading
Loading