Skip to content

Commit e194553

Browse files
committed
Can now handle logical errors.
1 parent 38d1a26 commit e194553

File tree

3 files changed

+24
-82
lines changed

3 files changed

+24
-82
lines changed

src/Server/Coderr.Server.ReportAnalyzer/ErrorReports/HashCodeGenerator.cs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,34 @@ protected virtual string DefaultCreateHashCode(ErrorReportEntity report)
6666

6767

6868
var hashSource = $"{report.Exception.FullName ?? report.Exception.Name}\r\n";
69+
var foundHashSource = false;
6970

7071
// the client libraries can by themselves specify how we should identify
7172
// unqiue incidents. We then use that identifier in combination with the exception name.
7273
var collection = report.ContextCollections.FirstOrDefault(x => x.Name == "CoderrData");
73-
if (collection != null && collection.Properties.TryGetValue("HashSource", out var reportHashSource))
74-
hashSource += reportHashSource;
75-
else
76-
hashSource += StripLineNumbers(report.Exception.StackTrace ?? "");
74+
if (collection != null)
75+
{
76+
if (collection.Properties.TryGetValue("HashSource", out var reportHashSource))
77+
{
78+
foundHashSource = true;
79+
hashSource += reportHashSource;
80+
}
81+
else
82+
hashSource += StripLineNumbers(report.Exception.StackTrace ?? "");
83+
}
84+
if (!foundHashSource)
85+
{
86+
// This identifier is determined by the developer when the error is generated.
87+
foreach (var contextCollection in report.ContextCollections)
88+
{
89+
if (!contextCollection.Properties.TryGetValue("ErrorHashSource", out var ourHashSource))
90+
continue;
91+
92+
hashSource = ourHashSource;
93+
break;
94+
}
95+
}
96+
7797

7898
var hash = 23;
7999
foreach (var c in hashSource)

src/Server/Coderr.Server.Web/Controllers/ReportReceiverController.cs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
using Coderr.Server.App.Core.Reports.Config;
1010
using Coderr.Server.ReportAnalyzer.Inbound;
1111
using Coderr.Server.Web.Infrastructure;
12-
using Coderr.Server.Web.Infrastructure.Misc;
1312
using Coderr.Server.Web.Infrastructure.Results;
1413
using DotNetCqs.Queues;
1514
using Griffin.Data;
@@ -55,9 +54,6 @@ public async Task<IActionResult> Post(string appKey, string sig)
5554
return await KillLargeReportAsync(appKey);
5655
if (contentLength == null || contentLength < 1)
5756
return BadRequest("Content required.");
58-
59-
if (!IsBelowReportLimit()) return NoContent();
60-
6157
try
6258
{
6359
var buffer = new byte[contentLength.Value];
@@ -112,30 +108,6 @@ internal static ClaimsPrincipal CreateReporterPrincipal()
112108
return principal;
113109
}
114110

115-
private bool IsBelowReportLimit()
116-
{
117-
if (!string.IsNullOrEmpty(License.LicensedTo))
118-
return true;
119-
120-
var count = License.Count / 5;
121-
count = count / 10;
122-
123-
if (_currentReportCount == 0)
124-
using (var cmd = _unitOfWork.CreateDbCommand())
125-
{
126-
var from = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1);
127-
cmd.CommandText =
128-
"SELECT count(*) FROM ErrorReports WHERE CreatedAtUtc >= @from AND CreatedAtUtc <= @to";
129-
cmd.AddParameter("from", from);
130-
cmd.AddParameter("to", DateTime.Now);
131-
_currentReportCount = (int) cmd.ExecuteScalar();
132-
}
133-
else
134-
_currentReportCount++;
135-
136-
return _currentReportCount < count;
137-
}
138-
139111
private Task<IActionResult> KillLargeReportAsync(string appKey)
140112
{
141113
_logger.Error(appKey + "Too large report: " + Request.ContentLength + " from " +

src/Server/Coderr.Server.Web/Infrastructure/Misc/License.cs

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)