Skip to content
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

Set up SentryOptions to allow for skipping module registration #202

Merged
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
15 changes: 9 additions & 6 deletions src/Sentry/Internal/MainSentryEventProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,18 @@ public SentryEvent Process(SentryEvent @event)
}
}

foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
if (_options.ReportAssemblies)
{
if (assembly.IsDynamic)
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
{
continue;
}
if (assembly.IsDynamic)
{
continue;
}

var asmName = assembly.GetName();
@event.Modules[asmName.Name] = asmName.Version.ToString();
var asmName = assembly.GetName();
@event.Modules[asmName.Name] = asmName.Version.ToString();
}
}
return @event;
}
Expand Down
5 changes: 5 additions & 0 deletions src/Sentry/SentryOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,11 @@ public IDiagnosticLogger DiagnosticLogger
}
}

/// <summary>
/// Whether or not to include referenced assemblies in each event sent to sentry. Defaults to <see langword="true"/>.
/// </summary>
public bool ReportAssemblies { get; set; } = true;

#if SYSTEM_WEB
/// <summary>
/// Max request body to be captured when a Web request exists on a ASP.NET Application.
Expand Down
11 changes: 11 additions & 0 deletions test/Sentry.Tests/Internals/MainSentryEventProcessorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,17 @@ public void Process_Modules_NotEmpty()
Assert.NotEmpty(evt.Modules);
}

[Fact]
public void Process_Modules_IsEmpty_WhenSpecified()
{
_fixture.SentryOptions.ReportAssemblies = false;
var sut = _fixture.GetSut();
var evt = new SentryEvent();
sut.Process(evt);

Assert.Empty(evt.Modules);
}

[Fact]
public void Process_SdkNameAndVersion_ToDefault()
{
Expand Down