Skip to content

Commit

Permalink
minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
RagingKore committed Jun 6, 2024
1 parent 28c6748 commit 741c432
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ namespace EventStore.Plugins.Diagnostics;
[PublicAPI]
public class PluginDiagnosticsDataCollector : IDisposable {
public PluginDiagnosticsDataCollector(string[] sources, int capacity = 10, OnEventCollected? onEventCollected = null) {
Listener = new(sources, 0, (source, data) => {
Listener = new(sources, capacity, (source, data) => {
if (data is not PluginDiagnosticsData pluginData) return;

CollectedEventsByPlugin.AddOrUpdate(
source,
static (_, state) => [state.PluginData],
Expand All @@ -41,13 +41,13 @@ public PluginDiagnosticsDataCollector(string[] sources, int capacity = 10, OnEve
evt.Data[key] = value;
}
}

break;
}

if (collected.Count > state.Capacity)
collected.Remove(collected.Min);

return collected;
},
(PluginData: pluginData, Capacity: capacity)
Expand All @@ -63,7 +63,7 @@ public PluginDiagnosticsDataCollector(string[] sources, int capacity = 10, OnEve
}

MultiSourceDiagnosticsListener Listener { get; }

ConcurrentDictionary<string, SortedSet<PluginDiagnosticsData>> CollectedEventsByPlugin { get; } = new();

public IEnumerable<PluginDiagnosticsData> CollectedEvents(string source) =>
Expand All @@ -76,7 +76,7 @@ public void ClearCollectedEvents(string source) {
if (CollectedEventsByPlugin.TryGetValue(source, out var data))
data.Clear();
}

public void ClearAllCollectedEvents() {
foreach (var data in CollectedEventsByPlugin.Values)
data.Clear();
Expand All @@ -86,7 +86,7 @@ public void Dispose() {
Listener.Dispose();
CollectedEventsByPlugin.Clear();
}

/// <summary>
/// Starts the <see cref="PluginDiagnosticsDataCollector" /> with the specified delegate and sources.
/// This method is a convenient way to create a new instance of the <see cref="PluginDiagnosticsDataCollector" /> and start collecting data immediately.
Expand All @@ -95,7 +95,7 @@ public void Dispose() {
/// <param name="sources">The plugin diagnostic names to collect diagnostics data from.</param>
public static PluginDiagnosticsDataCollector Start(OnEventCollected onEventCollected, params string[] sources) =>
new(sources, 10, onEventCollected);

/// <summary>
/// Starts the <see cref="PluginDiagnosticsDataCollector" /> with the specified delegate and sources.
/// This method is a convenient way to create a new instance of the <see cref="PluginDiagnosticsDataCollector" /> and start collecting data immediately.
Expand All @@ -122,4 +122,4 @@ public static PluginDiagnosticsDataCollector Start(OnEventCollected onEventColle
/// <param name="capacity">The maximum number of diagnostics data to collect per source.</param>
/// <param name="sources">The plugin diagnostic names to collect diagnostics data from.</param>
public static PluginDiagnosticsDataCollector Start(int capacity, params string[] sources) => new(sources, capacity);
}
}

0 comments on commit 741c432

Please sign in to comment.