DiagnosticTracerBase Class |
Namespace: Autofac.Diagnostics
The DiagnosticTracerBase type exposes the following members.
Name | Description | |
---|---|---|
DiagnosticTracerBase | Initializes a new instance of the DiagnosticTracerBase class |
Name | Description | |
---|---|---|
Disable |
Unsubscribes the observer from a particular named diagnostic event.
| |
DisableBase |
Unsubscribes the observer from a particular named diagnostic event.
| |
Enable |
Subscribes the observer to a particular named diagnostic event.
| |
EnableAll |
Subscribes the observer to all Autofac events.
| |
EnableBase |
Subscribes the observer to a particular named diagnostic event.
| |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
IsEnabled |
Determines if this observer is enabled for listening to a specific
named event.
| |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
OnMiddlewareFailure |
Handles the event raised when middleware encounters an error.
| |
OnMiddlewareStart |
Handles the event raised when middleware starts.
| |
OnMiddlewareSuccess |
Handles the event raised when middleware exits successfully.
| |
OnOperationFailure |
Handles the event raised when a resolve operation encounters an error.
| |
OnOperationStart |
Handles the event raised when a resolve operation starts.
| |
OnOperationSuccess |
Handles the event raised when a resolve operation completes successfully.
| |
OnRequestFailure |
Handles the event raised when a resolve request encounters an error.
| |
OnRequestStart |
Handles the event raised when a resolve request starts.
| |
OnRequestSuccess |
Handles the event raised when a resolve request completes successfully.
| |
ToString | Returns a string that represents the current object. (Inherited from Object.) | |
Write |
Handles inbound events and converts the diagnostic data to a
strongly-typed object that can be handled by the other methods
in this observer.
|
Name | Description | |
---|---|---|
IObserverKeyValuePairString, ObjectOnCompleted | Notifies the observer that the provider has finished sending push-based notifications. | |
IObserverKeyValuePairString, ObjectOnError | Notifies the observer that the provider has experienced an error condition. | |
IObserverKeyValuePairString, ObjectOnNext | Provides the observer with new data. |
Following events from a DiagnosticListener involves subscribing to that listener with an IObserverT where the observable is a KeyValuePairTKey, TValue of String event names and Object event data.
This class helps with that by providing strongly typed event handlers pre-wired to convert the event data into the right object type, allowing you to focus on the handling logic and not the event/data parsing.
While technically you could subscribe to non-Autofac events using this observer, it's not a general purpose mechanism - it's very much tailored to Autofac.
Should you want to start emitting and subscribing to your own events in the Autofac pipeline (e.g., a custom middleware that emits your own custom events) you have some options:
First, you could implement your own IObserverT that listens for your custom events. Since you can subscribe any number of IObserverT to a given DiagnosticListener, having one that derives from this class and a separate one of your own making is acceptable.
Second, you could create your own IObserverT that does not derive from this class but still listens for Autofac events as well as any custom events you emit. Any diagnostics observer can listen for these events as long as it's subscribed to the DiagnosticSource; it doesn't have to be one of this specific class type.
Finally, if you want to use this as a base but to listen for your custom events, you can derive from this and override the Write(String, Object) method. Handle your custom events, or if it's not one of your custom events, call the base to handle the Autofac events.