Skip to content

Commit 4af9be8

Browse files
committed
Added extra logging to event submission
1 parent 64ba149 commit 4af9be8

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

Source/Api/Controllers/EventController.cs

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public async Task<IHttpActionResult> GetByIdAsync(string id, string filter = nul
9292
var organization = await GetOrganizationAsync(model.OrganizationId);
9393
if (organization == null)
9494
return NotFound();
95-
95+
9696
if (organization.IsSuspended || organization.RetentionDays > 0 && model.Date.UtcDateTime < SystemClock.UtcNow.SubtractDays(organization.RetentionDays))
9797
return PlanLimitReached("Unable to view event occurrence due to plan limits.");
9898

@@ -318,7 +318,7 @@ public async Task<IHttpActionResult> GetByReferenceIdAsync(string referenceId, s
318318
var project = await GetProjectAsync(projectId);
319319
if (project == null)
320320
return NotFound();
321-
321+
322322
var organization = await GetOrganizationAsync(project.OrganizationId);
323323
if (organization == null)
324324
return NotFound();
@@ -378,7 +378,7 @@ public async Task<IHttpActionResult> GetBySessionIdAsync(string sessionId, strin
378378
var project = await GetProjectAsync(projectId);
379379
if (project == null)
380380
return NotFound();
381-
381+
382382
var organization = await GetOrganizationAsync(project.OrganizationId);
383383
if (organization == null)
384384
return NotFound();
@@ -448,7 +448,7 @@ public async Task<IHttpActionResult> GetBySessionAsync(string projectId, string
448448
var sf = new ExceptionlessSystemFilterQuery(project, organization);
449449
return await GetInternalAsync(sf, ti, $"type:{Event.KnownTypes.Session} {filter}", sort, mode, page, limit, true);
450450
}
451-
451+
452452
/// <summary>
453453
/// Set user description
454454
/// </summary>
@@ -566,12 +566,12 @@ public async Task<IHttpActionResult> RecordHeartbeatAsync(string projectId = nul
566566
/// </summary>
567567
/// <remarks>
568568
/// You can create an event using query string parameters.
569-
///
569+
///
570570
/// Feature usage named build with a duration of 10:
571571
/// <code><![CDATA[/events/submit?access_token=YOUR_API_KEY&type=usage&source=build&value=10]]></code>
572572
/// OR
573573
/// <code><![CDATA[/events/submit/usage?access_token=YOUR_API_KEY&source=build&value=10]]></code>
574-
///
574+
///
575575
/// Log with message, geo and extended data
576576
/// <code><![CDATA[/events/submit?access_token=YOUR_API_KEY&type=log&message=Hello World&source=server01&geo=32.85,-96.9613&randomproperty=true]]></code>
577577
/// OR
@@ -769,6 +769,18 @@ await _eventPostQueue.EnqueueAsync(new EventPostInfo {
769769
// Set the project for the configuration response filter.
770770
Request.SetProject(project);
771771

772+
if (data.LongLength > Settings.Current.MaximumEventPostSize) {
773+
_logger.Error().Critical()
774+
.Message("Attempting to enqueue events greater than the maxiumum queue size")
775+
.Project(projectId)
776+
.Identity(ExceptionlessUser?.EmailAddress)
777+
.Property("User", ExceptionlessUser)
778+
.Property("Headers", Request.Content.Headers)
779+
.Property("Size", data.LongLength)
780+
.Property("MaximumEventPostSize", Settings.Current.MaximumEventPostSize)
781+
.SetActionContext(ActionContext);
782+
}
783+
772784
string contentEncoding = Request.Content.Headers.ContentEncoding.ToString();
773785
bool isCompressed = contentEncoding == "gzip" || contentEncoding == "deflate";
774786
if (!isCompressed && data.Length > 1000) {
@@ -819,7 +831,7 @@ public Task<IHttpActionResult> DeleteAsync(string ids) {
819831
private Task<Organization> GetOrganizationAsync(string organizationId, bool useCache = true) {
820832
if (String.IsNullOrEmpty(organizationId) || !CanAccessOrganization(organizationId))
821833
return null;
822-
834+
823835
return _organizationRepository.GetByIdAsync(organizationId, useCache);
824836
}
825837

@@ -833,7 +845,7 @@ private async Task<Project> GetProjectAsync(string projectId, bool useCache = tr
833845

834846
return project;
835847
}
836-
848+
837849
private async Task<Stack> GetStackAsync(string stackId, bool useCache = true) {
838850
if (String.IsNullOrEmpty(stackId))
839851
return null;

Source/Api/Utility/Handlers/OverageHandler.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ private bool IsEventPost(HttpRequestMessage request) {
2929
if (request.Method != HttpMethod.Post)
3030
return false;
3131

32-
return request.RequestUri.AbsolutePath.EndsWith("/events", StringComparison.OrdinalIgnoreCase)
32+
return request.RequestUri.AbsolutePath.EndsWith("/events", StringComparison.OrdinalIgnoreCase)
3333
|| String.Equals(request.RequestUri.AbsolutePath, "/api/v1/error", StringComparison.OrdinalIgnoreCase);
3434
}
3535

@@ -41,7 +41,7 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
4141
return CreateResponse(request, HttpStatusCode.ServiceUnavailable, "Service Unavailable");
4242

4343
bool tooBig = false;
44-
if (request.Content?.Headers != null) {
44+
if (request.Method == HttpMethod.Post && request.Content?.Headers != null) {
4545
long size = request.Content.Headers.ContentLength.GetValueOrDefault();
4646
await _metricsClient.GaugeAsync(MetricNames.PostsSize, size);
4747
if (size > Settings.Current.MaximumEventPostSize) {
@@ -64,7 +64,7 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
6464

6565
return await base.SendAsync(request, cancellationToken);
6666
}
67-
67+
6868
private HttpResponseMessage CreateResponse(HttpRequestMessage request, HttpStatusCode statusCode, string message) {
6969
HttpResponseMessage response = request.CreateResponse(statusCode);
7070
response.ReasonPhrase = message;

0 commit comments

Comments
 (0)