Skip to content

Add Exceptionless.Windows plugin to capture additional helpful information #269

@elachlan

Description

@elachlan

Hi,

I wrote a plugin to capture the processes handle count, user object count, and GDI object count.

To reduce maintenance and improve portability. I think this information should be made available via a plugin in Exceptionless. Similar to the web/webapi plugins.

Would you accept a pull request for a plugin added to Exceptionless.Windows?

This is what I currently use, but I imagine there is a nicer approach using dependency injection with IEnvironmentInfoCollector so that we can extend EnvironmentInfo?

Public Class SysInfoPlugin
    Implements IEventPlugin
    Public Sub Run(context As EventPluginContext) Implements IEventPlugin.Run
        If context.Event.Type = [Event].KnownTypes.Error Then
            Dim info As Data.EnvironmentInfo = Nothing
            If context.Event.Data.TryGetValue([Event].KnownDataKeys.EnvironmentInfo, info) Then
                info.Data.Add("Handle Count", Process.GetCurrentProcess.HandleCount)
                info.Data.Add("User Object Count", GetGuiResourcesUserCount())
                info.Data.Add("GDI Object Count", GetGuiResourcesGDIObjectCount())
            End If
        End If
    End Sub

    <DllImport("User32")>
    Public Shared Function GetGuiResources(hProcess As IntPtr, uiFlags As Integer) As Integer
    End Function

    Public Shared Function GetGuiResourcesUserCount() As Integer
        Return GetGuiResources(Process.GetCurrentProcess().Handle, 1)
    End Function
    Public Shared Function GetGuiResourcesGDIObjectCount() As Integer
        Return GetGuiResources(Process.GetCurrentProcess().Handle, 0)
    End Function
End Class

Cheers,
Lachlan

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions