There's no clean public API for registering an event processor. To do it today, a user has to write a PowerShell class deriving from an internal C# base type (SentryEventProcessor_) and then register this with options.AddEventProcessor from inside Start-Sentry.
|
// This is an abstract class for any PowerShell event processors. It gets around an issue with Windows PowerShell |
|
// failing to compile scripts that have a method name `Process`, which is a reserved word. |
|
// https://stackoverflow.com/questions/78001695/windows-powershell-implement-c-sharp-interface-with-reserved-words-as-method-n/78001981 |
|
// This way, we can keep the PowerShell implementation of the event processor, with access to System.Management.Automation, etc. |
|
public abstract class SentryEventProcessor_ : Sentry.Extensibility.ISentryEventProcessor |
In #27 Ivan proposed we add Add-SentryEventProcessor taking a scriptblock, wrapped internally by a C# class that implements ISentryEventProcessor directly. Could be used like so:
Add-SentryEventProcessor {
if ($_.Message -match 'secret') { return $null }
$_.SetTag('host', $env:COMPUTERNAME)
$_
}
Nice-to-have follow-on: migrate the two existing built-in processors (EventUpdater, StackTraceProcessor) onto the same mechanism so the PowerShell class files in modules/Sentry/private/ can be deleted. This also eliminates the Process-keyword constraint on the internal architecture.
PR #130 implements both pieces.
There's no clean public API for registering an event processor. To do it today, a user has to write a PowerShell
classderiving from an internal C# base type (SentryEventProcessor_) and then register this withoptions.AddEventProcessorfrom insideStart-Sentry.sentry-powershell/modules/Sentry/private/SentryEventProcessor.cs
Lines 1 to 5 in 7818d05
In #27 Ivan proposed we add
Add-SentryEventProcessortaking ascriptblock, wrapped internally by a C# class that implementsISentryEventProcessordirectly. Could be used like so:Nice-to-have follow-on: migrate the two existing built-in processors (
EventUpdater,StackTraceProcessor) onto the same mechanism so the PowerShellclassfiles inmodules/Sentry/private/can be deleted. This also eliminates theProcess-keyword constraint on the internal architecture.PR #130 implements both pieces.