Skip to content

Fixes #238: Add ability to exclude Modules from getting sent with error reports #302

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Exceptionless/Configuration/ExceptionlessConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public ExceptionlessConfiguration(IDependencyResolver resolver) {
DefaultData = new DataDictionary();
Settings = new SettingsDictionary();
IncludePrivateInformation = true;
IncludeModules = true;

_resolver = resolver;

Expand Down Expand Up @@ -267,6 +268,11 @@ public bool IncludePrivateInformation {
/// NOTE: DataExclusions are applied to all Query String keys when enabled.
/// </summary>
public bool IncludeQueryString { get; set; }

/// <summary>
/// Gets or sets a value indicating whether to include module information.
/// </summary>
public bool IncludeModules { get; set; }

/// <summary>
/// Gets or sets a value indicating whether to automatically send session start, session heartbeats and session end events.
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptionless/Extensions/ToErrorModelExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private static Error ToErrorModelInternal(Exception exception, ExceptionlessClie
Type = typeName
};

if (!isInner)
if (!isInner && client.Configuration.IncludeModules)
error.Modules = GetLoadedModules(log);

error.PopulateStackTrace(error, exception, log);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private static SimpleError ToSimpleErrorModelInternal(this Exception exception,
StackTrace = exception.Demystify().StackTrace
};

if (!isInner)
if (!isInner && client.Configuration.IncludeModules)
error.Modules = ToErrorModelExtensions.GetLoadedModules(log);

var exclusions = _exceptionExclusions.Union(client.Configuration.DataExclusions).ToList();
Expand Down
2 changes: 1 addition & 1 deletion src/Exceptionless/Storage/InMemoryObjectStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public bool SaveObject<T>(string path, T value) where T : class {
}, (object)value);

if (_storage.Count > MaxObjects)
_storage.Remove(_storage.OrderByDescending(kvp => kvp.Value.Item1.Created).First().Key);
_storage.Remove(_storage.OrderBy(kvp => kvp.Value.Item1.Created).First().Key);
}

return true;
Expand Down
3 changes: 3 additions & 0 deletions test/Exceptionless.Tests/Configuration/ConfigurationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public void CanConfigureApiKeyFromClientConstructor() {
Assert.True(client.Configuration.IncludeUserName);
Assert.True(client.Configuration.IncludeMachineName);
Assert.True(client.Configuration.IncludeIpAddress);
Assert.True(client.Configuration.IncludeHeaders);
Assert.True(client.Configuration.IncludeCookies);
Assert.True(client.Configuration.IncludePostData);
Assert.True(client.Configuration.IncludeQueryString);
Expand All @@ -42,6 +43,7 @@ public void CanConfigureApiKeyFromClientConstructor() {
Assert.False(client.Configuration.IncludeUserName);
Assert.False(client.Configuration.IncludeMachineName);
Assert.False(client.Configuration.IncludeIpAddress);
Assert.False(client.Configuration.IncludeHeaders);
Assert.False(client.Configuration.IncludeCookies);
Assert.False(client.Configuration.IncludePostData);
Assert.False(client.Configuration.IncludeQueryString);
Expand All @@ -51,6 +53,7 @@ public void CanConfigureApiKeyFromClientConstructor() {
Assert.False(client.Configuration.IncludeUserName);
Assert.True(client.Configuration.IncludeMachineName);
Assert.False(client.Configuration.IncludeIpAddress);
Assert.False(client.Configuration.IncludeHeaders);
Assert.False(client.Configuration.IncludeCookies);
Assert.False(client.Configuration.IncludePostData);
Assert.False(client.Configuration.IncludeQueryString);
Expand Down