Skip to content

Add Add-SentryEventProcessor cmdlet for custom event processors #124

@jamescrosswell

Description

@jamescrosswell

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions