Skip to content

Channel Events

Channels provide a way to monitor certain events that occur during a channel's lifetime. This can be useful for logging, metrics, or other cross-cutting concerns. The following events are available:

  • Channel Created
  • Channel Closed
  • Data Received
  • Data Sent

To monitor channel events, you'll need to create a class that implements the IChannelMonitor interface and then add it to the DI container. You can register as many implementations as you need. They can be registered as singleton, scoped (channel bound) or transient services, depending on your requirements.

All registered monitors are notified for every channel event.

public class MyChannelMonitor : IChannelMonitor
{
    // ...
}

// ...

IServiceCollection services = ...;

services.AddSingleton<IChannelMonitor, MyChannelMonitor>();