Skip to content

Commit 3195661

Browse files
committed
Merge pull request #82 from exceptionless/feature/stacking
Updates for custom stacking
2 parents fbe6c96 + 4df268f commit 3195661

File tree

14 files changed

+148
-24
lines changed

14 files changed

+148
-24
lines changed

Source/Samples/SampleConsole/Exceptionless.SampleConsole.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@
4444
</AssemblyOriginatorKeyFile>
4545
</PropertyGroup>
4646
<ItemGroup>
47-
<Reference Include="Exceptionless.DateTimeExtensions, Version=3.1.42.0, Culture=neutral, processorArchitecture=MSIL">
48-
<HintPath>..\..\..\packages\Exceptionless.DateTimeExtensions.3.1.42\lib\portable-net40+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\Exceptionless.DateTimeExtensions.dll</HintPath>
47+
<Reference Include="Exceptionless.DateTimeExtensions, Version=3.1.44.0, Culture=neutral, processorArchitecture=MSIL">
48+
<HintPath>..\..\..\packages\Exceptionless.DateTimeExtensions.3.1.44\lib\portable-net40+win+wpa81+MonoAndroid10+xamarinios10+MonoTouch10\Exceptionless.DateTimeExtensions.dll</HintPath>
4949
<Private>True</Private>
5050
</Reference>
51-
<Reference Include="Exceptionless.RandomData, Version=1.0.17.0, Culture=neutral, processorArchitecture=MSIL">
52-
<HintPath>..\..\..\packages\Exceptionless.RandomData.1.0.17.0\lib\net40\Exceptionless.RandomData.dll</HintPath>
51+
<Reference Include="Exceptionless.RandomData, Version=1.0.21.0, Culture=neutral, processorArchitecture=MSIL">
52+
<HintPath>..\..\..\packages\Exceptionless.RandomData.1.0.21.0\lib\net40\Exceptionless.RandomData.dll</HintPath>
5353
<Private>True</Private>
5454
</Reference>
5555
<Reference Include="log4net, Version=1.2.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">

Source/Samples/SampleConsole/packages.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="Exceptionless.DateTimeExtensions" version="3.1.42" targetFramework="net451" />
4-
<package id="Exceptionless.RandomData" version="1.0.17.0" targetFramework="net452" />
3+
<package id="Exceptionless.DateTimeExtensions" version="3.1.44" targetFramework="net452" />
4+
<package id="Exceptionless.RandomData" version="1.0.21.0" targetFramework="net452" />
55
<package id="log4net" version="2.0.5" targetFramework="net451" />
66
<package id="NLog" version="4.2.3" targetFramework="net451" />
77
<package id="NLog.Config" version="4.2.3" targetFramework="net451" />

Source/Samples/SampleMvc/Controllers/HomeController.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.Threading;
34
using System.Web;
45
using System.Web.Mvc;
@@ -32,6 +33,23 @@ public ViewResult Error() {
3233
public ViewResult CustomError() {
3334
return View("CustomError");
3435
}
36+
37+
[HttpGet]
38+
public ViewResult ManualStacking(string myId) {
39+
ExceptionlessClient.Default.CreateLog(nameof(HomeController), "Random Log message")
40+
.SetManualStackingInfo("Manual Stacked Log Messages", new Dictionary<string, string> {
41+
{ "Controller", nameof(HomeController) },
42+
{ "Action", nameof(ManualStacking) }
43+
})
44+
.Submit();
45+
46+
try {
47+
throw new Exception(Guid.NewGuid().ToString());
48+
} catch (Exception ex) {
49+
ex.ToExceptionless().SetManualStackingKey(nameof(HomeController)).Submit();
50+
throw;
51+
}
52+
}
3553

3654
[HttpGet]
3755
public ViewResult FourZeroFour() {

Source/Samples/SampleMvc/Controllers/ValuesController.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ namespace Exceptionless.SampleMvc.Controllers {
66
public class ValuesController : ApiController {
77
// GET api/values
88
public IEnumerable<string> Get() {
9-
throw new ApplicationException("WebApi GET error");
9+
try {
10+
throw new ApplicationException("WebApi GET error");
11+
} catch (Exception ex) {
12+
ex.ToExceptionless().Submit();
13+
throw;
14+
}
1015
}
1116

1217
// GET api/values/5

Source/Samples/SampleMvc/Views/Home/Index.cshtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
@Html.ActionLink("Boom!", "Boom")
44
@Html.ActionLink("Custom Boom!", "CustomBoom")
55
@Html.ActionLink("Boom 25!", "Boom25")
6+
@Html.ActionLink("Manual Stacking", "ManualStacking", new { myId = "123456789" })
67

78
<a href="javascript:doAjax()">Ajax Boom</a>
89

Source/Shared/Exceptionless.Portable.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
<Compile Include="Dependency\TinyIoC.cs" />
6161
<Compile Include="Events\EventSubmissionEventArgsBase.cs" />
6262
<Compile Include="Events\EventSubmittedEventArgs.cs" />
63+
<Compile Include="Models\Client\Data\ManualStackingInfo.cs" />
6364
<Compile Include="Plugins\Default\025_SessionIdManagementPlugin.cs" />
6465
<Compile Include="Plugins\Default\030_DuplicateCheckerPlugin.cs" />
6566
<Compile Include="Plugins\ContextData.cs" />

Source/Shared/Extensions/EventBuilderExtensions.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections.Generic;
23
using Exceptionless.Models.Data;
34

45
namespace Exceptionless {
@@ -55,6 +56,27 @@ public static EventBuilder SetVersion(this EventBuilder builder, string version)
5556
return builder;
5657
}
5758

59+
/// <summary>
60+
/// Changes default stacking behavior by setting the stacking key.
61+
/// </summary>
62+
/// <param name="builder">The event builder object.</param>
63+
/// <param name="signatureData">Key value pair that determines how the event is stacked.</param>
64+
public static EventBuilder SetManualStackingInfo(this EventBuilder builder, IDictionary<string, string> signatureData) {
65+
builder.Target.SetManualStackingInfo(signatureData);
66+
return builder;
67+
}
68+
69+
/// <summary>
70+
/// Changes default stacking behavior by setting the stacking key.
71+
/// </summary>
72+
/// <param name="builder">The event builder object.</param>
73+
/// <param name="title">The stack title.</param>
74+
/// <param name="signatureData">Key value pair that determines how the event is stacked.</param>
75+
public static EventBuilder SetManualStackingInfo(this EventBuilder builder, string title, IDictionary<string, string> signatureData) {
76+
builder.Target.SetManualStackingInfo(title, signatureData);
77+
return builder;
78+
}
79+
5880
/// <summary>
5981
/// Changes default stacking behavior by setting the stacking key.
6082
/// </summary>
@@ -64,5 +86,16 @@ public static EventBuilder SetManualStackingKey(this EventBuilder builder, strin
6486
builder.Target.SetManualStackingKey(manualStackingKey);
6587
return builder;
6688
}
89+
90+
/// <summary>
91+
/// Changes default stacking behavior by setting the stacking key.
92+
/// </summary>
93+
/// <param name="builder">The event builder object.</param>
94+
/// <param name="title">The stack title.</param>
95+
/// <param name="manualStackingKey">The manual stacking key.</param>
96+
public static EventBuilder SetManualStackingKey(this EventBuilder builder, string title, string manualStackingKey) {
97+
builder.Target.SetManualStackingKey(title, manualStackingKey);
98+
return builder;
99+
}
67100
}
68101
}

Source/Shared/Extensions/EventExtensions.cs

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,15 +281,53 @@ private static bool IsValidIdentifier(string value) {
281281
}
282282

283283
/// <summary>
284-
/// Sets the manual stacking key
284+
/// Changes default stacking behavior
285+
/// </summary>
286+
/// <param name="ev">The event</param>
287+
/// <param name="signatureData">Key value pair that determines how the event is stacked.</param>
288+
public static void SetManualStackingInfo(this Event ev, IDictionary<string, string> signatureData) {
289+
if (signatureData == null || signatureData.Count == 0)
290+
return;
291+
292+
ev.Data[Event.KnownDataKeys.ManualStackingInfo] = new ManualStackingInfo(signatureData);
293+
}
294+
295+
/// <summary>
296+
/// Changes default stacking behavior
297+
/// </summary>
298+
/// <param name="ev">The event</param>
299+
/// <param name="title">The stack title.</param>
300+
/// <param name="signatureData">Key value pair that determines how the event is stacked.</param>
301+
public static void SetManualStackingInfo(this Event ev, string title, IDictionary<string, string> signatureData) {
302+
if (String.IsNullOrWhiteSpace(title) || signatureData == null || signatureData.Count == 0)
303+
return;
304+
305+
ev.Data[Event.KnownDataKeys.ManualStackingInfo] = new ManualStackingInfo(title, signatureData);
306+
}
307+
308+
/// <summary>
309+
/// Changes default stacking behavior by setting the stacking info.
285310
/// </summary>
286311
/// <param name="ev">The event</param>
287312
/// <param name="manualStackingKey">The manual stacking key.</param>
288313
public static void SetManualStackingKey(this Event ev, string manualStackingKey) {
289314
if (String.IsNullOrWhiteSpace(manualStackingKey))
290315
return;
291316

292-
ev.Data[Event.KnownDataKeys.ManualStackingKey] = manualStackingKey.Trim();
317+
ev.Data[Event.KnownDataKeys.ManualStackingInfo] = new ManualStackingInfo(null, new Dictionary<string, string> { { "ManualStackingKey", manualStackingKey } });
318+
}
319+
320+
/// <summary>
321+
/// Changes default stacking behavior by setting the stacking info.
322+
/// </summary>
323+
/// <param name="ev">The event</param>
324+
/// <param name="title">The stack title.</param>
325+
/// <param name="manualStackingKey">The manual stacking key.</param>
326+
public static void SetManualStackingKey(this Event ev, string title, string manualStackingKey) {
327+
if (String.IsNullOrWhiteSpace(title) || String.IsNullOrWhiteSpace(manualStackingKey))
328+
return;
329+
330+
ev.Data[Event.KnownDataKeys.ManualStackingInfo] = new ManualStackingInfo(title, new Dictionary<string, string> { { "ManualStackingKey", manualStackingKey } });
293331
}
294332

295333
public static T GetDataValue<T>(this Event ev, string key, IJsonSerializer serializer = null) {
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using Exceptionless.Extensions;
4+
5+
namespace Exceptionless.Models.Data {
6+
public class ManualStackingInfo {
7+
public ManualStackingInfo() {
8+
SignatureData = new Dictionary<string, string>();
9+
}
10+
11+
public ManualStackingInfo(string title) : this() {
12+
if (!String.IsNullOrWhiteSpace(title))
13+
Title = title.Trim();
14+
}
15+
16+
public ManualStackingInfo(string title, IDictionary<string, string> signatureData) : this(title) {
17+
if (signatureData != null && signatureData.Count > 0)
18+
SignatureData.AddRange(signatureData);
19+
}
20+
21+
public ManualStackingInfo(IDictionary<string, string> signatureData) : this(null, signatureData) {}
22+
23+
/// <summary>
24+
/// Stack Title (defaults to the event message)
25+
/// </summary>
26+
public string Title { get; set; }
27+
28+
/// <summary>
29+
/// Key value pair that determines how the event is stacked.
30+
/// </summary>
31+
public IDictionary<string, string> SignatureData { get; set; }
32+
}
33+
}

Source/Shared/Models/Client/Event.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public static class KnownDataKeys {
7878
public const string Version = "@version";
7979
public const string Level = "@level";
8080
public const string SubmissionMethod = "@submission_method";
81-
public const string ManualStackingKey = "@stack";
81+
public const string ManualStackingInfo = "@stack";
8282
}
8383
}
8484
}

0 commit comments

Comments
 (0)