Click or drag to resize

DiagnosticTracerBase Class

Base class for creating diagnostic tracers that follow Autofac diagnostic events.
Inheritance Hierarchy

Namespace:  Autofac.Diagnostics
Assembly:  Autofac (in Autofac.dll) Version: 6.0.0+39696a967e8826f7f1ebc8c1ff4523c9dd75abe0
Syntax
public abstract class DiagnosticTracerBase : IObserver<KeyValuePair<string, Object>>

The DiagnosticTracerBase type exposes the following members.

Constructors
  NameDescription
Protected methodDiagnosticTracerBase
Initializes a new instance of the DiagnosticTracerBase class
Top
Methods
  NameDescription
Public methodDisable
Unsubscribes the observer from a particular named diagnostic event.
Protected methodDisableBase
Unsubscribes the observer from a particular named diagnostic event.
Public methodEnable
Subscribes the observer to a particular named diagnostic event.
Public methodEnableAll
Subscribes the observer to all Autofac events.
Protected methodEnableBase
Subscribes the observer to a particular named diagnostic event.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodIsEnabled
Determines if this observer is enabled for listening to a specific named event.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodOnMiddlewareFailure
Handles the event raised when middleware encounters an error.
Protected methodOnMiddlewareStart
Handles the event raised when middleware starts.
Protected methodOnMiddlewareSuccess
Handles the event raised when middleware exits successfully.
Protected methodOnOperationFailure
Handles the event raised when a resolve operation encounters an error.
Protected methodOnOperationStart
Handles the event raised when a resolve operation starts.
Protected methodOnOperationSuccess
Handles the event raised when a resolve operation completes successfully.
Protected methodOnRequestFailure
Handles the event raised when a resolve request encounters an error.
Protected methodOnRequestStart
Handles the event raised when a resolve request starts.
Protected methodOnRequestSuccess
Handles the event raised when a resolve request completes successfully.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Protected methodWrite
Handles inbound events and converts the diagnostic data to a strongly-typed object that can be handled by the other methods in this observer.
Top
Explicit Interface Implementations
  NameDescription
Explicit interface implementationPrivate methodIObserverKeyValuePairString, ObjectOnCompleted
Notifies the observer that the provider has finished sending push-based notifications.
Explicit interface implementationPrivate methodIObserverKeyValuePairString, ObjectOnError
Notifies the observer that the provider has experienced an error condition.
Explicit interface implementationPrivate methodIObserverKeyValuePairString, ObjectOnNext
Provides the observer with new data.
Top
Remarks

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.

See Also