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

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

    Parameters

    metricData
    An object or Type defining sampled metrics via attributes on itself or on its base types or interfaces.
    Exceptions
    ExceptionDescription
    The provided metricData object was null.
    The specified Type does not have a SampledMetric attribute, so it can't be used to define sampled metrics.
    - or -
    The specified Type does not have a usable SampledMetric attribute, so it can't be used to define sampled metrics.
    - or -
    The specified Type's SampledMetric attribute has an empty metric namespace which is not allowed, so no metrics can be defined under it.
    - or -
    The specified Type's SampledMetric attribute has an empty metric category name which is not allowed, so no metrics can be defined under it.
    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 can be as fast as possible. 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 a SampledMetricInstanceNameAttribute Class will be queried and used to also register a sampled 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 sampled metric definitions. Metric instances will still be automatically created as needed when writing a metricDataObject.

    Example
    For examples, see the Sampled Metric class overview.
    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