Skip to content

Commit 632fb82

Browse files
committed
Added metric for field count
1 parent 5b6a409 commit 632fb82

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/Exceptionless.Core/Pipeline/035_CopySimpleDataToIdxAction.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,32 @@
11
using System;
22
using System.Threading.Tasks;
3+
using Exceptionless.Core.AppStats;
34
using Exceptionless.Core.Plugins.EventProcessor;
5+
using Foundatio.Metrics;
46
using Microsoft.Extensions.Logging;
57

68
namespace Exceptionless.Core.Pipeline {
79
[Priority(40)]
810
public class CopySimpleDataToIdxAction : EventPipelineActionBase {
9-
public CopySimpleDataToIdxAction(ILoggerFactory loggerFactory = null) : base(loggerFactory) {}
11+
private readonly IMetricsClient _metricsClient;
12+
13+
public CopySimpleDataToIdxAction(IMetricsClient metricsClient, ILoggerFactory loggerFactory = null) : base(loggerFactory) {
14+
_metricsClient = metricsClient;
15+
}
1016

1117
public override Task ProcessAsync(EventContext ctx) {
1218
if (!ctx.Organization.HasPremiumFeatures)
1319
return Task.CompletedTask;
1420

1521
// TODO: Do we need a pipeline action to trim keys and remove null values that may be sent by other native clients.
1622
ctx.Event.CopyDataToIndex(Array.Empty<string>());
23+
int fieldCount = ctx.Event.Idx.Count;
24+
_metricsClient.Gauge(MetricNames.EventsFieldCount, fieldCount);
25+
if (fieldCount > 20 && _logger.IsEnabled(LogLevel.Warning)) {
26+
var ev = ctx.Event;
27+
using (_logger.BeginScope(new ExceptionlessState().Organization(ctx.Organization.Id).Property("Event", new { ev.Date, ev.StackId, ev.Type, ev.Source, ev.Message, ev.Value, ev.Geo, ev.ReferenceId, ev.Tags, ev.Idx })))
28+
_logger.LogWarning("Event has {FieldCount} indexed fields.", fieldCount);
29+
}
1730

1831
return Task.CompletedTask;
1932
}

src/Exceptionless.Core/Utility/MetricNames.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public static class MetricNames {
1010
public const string EventsProcessCancelled = "events.processing.cancelled";
1111
public const string EventsRetryCount = "events.retry.count";
1212
public const string EventsRetryErrors = "events.retry.errors";
13+
public const string EventsFieldCount = "events.field.count";
1314

1415
public const string PostsParsed = "posts.parsed";
1516
public const string PostsEventCount = "posts.eventcount";

0 commit comments

Comments
 (0)