Loupe - Log - Monitor - Resolve
Gibraltar.Agent.Metrics Namespace / EventMetricDefinition Class / Register Method / Register(EventMetricDefinition,String) Method
A reference to an event metric definition template to be registered, and to receive the official registered event metric definition.
The name of a value column to designate as the default one to graph for this metric.

In This Topic
    Register(EventMetricDefinition,String) Method
    In This Topic
    Register the referenced EventMetricDefinition template, or update the reference to the official definition if a compatible event metric definition already exists for the same 3-part Key.
    Syntax
    'Declaration
     
    
    Public Overloads Shared Sub Register( _
       ByRef newDefinition As EventMetricDefinition, _
       ByVal defaultValue As String _
    ) 
    public static void Register( 
       ref EventMetricDefinition newDefinition,
       string defaultValue
    )

    Parameters

    newDefinition
    A reference to an event metric definition template to be registered, and to receive the official registered event metric definition.
    defaultValue
    The name of a value column to designate as the default one to graph for this metric.
    Exceptions
    ExceptionDescription
    A null newDefinition or a null or empty defaultValue was provided.
    The specified defaultValue column name was not found in the provided definition.
    Remarks

    This is the final step for creating a new event metric definition programmatically, after constructing a new EventMetricDefinition(...) and calling AddValue(...) as desired to define value columns. If a metric definition is already registered with the same Key, it will be checked for compatibility. An incompatible existing definition (e.g. a sampled metric, or missing value columns from the provided template) will result in an ArgumentException to signal your programming mistake; each different metric definition in an application session must have a unique 3-part Key. If a compatible existing event metric definition is found, the reference to the EventMetricDefinition will be updated to the registered definition. If no metric definition exists with the same 3-part key as the template, then the new definition will be officially registered and may be used as a valid definition. This approach ensures thread-safe creation of singular event metric definitions without the need for locking by your code.

    This overload allows a value column of the definition template to be designated as the default one to graph for this event metric. The specified name must match a value column name in the definition template or a KeyNotFoundException will be thrown (and the template will not be registered). The defaultValue parameter will overwrite any previous setting of the DefaultValue property of the event metric definition template. If the completed template is not ultimately used because a metric definition already exists with the same 3-part Key, then the defaultValue parameter will have no effect; a metric definition which is already registered can not be altered, to ensure consistency within the session log.

    Also see the overload directly taking an EventMetricValueDefinition as the defaultValue for an approach which may be less prone to mistakes.

    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