Loupe - Log - Monitor - Resolve
Gibraltar.Agent.Metrics Namespace / EventMetric Class / Register Method / Register(Object) Method
An object or Type defining event metrics via attributes on itself or on its base types or interfaces.

In This Topic
    Register(Object) Method
    In This Topic
    Registers all event metric definitions defined by attributes on the provided object or Type, and registers metric instances where EventMetricInstanceName attribute is also found (with a live object).
    Syntax
    'Declaration
     
    
    Public Overloads Shared Sub Register( _
       ByVal metricData As Object _
    ) 
    public static void Register( 
       object metricData
    )

    Parameters

    metricData
    An object or Type defining event metrics via attributes on itself or on its base types or interfaces.
    Exceptions
    ExceptionDescription
    Thrown if metricData is null.
    The specified metricDataObjectType does not have an EventMetric attribute

    -or-

    The specified Type does not have a usable EventMetric attribute, so it can't be used to define an event metric.

    -or-

    The specified Type's EventMetric has an empty metric namespace which is not allowed, so no metric can be defined.

    -or-

    The specified Type's EventMetric has an empty metric category name which is not allowed, so no metric can be defined.

    -or-

    The specified Type's EventMetric has an empty metric counter name which is not allowed, so no metric can be defined.

    -or-

    The specified Type's EventMetric attribute's 3-part Key is already used for a metric definition which is not an event metric.
    Remarks

    This call ensures that the reflection scan of all members looking for attributes across the entire inheritance of an object instance or Type has been done (e.g. outside of a critical path) so that the first call to Write will not have to do that work within a critical path. Results are cached internally, so redundant calls to this method will not repeat the scan for types already scanned (including as part of a different top-level type).

    If a live object is given (not just a Type) then the member(s) decorated with an EventMetricInstanceNameAttribute Class will be queried and used to also register an event metric instance with the returned name

    If a Type is given instead of a live object, it can't be queried for instance name(s) and will only register the event metric definitions. Metric instances will still be created automatically as needed when Write is called.

    Example
    See the EventMetric Class Overview for an example.
    Requirements

    Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also