MetricsCollection.GetOrCreate(MetricIdentifier, MetricConfiguration) Method

Definition

Gets the specified metric, or creates one if no such metric exists.

public Microsoft.ApplicationInsights.Metric GetOrCreate (Microsoft.ApplicationInsights.Metrics.MetricIdentifier metricIdentifier, Microsoft.ApplicationInsights.Metrics.MetricConfiguration metricConfiguration);
member this.GetOrCreate : Microsoft.ApplicationInsights.Metrics.MetricIdentifier * Microsoft.ApplicationInsights.Metrics.MetricConfiguration -> Microsoft.ApplicationInsights.Metric
Public Function GetOrCreate (metricIdentifier As MetricIdentifier, metricConfiguration As MetricConfiguration) As Metric

Parameters

metricIdentifier
MetricIdentifier

The identity of the metric.

metricConfiguration
MetricConfiguration

@The configutration of the metric.

Returns

A metric with the specified identify and configuration.

Exceptions

If a metric with the specified identify exists, but its configuration does not match the specified configuration. You may not change a metric configurations once a metric was created for the first time. Either specify the same configuration every time, or specify null during every invocation except the first one. null will match against any previously specified configuration when retrieving existing metrics, or fall back to the default when creating new metrics.

Applies to