diff --git a/BASE/src/Microsoft.ApplicationInsights/ITelemetryClient.cs b/BASE/src/Microsoft.ApplicationInsights/ITelemetryClient.cs new file mode 100644 index 0000000000..d7b0551894 --- /dev/null +++ b/BASE/src/Microsoft.ApplicationInsights/ITelemetryClient.cs @@ -0,0 +1,770 @@ +namespace Microsoft.ApplicationInsights +{ + using System; + using System.Collections.Generic; + using System.ComponentModel; + using System.Threading; + using System.Threading.Tasks; + using Channel; + using DataContracts; + using Extensibility; + using Metrics; + + /// + /// Send events, metrics and other telemetry to the Application Insights service. + /// Learn more + /// + public interface ITelemetryClient + { + /// + /// Gets the current context that will be used to augment telemetry you send. + /// + TelemetryContext Context { get; } + + /// + /// Gets or sets the default instrumentation key for all objects logged in this . + /// + string InstrumentationKey + { + get; + + [Obsolete("InstrumentationKey based global ingestion is being deprecated. Recommended to set TelemetryConfiguration.ConnectionString. See https://github.com/microsoft/ApplicationInsights-dotnet/issues/2560 for more details.")] + set; + } + + /// + /// Gets the object associated with this telemetry client instance. + /// Changes made to the configuration can affect other clients. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + TelemetryConfiguration TelemetryConfiguration { get; } + + /// + /// Check to determine if the tracking is enabled. + /// + bool IsEnabled(); + + /// + /// Send an for display in Diagnostic Search and in the Analytics Portal. + /// + /// + /// Learn more + /// + /// A name for the event. + /// Named string values you can use to search and classify events. + /// Measurements associated with this event. + void TrackEvent(string eventName, IDictionary properties = null, + IDictionary metrics = null); + + /// + /// Send an for display in Diagnostic Search and in the Analytics Portal. + /// Create a separate instance for each call to . + /// + /// + /// Learn more + /// + /// An event log item. + void TrackEvent(EventTelemetry telemetry); + + /// + /// Send a trace message for display in Diagnostic Search. + /// + /// + /// Learn more + /// + /// Message to display. + void TrackTrace(string message); + + /// + /// Send a trace message for display in Diagnostic Search. + /// + /// + /// Learn more + /// + /// Message to display. + /// Trace severity level. + void TrackTrace(string message, SeverityLevel severityLevel); + + /// + /// Send a trace message for display in Diagnostic Search. + /// + /// + /// Learn more + /// + /// Message to display. + /// Named string values you can use to search and classify events. + void TrackTrace(string message, IDictionary properties); + + /// + /// Send a trace message for display in Diagnostic Search. + /// + /// + /// Learn more + /// + /// Message to display. + /// Trace severity level. + /// Named string values you can use to search and classify events. + void TrackTrace(string message, SeverityLevel severityLevel, IDictionary properties); + + /// + /// Send a trace message for display in Diagnostic Search. + /// Create a separate instance for each call to . + /// + /// + /// Learn more + /// + /// Message with optional properties. + void TrackTrace(TraceTelemetry telemetry); + + /// + /// This method is not the preferred method for sending metrics. + /// Metrics should always be pre-aggregated across a time period before being sent.
+ /// Use one of the GetMetric(..) overloads to get a metric object for accessing SDK pre-aggregation capabilities.
+ /// If you are implementing your own pre-aggregation logic, then you can use this method. + /// If your application requires sending a separate telemetry item at every occasion without aggregation across time, + /// you likely have a use case for event telemetry; see . + ///
+ /// Metric name. + /// Metric value. + /// Named string values you can use to classify and filter metrics. + void TrackMetric(string name, double value, IDictionary properties = null); + + /// + /// This method is not the preferred method for sending metrics. + /// Metrics should always be pre-aggregated across a time period before being sent.
+ /// Use one of the GetMetric(..) overloads to get a metric object for accessing SDK pre-aggregation capabilities.
+ /// If you are implementing your own pre-aggregation logic, then you can use this method. + /// If your application requires sending a separate telemetry item at every occasion without aggregation across time, + /// you likely have a use case for event telemetry; see . + ///
+ /// The metric telemetry item. + void TrackMetric(MetricTelemetry telemetry); + + /// + /// Send an for display in Diagnostic Search. + /// + /// The exception to log. + /// Named string values you can use to classify and search for this exception. + /// Additional values associated with this exception. + /// + /// Learn more + /// + void TrackException(Exception exception, IDictionary properties = null, + IDictionary metrics = null); + + /// + /// Send an for display in Diagnostic Search. + /// Create a separate instance for each call to . + /// + /// + /// Learn more + /// + void TrackException(ExceptionTelemetry telemetry); + + /// + /// Send information about an external dependency (outgoing call) in the application. + /// + /// Name of the command initiated with this dependency call. Low cardinality value. Examples are stored procedure name and URL path template. + /// Command initiated by this dependency call. Examples are SQL statement and HTTP URL's with all query parameters. + /// The time when the dependency was called. + /// The time taken by the external dependency to handle the call. + /// True if the dependency call was handled successfully. + /// + /// Learn more + /// + [Obsolete("Please use a different overload of TrackDependency")] + void TrackDependency(string dependencyName, string data, DateTimeOffset startTime, TimeSpan duration, + bool success); + + /// + /// Send information about an external dependency (outgoing call) in the application. + /// + /// External dependency type. Very low cardinality value for logical grouping and interpretation of fields. Examples are SQL, Azure table, and HTTP. + /// Name of the command initiated with this dependency call. Low cardinality value. Examples are stored procedure name and URL path template. + /// Command initiated by this dependency call. Examples are SQL statement and HTTP URL's with all query parameters. + /// The time when the dependency was called. + /// The time taken by the external dependency to handle the call. + /// True if the dependency call was handled successfully. + /// + /// Learn more + /// + void TrackDependency(string dependencyTypeName, string dependencyName, string data, DateTimeOffset startTime, + TimeSpan duration, bool success); + + /// + /// Send information about an external dependency (outgoing call) in the application. + /// + /// External dependency type. Very low cardinality value for logical grouping and interpretation of fields. Examples are SQL, Azure table, and HTTP. + /// External dependency target. + /// Name of the command initiated with this dependency call. Low cardinality value. Examples are stored procedure name and URL path template. + /// Command initiated by this dependency call. Examples are SQL statement and HTTP URL's with all query parameters. + /// The time when the dependency was called. + /// The time taken by the external dependency to handle the call. + /// Result code of dependency call execution. + /// True if the dependency call was handled successfully. + /// + /// Learn more + /// + void TrackDependency(string dependencyTypeName, string target, string dependencyName, string data, + DateTimeOffset startTime, TimeSpan duration, string resultCode, bool success); + + /// + /// Send information about external dependency call in the application. + /// Create a separate instance for each call to . + /// + /// + /// Learn more + /// + void TrackDependency(DependencyTelemetry telemetry); + + /// + /// Send information about availability of an application. + /// + /// Availability test name. + /// The time when the availability was captured. + /// The time taken for the availability test to run. + /// Name of the location the availability test was run from. + /// True if the availability test ran successfully. + /// Error message on availability test run failure. + /// Named string values you can use to classify and search for this availability telemetry. + /// Additional values associated with this availability telemetry. + /// + /// Learn more + /// + void TrackAvailability(string name, DateTimeOffset timeStamp, TimeSpan duration, string runLocation, + bool success, string message = null, IDictionary properties = null, + IDictionary metrics = null); + + /// + /// Send information about availability of an application. + /// Create a separate instance for each call to . + /// + /// + /// Learn more + /// + void TrackAvailability(AvailabilityTelemetry telemetry); + + /// + /// Send information about the page viewed in the application. + /// + /// Name of the page. + /// + /// Learn more + /// + void TrackPageView(string name); + + /// + /// Send information about the page viewed in the application. + /// Create a separate instance for each call to . + /// + /// + /// Learn more + /// + void TrackPageView(PageViewTelemetry telemetry); + + /// + /// Send information about a request handled by the application. + /// + /// The request name. + /// The time when the page was requested. + /// The time taken by the application to handle the request. + /// The response status code. + /// True if the request was handled successfully by the application. + /// + /// Learn more + /// + void TrackRequest(string name, DateTimeOffset startTime, TimeSpan duration, string responseCode, bool success); + + /// + /// Send information about a request handled by the application. + /// Create a separate instance for each call to . + /// + /// + /// Learn more + /// + void TrackRequest(RequestTelemetry request); + + /// + /// Flushes the in-memory buffer and any metrics being pre-aggregated. + /// + /// + /// Learn more + /// + void Flush(); + + /// + /// Asynchronously Flushes the in-memory buffer and any metrics being pre-aggregated. + /// + /// + /// Learn more + /// + /// + /// Returns true when telemetry data is transferred out of process (application insights server or local storage) and are emitted before the flush invocation. + /// Returns false when transfer of telemetry data to server has failed with non-retriable http status. + /// FlushAsync on InMemoryChannel always returns true, as the channel offers minimal reliability guarantees and doesn't retry sending telemetry after a failure. + /// + Task FlushAsync(CancellationToken cancellationToken); + + /// + /// Gets or creates a metric container that you can use to track, aggregate and send metric values.
+ /// Optionally specify a metric configuration to control how the tracked values are aggregated. + ///
+ /// The aggregated values will be sent to the TelemetryConfiguration + /// associated with this client.
+ /// The aggregation scope of the fetchedMetric is TelemetryConfiguration; this + /// means that all values tracked for a given metric ID and dimensions will be aggregated together + /// across all clients that share the same TelemetryConfiguration.
+ /// The ID (name) of the metric. + /// (The namespace specified in will be used. + /// To specify another namespace, use an overload that takes a MetricIdentifier parameter instead.) + /// A Metric with the specified ID and dimensions. If you call this method several times + /// with the same metric ID and dimensions for a given aggregation scope, you will receive the same + /// instance of Metric. + /// If you previously created a metric with the same namespace, ID, dimensions + /// and aggregation scope, but with a different configuration. When calling this method to get a previously + /// created metric, you can simply avoid specifying any configuration (or specify null) to imply the + /// configuration used earlier. + Metric GetMetric(string metricId); + + /// + /// Gets or creates a metric container that you can use to track, aggregate and send metric values.
+ /// Optionally specify a metric configuration to control how the tracked values are aggregated. + ///
+ /// The aggregated values will be sent to the TelemetryConfiguration + /// associated with this client.
+ /// The aggregation scope of the fetchedMetric is TelemetryConfiguration; this + /// means that all values tracked for a given metric ID and dimensions will be aggregated together + /// across all clients that share the same TelemetryConfiguration.
+ /// The ID (name) of the metric. + /// (The namespace specified in will be used. + /// To specify another namespace, use an overload that takes a MetricIdentifier parameter instead.) + /// Determines how tracked values will be aggregated.
+ /// Use presets in or specify your own settings. + /// A Metric with the specified ID and dimensions. If you call this method several times + /// with the same metric ID and dimensions for a given aggregation scope, you will receive the same + /// instance of Metric. + /// If you previously created a metric with the same namespace, ID, dimensions + /// and aggregation scope, but with a different configuration. When calling this method to get a previously + /// created metric, you can simply avoid specifying any configuration (or specify null) to imply the + /// configuration used earlier. + Metric GetMetric(string metricId, MetricConfiguration metricConfiguration); + + /// + /// Gets or creates a metric container that you can use to track, aggregate and send metric values.
+ /// Optionally specify a metric configuration to control how the tracked values are aggregated. + ///
+ /// The ID (name) of the metric. + /// (The namespace specified in will be used. + /// To specify another namespace, use an overload that takes a MetricIdentifier parameter instead.) + /// Determines how tracked values will be aggregated.
+ /// Use presets in or specify your own settings. + /// A Metric with the specified ID and dimensions. If you call this method several times + /// with the same metric ID and dimensions for a given aggregation scope, you will receive the same + /// instance of Metric. + /// If you previously created a metric with the same namespace, ID, dimensions + /// and aggregation scope, but with a different configuration. When calling this method to get a previously + /// created metric, you can simply avoid specifying any configuration (or specify null) to imply the + /// configuration used earlier. + /// The scope across which the values for the metric are to be aggregated in memory. + /// See for more info. + /// A instance that you can use to automatically aggregate and then sent metric data value. + Metric GetMetric( + string metricId, + MetricConfiguration metricConfiguration, + MetricAggregationScope aggregationScope); + + /// + /// Gets or creates a metric container that you can use to track, aggregate and send metric values.
+ /// Optionally specify a metric configuration to control how the tracked values are aggregated. + ///
+ /// The aggregated values will be sent to the TelemetryConfiguration + /// associated with this client.
+ /// The aggregation scope of the fetchedMetric is TelemetryConfiguration; this + /// means that all values tracked for a given metric ID and dimensions will be aggregated together + /// across all clients that share the same TelemetryConfiguration.
+ /// The ID (name) of the metric. + /// (The namespace specified in will be used. + /// To specify another namespace, use an overload that takes a MetricIdentifier parameter instead.) + /// The name of the first dimension. + /// If you previously created a metric with the same namespace, ID, dimensions + /// and aggregation scope, but with a different configuration. When calling this method to get a previously + /// created metric, you can simply avoid specifying any configuration (or specify null) to imply the + /// configuration used earlier. + /// A instance that you can use to automatically aggregate and then sent metric data value. + Metric GetMetric( + string metricId, + string dimension1Name); + + /// + /// Gets or creates a metric container that you can use to track, aggregate and send metric values.
+ /// Optionally specify a metric configuration to control how the tracked values are aggregated. + ///
+ /// The aggregated values will be sent to the TelemetryConfiguration + /// associated with this client.
+ /// The aggregation scope of the fetchedMetric is TelemetryConfiguration; this + /// means that all values tracked for a given metric ID and dimensions will be aggregated together + /// across all clients that share the same TelemetryConfiguration.
+ /// The ID (name) of the metric. + /// (The namespace specified in will be used. + /// To specify another namespace, use an overload that takes a MetricIdentifier parameter instead.) + /// The name of the first dimension. + /// Determines how tracked values will be aggregated.
+ /// Use presets in or specify your own settings. + /// A Metric with the specified ID and dimensions. If you call this method several times + /// with the same metric ID and dimensions for a given aggregation scope, you will receive the same + /// instance of Metric. + /// If you previously created a metric with the same namespace, ID, dimensions + /// and aggregation scope, but with a different configuration. When calling this method to get a previously + /// created metric, you can simply avoid specifying any configuration (or specify null) to imply the + /// configuration used earlier. + Metric GetMetric( + string metricId, + string dimension1Name, + MetricConfiguration metricConfiguration); + + /// + /// Gets or creates a metric container that you can use to track, aggregate and send metric values.
+ /// Optionally specify a metric configuration to control how the tracked values are aggregated. + ///
+ /// The ID (name) of the metric. + /// (The namespace specified in will be used. + /// To specify another namespace, use an overload that takes a MetricIdentifier parameter instead.) + /// The name of the first dimension. + /// Determines how tracked values will be aggregated.
+ /// Use presets in or specify your own settings. + /// A Metric with the specified ID and dimensions. If you call this method several times + /// with the same metric ID and dimensions for a given aggregation scope, you will receive the same + /// instance of Metric. + /// If you previously created a metric with the same namespace, ID, dimensions + /// and aggregation scope, but with a different configuration. When calling this method to get a previously + /// created metric, you can simply avoid specifying any configuration (or specify null) to imply the + /// configuration used earlier. + /// The scope across which the values for the metric are to be aggregated in memory. + /// See for more info. + Metric GetMetric( + string metricId, + string dimension1Name, + MetricConfiguration metricConfiguration, + MetricAggregationScope aggregationScope); + + /// + /// Gets or creates a metric container that you can use to track, aggregate and send metric values.
+ /// Optionally specify a metric configuration to control how the tracked values are aggregated. + ///
+ /// The aggregated values will be sent to the TelemetryConfiguration + /// associated with this client.
+ /// The aggregation scope of the fetchedMetric is TelemetryConfiguration; this + /// means that all values tracked for a given metric ID and dimensions will be aggregated together + /// across all clients that share the same TelemetryConfiguration.
+ /// The ID (name) of the metric. + /// (The namespace specified in will be used. + /// To specify another namespace, use an overload that takes a MetricIdentifier parameter instead.) + /// The name of the first dimension. + /// The name of the second dimension. + /// If you previously created a metric with the same namespace, ID, dimensions + /// and aggregation scope, but with a different configuration. When calling this method to get a previously + /// created metric, you can simply avoid specifying any configuration (or specify null) to imply the + /// configuration used earlier. + /// A instance that you can use to automatically aggregate and then sent metric data value. + Metric GetMetric( + string metricId, + string dimension1Name, + string dimension2Name); + + /// + /// Gets or creates a metric container that you can use to track, aggregate and send metric values.
+ /// Optionally specify a metric configuration to control how the tracked values are aggregated. + ///
+ /// The aggregated values will be sent to the TelemetryConfiguration + /// associated with this client.
+ /// The aggregation scope of the fetchedMetric is TelemetryConfiguration; this + /// means that all values tracked for a given metric ID and dimensions will be aggregated together + /// across all clients that share the same TelemetryConfiguration.
+ /// The ID (name) of the metric. + /// (The namespace specified in will be used. + /// To specify another namespace, use an overload that takes a MetricIdentifier parameter instead.) + /// The name of the first dimension. + /// The name of the second dimension. + /// Determines how tracked values will be aggregated.
+ /// Use presets in or specify your own settings. + /// A Metric with the specified ID and dimensions. If you call this method several times + /// with the same metric ID and dimensions for a given aggregation scope, you will receive the same + /// instance of Metric. + /// If you previously created a metric with the same namespace, ID, dimensions + /// and aggregation scope, but with a different configuration. When calling this method to get a previously + /// created metric, you can simply avoid specifying any configuration (or specify null) to imply the + /// configuration used earlier. + Metric GetMetric( + string metricId, + string dimension1Name, + string dimension2Name, + MetricConfiguration metricConfiguration); + + /// + /// Gets or creates a metric container that you can use to track, aggregate and send metric values.
+ /// Optionally specify a metric configuration to control how the tracked values are aggregated. + ///
+ /// The ID (name) of the metric. + /// (The namespace specified in will be used. + /// To specify another namespace, use an overload that takes a MetricIdentifier parameter instead.) + /// The name of the first dimension. + /// The name of the second dimension. + /// Determines how tracked values will be aggregated.
+ /// Use presets in or specify your own settings. + /// A Metric with the specified ID and dimensions. If you call this method several times + /// with the same metric ID and dimensions for a given aggregation scope, you will receive the same + /// instance of Metric. + /// If you previously created a metric with the same namespace, ID, dimensions + /// and aggregation scope, but with a different configuration. When calling this method to get a previously + /// created metric, you can simply avoid specifying any configuration (or specify null) to imply the + /// configuration used earlier. + /// The scope across which the values for the metric are to be aggregated in memory. + /// See for more info. + Metric GetMetric( + string metricId, + string dimension1Name, + string dimension2Name, + MetricConfiguration metricConfiguration, + MetricAggregationScope aggregationScope); + + /// + /// Gets or creates a metric container that you can use to track, aggregate and send metric values.
+ /// Optionally specify a metric configuration to control how the tracked values are aggregated. + ///
+ /// The aggregated values will be sent to the TelemetryConfiguration + /// associated with this client.
+ /// The aggregation scope of the fetchedMetric is TelemetryConfiguration; this + /// means that all values tracked for a given metric ID and dimensions will be aggregated together + /// across all clients that share the same TelemetryConfiguration.
+ /// The ID (name) of the metric. + /// (The namespace specified in will be used. + /// To specify another namespace, use an overload that takes a MetricIdentifier parameter instead.) + /// The name of the first dimension. + /// The name of the second dimension. + /// The name of the third dimension. + /// If you previously created a metric with the same namespace, ID, dimensions + /// and aggregation scope, but with a different configuration. When calling this method to get a previously + /// created metric, you can simply avoid specifying any configuration (or specify null) to imply the + /// configuration used earlier. + /// A instance that you can use to automatically aggregate and then sent metric data value. + Metric GetMetric( + string metricId, + string dimension1Name, + string dimension2Name, + string dimension3Name); + + /// + /// Gets or creates a metric container that you can use to track, aggregate and send metric values.
+ /// Optionally specify a metric configuration to control how the tracked values are aggregated. + ///
+ /// The aggregated values will be sent to the TelemetryConfiguration + /// associated with this client.
+ /// The aggregation scope of the fetchedMetric is TelemetryConfiguration; this + /// means that all values tracked for a given metric ID and dimensions will be aggregated together + /// across all clients that share the same TelemetryConfiguration.
+ /// The ID (name) of the metric. + /// (The namespace specified in will be used. + /// To specify another namespace, use an overload that takes a MetricIdentifier parameter instead.) + /// The name of the first dimension. + /// The name of the second dimension. + /// The name of the third dimension. + /// Determines how tracked values will be aggregated.
+ /// Use presets in or specify your own settings. + /// A Metric with the specified ID and dimensions. If you call this method several times + /// with the same metric ID and dimensions for a given aggregation scope, you will receive the same + /// instance of Metric. + /// If you previously created a metric with the same namespace, ID, dimensions + /// and aggregation scope, but with a different configuration. When calling this method to get a previously + /// created metric, you can simply avoid specifying any configuration (or specify null) to imply the + /// configuration used earlier. + Metric GetMetric( + string metricId, + string dimension1Name, + string dimension2Name, + string dimension3Name, + MetricConfiguration metricConfiguration); + + /// + /// Gets or creates a metric container that you can use to track, aggregate and send metric values.
+ /// Optionally specify a metric configuration to control how the tracked values are aggregated. + ///
+ /// The ID (name) of the metric. + /// (The namespace specified in will be used. + /// To specify another namespace, use an overload that takes a MetricIdentifier parameter instead.) + /// The name of the first dimension. + /// The name of the second dimension. + /// The name of the third dimension. + /// Determines how tracked values will be aggregated.
+ /// Use presets in or specify your own settings. + /// A Metric with the specified ID and dimensions. If you call this method several times + /// with the same metric ID and dimensions for a given aggregation scope, you will receive the same + /// instance of Metric. + /// If you previously created a metric with the same namespace, ID, dimensions + /// and aggregation scope, but with a different configuration. When calling this method to get a previously + /// created metric, you can simply avoid specifying any configuration (or specify null) to imply the + /// configuration used earlier. + /// The scope across which the values for the metric are to be aggregated in memory. + /// See for more info. + Metric GetMetric( + string metricId, + string dimension1Name, + string dimension2Name, + string dimension3Name, + MetricConfiguration metricConfiguration, + MetricAggregationScope aggregationScope); + + /// + /// Gets or creates a metric container that you can use to track, aggregate and send metric values.
+ /// Optionally specify a metric configuration to control how the tracked values are aggregated. + ///
+ /// The aggregated values will be sent to the TelemetryConfiguration + /// associated with this client.
+ /// The aggregation scope of the fetchedMetric is TelemetryConfiguration; this + /// means that all values tracked for a given metric ID and dimensions will be aggregated together + /// across all clients that share the same TelemetryConfiguration.
+ /// The ID (name) of the metric. + /// (The namespace specified in will be used. + /// To specify another namespace, use an overload that takes a MetricIdentifier parameter instead.) + /// The name of the first dimension. + /// The name of the second dimension. + /// The name of the third dimension. + /// The name of the fourth dimension. + /// If you previously created a metric with the same namespace, ID, dimensions + /// and aggregation scope, but with a different configuration. When calling this method to get a previously + /// created metric, you can simply avoid specifying any configuration (or specify null) to imply the + /// configuration used earlier. + /// A instance that you can use to automatically aggregate and then sent metric data value. + Metric GetMetric( + string metricId, + string dimension1Name, + string dimension2Name, + string dimension3Name, + string dimension4Name); + + /// + /// Gets or creates a metric container that you can use to track, aggregate and send metric values.
+ /// Optionally specify a metric configuration to control how the tracked values are aggregated. + ///
+ /// The aggregated values will be sent to the TelemetryConfiguration + /// associated with this client.
+ /// The aggregation scope of the fetchedMetric is TelemetryConfiguration; this + /// means that all values tracked for a given metric ID and dimensions will be aggregated together + /// across all clients that share the same TelemetryConfiguration.
+ /// The ID (name) of the metric. + /// (The namespace specified in will be used. + /// To specify another namespace, use an overload that takes a MetricIdentifier parameter instead.) + /// The name of the first dimension. + /// The name of the second dimension. + /// The name of the third dimension. + /// The name of the fourth dimension. + /// Determines how tracked values will be aggregated.
+ /// Use presets in or specify your own settings. + /// A Metric with the specified ID and dimensions. If you call this method several times + /// with the same metric ID and dimensions for a given aggregation scope, you will receive the same + /// instance of Metric. + /// If you previously created a metric with the same namespace, ID, dimensions + /// and aggregation scope, but with a different configuration. When calling this method to get a previously + /// created metric, you can simply avoid specifying any configuration (or specify null) to imply the + /// configuration used earlier. + Metric GetMetric( + string metricId, + string dimension1Name, + string dimension2Name, + string dimension3Name, + string dimension4Name, + MetricConfiguration metricConfiguration); + + /// + /// Gets or creates a metric container that you can use to track, aggregate and send metric values.
+ /// Optionally specify a metric configuration to control how the tracked values are aggregated. + ///
+ /// The ID (name) of the metric. + /// (The namespace specified in will be used. + /// To specify another namespace, use an overload that takes a MetricIdentifier parameter instead.) + /// The name of the first dimension. + /// The name of the second dimension. + /// The name of the third dimension. + /// The name of the fourth dimension. + /// Determines how tracked values will be aggregated.
+ /// Use presets in or specify your own settings. + /// A Metric with the specified ID and dimensions. If you call this method several times + /// with the same metric ID and dimensions for a given aggregation scope, you will receive the same + /// instance of Metric. + /// If you previously created a metric with the same namespace, ID, dimensions + /// and aggregation scope, but with a different configuration. When calling this method to get a previously + /// created metric, you can simply avoid specifying any configuration (or specify null) to imply the + /// configuration used earlier. + /// The scope across which the values for the metric are to be aggregated in memory. + /// See for more info. + Metric GetMetric( + string metricId, + string dimension1Name, + string dimension2Name, + string dimension3Name, + string dimension4Name, + MetricConfiguration metricConfiguration, + MetricAggregationScope aggregationScope); + + /// + /// Gets or creates a metric container that you can use to track, aggregate and send metric values.
+ /// Optionally specify a metric configuration to control how the tracked values are aggregated. + ///
+ /// The aggregated values will be sent to the TelemetryConfiguration + /// associated with this client.
+ /// The aggregation scope of the fetchedMetric is TelemetryConfiguration; this + /// means that all values tracked for a given metric ID and dimensions will be aggregated together + /// across all clients that share the same TelemetryConfiguration.
+ /// A grouping containing the Namespace, the ID (name) and the dimension names of the metric. + /// If you previously created a metric with the same namespace, ID, dimensions + /// and aggregation scope, but with a different configuration. When calling this method to get a previously + /// created metric, you can simply avoid specifying any configuration (or specify null) to imply the + /// configuration used earlier. + /// A instance that you can use to automatically aggregate and then sent metric data value. + Metric GetMetric( + MetricIdentifier metricIdentifier); + + /// + /// Gets or creates a metric container that you can use to track, aggregate and send metric values.
+ /// Optionally specify a metric configuration to control how the tracked values are aggregated. + ///
+ /// The aggregated values will be sent to the TelemetryConfiguration + /// associated with this client.
+ /// The aggregation scope of the fetchedMetric is TelemetryConfiguration; this + /// means that all values tracked for a given metric ID and dimensions will be aggregated together + /// across all clients that share the same TelemetryConfiguration.
+ /// A grouping containing the Namespace, the ID (name) and the dimension names of the metric. + /// Determines how tracked values will be aggregated.
+ /// Use presets in or specify your own settings. + /// A Metric with the specified ID and dimensions. If you call this method several times + /// with the same metric ID and dimensions for a given aggregation scope, you will receive the same + /// instance of Metric. + /// If you previously created a metric with the same namespace, ID, dimensions + /// and aggregation scope, but with a different configuration. When calling this method to get a previously + /// created metric, you can simply avoid specifying any configuration (or specify null) to imply the + /// configuration used earlier. + Metric GetMetric( + MetricIdentifier metricIdentifier, + MetricConfiguration metricConfiguration); + + /// + /// Gets or creates a metric container that you can use to track, aggregate and send metric values.
+ /// Optionally specify a metric configuration to control how the tracked values are aggregated. + ///
+ /// A grouping containing the Namespace, the ID (name) and the dimension names of the metric. + /// Determines how tracked values will be aggregated.
+ /// Use presets in or specify your own settings. + /// A Metric with the specified ID and dimensions. If you call this method several times + /// with the same metric ID and dimensions for a given aggregation scope, you will receive the same + /// instance of Metric. + /// If you previously created a metric with the same namespace, ID, dimensions + /// and aggregation scope, but with a different configuration. When calling this method to get a previously + /// created metric, you can simply avoid specifying any configuration (or specify null) to imply the + /// configuration used earlier. + /// The scope across which the values for the metric are to be aggregated in memory. + /// See for more info. + Metric GetMetric( + MetricIdentifier metricIdentifier, + MetricConfiguration metricConfiguration, + MetricAggregationScope aggregationScope); + } +} diff --git a/BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs b/BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs index 41a1540532..06065f5885 100644 --- a/BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs +++ b/BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs @@ -15,11 +15,8 @@ using Microsoft.ApplicationInsights.Metrics; using Microsoft.ApplicationInsights.Metrics.Extensibility; - /// - /// Send events, metrics and other telemetry to the Application Insights service. - /// Learn more - /// - public sealed class TelemetryClient + /// + public sealed class TelemetryClient : ITelemetryClient { #if NETSTANDARD // This constant is defined for all versions of NetStandard https://docs.microsoft.com/en-us/dotnet/core/tutorials/libraries#how-to-multitarget private const string VersionPrefix = "dotnetc:"; @@ -41,11 +38,7 @@ public TelemetryClient() : this(TelemetryConfiguration.Active) { } - /// - /// Initializes a new instance of the class. Send telemetry with the specified . - /// - /// The is null. - /// The does not contain a telemetry channel. + /// public TelemetryClient(TelemetryConfiguration configuration) { if (configuration == null) @@ -63,9 +56,7 @@ public TelemetryClient(TelemetryConfiguration configuration) } #pragma warning restore 612, 618 // TelemetryConfiguration.Active - /// - /// Gets the current context that will be used to augment telemetry you send. - /// + /// public TelemetryContext Context { get; @@ -74,9 +65,7 @@ public TelemetryContext Context = new TelemetryContext(); - /// - /// Gets or sets the default instrumentation key for all objects logged in this . - /// + /// public string InstrumentationKey { get => this.Context.InstrumentationKey; @@ -85,33 +74,20 @@ public string InstrumentationKey set { this.Context.InstrumentationKey = value; } } - /// - /// Gets the object associated with this telemetry client instance. - /// Changes made to the configuration can affect other clients. - /// + /// [EditorBrowsable(EditorBrowsableState.Never)] public TelemetryConfiguration TelemetryConfiguration { get { return this.configuration; } } - /// - /// Check to determine if the tracking is enabled. - /// + /// public bool IsEnabled() { return !this.configuration.DisableTelemetry; } - /// - /// Send an for display in Diagnostic Search and in the Analytics Portal. - /// - /// - /// Learn more - /// - /// A name for the event. - /// Named string values you can use to search and classify events. - /// Measurements associated with this event. + /// public void TrackEvent(string eventName, IDictionary properties = null, IDictionary metrics = null) { var telemetry = new EventTelemetry(eventName); @@ -129,14 +105,7 @@ public void TrackEvent(string eventName, IDictionary properties this.TrackEvent(telemetry); } - /// - /// Send an for display in Diagnostic Search and in the Analytics Portal. - /// Create a separate instance for each call to . - /// - /// - /// Learn more - /// - /// An event log item. + /// public void TrackEvent(EventTelemetry telemetry) { if (telemetry == null) @@ -147,39 +116,19 @@ public void TrackEvent(EventTelemetry telemetry) this.Track(telemetry); } - /// - /// Send a trace message for display in Diagnostic Search. - /// - /// - /// Learn more - /// - /// Message to display. + /// public void TrackTrace(string message) { this.TrackTrace(new TraceTelemetry(message)); } - /// - /// Send a trace message for display in Diagnostic Search. - /// - /// - /// Learn more - /// - /// Message to display. - /// Trace severity level. + /// public void TrackTrace(string message, SeverityLevel severityLevel) { this.TrackTrace(new TraceTelemetry(message, severityLevel)); } - /// - /// Send a trace message for display in Diagnostic Search. - /// - /// - /// Learn more - /// - /// Message to display. - /// Named string values you can use to search and classify events. + /// public void TrackTrace(string message, IDictionary properties) { TraceTelemetry telemetry = new TraceTelemetry(message); @@ -192,15 +141,7 @@ public void TrackTrace(string message, IDictionary properties) this.TrackTrace(telemetry); } - /// - /// Send a trace message for display in Diagnostic Search. - /// - /// - /// Learn more - /// - /// Message to display. - /// Trace severity level. - /// Named string values you can use to search and classify events. + /// public void TrackTrace(string message, SeverityLevel severityLevel, IDictionary properties) { TraceTelemetry telemetry = new TraceTelemetry(message, severityLevel); @@ -213,31 +154,14 @@ public void TrackTrace(string message, SeverityLevel severityLevel, IDictionary< this.TrackTrace(telemetry); } - /// - /// Send a trace message for display in Diagnostic Search. - /// Create a separate instance for each call to . - /// - /// - /// Learn more - /// - /// Message with optional properties. + /// public void TrackTrace(TraceTelemetry telemetry) { telemetry = telemetry ?? new TraceTelemetry(); this.Track(telemetry); } - /// - /// This method is not the preferred method for sending metrics. - /// Metrics should always be pre-aggregated across a time period before being sent.
- /// Use one of the GetMetric(..) overloads to get a metric object for accessing SDK pre-aggregation capabilities.
- /// If you are implementing your own pre-aggregation logic, then you can use this method. - /// If your application requires sending a separate telemetry item at every occasion without aggregation across time, - /// you likely have a use case for event telemetry; see . - ///
- /// Metric name. - /// Metric value. - /// Named string values you can use to classify and filter metrics. + /// public void TrackMetric(string name, double value, IDictionary properties = null) { var telemetry = new MetricTelemetry(name, value); @@ -249,15 +173,7 @@ public void TrackMetric(string name, double value, IDictionary p this.TrackMetric(telemetry); } - /// - /// This method is not the preferred method for sending metrics. - /// Metrics should always be pre-aggregated across a time period before being sent.
- /// Use one of the GetMetric(..) overloads to get a metric object for accessing SDK pre-aggregation capabilities.
- /// If you are implementing your own pre-aggregation logic, then you can use this method. - /// If your application requires sending a separate telemetry item at every occasion without aggregation across time, - /// you likely have a use case for event telemetry; see . - ///
- /// The metric telemetry item. + /// public void TrackMetric(MetricTelemetry telemetry) { if (telemetry == null) @@ -268,15 +184,7 @@ public void TrackMetric(MetricTelemetry telemetry) this.Track(telemetry); } - /// - /// Send an for display in Diagnostic Search. - /// - /// The exception to log. - /// Named string values you can use to classify and search for this exception. - /// Additional values associated with this exception. - /// - /// Learn more - /// + /// public void TrackException(Exception exception, IDictionary properties = null, IDictionary metrics = null) { if (exception == null) @@ -299,13 +207,7 @@ public void TrackException(Exception exception, IDictionary prop this.TrackException(telemetry); } - /// - /// Send an for display in Diagnostic Search. - /// Create a separate instance for each call to . - /// - /// - /// Learn more - /// + /// public void TrackException(ExceptionTelemetry telemetry) { if (telemetry == null) @@ -317,17 +219,7 @@ public void TrackException(ExceptionTelemetry telemetry) this.Track(telemetry); } - /// - /// Send information about an external dependency (outgoing call) in the application. - /// - /// Name of the command initiated with this dependency call. Low cardinality value. Examples are stored procedure name and URL path template. - /// Command initiated by this dependency call. Examples are SQL statement and HTTP URL's with all query parameters. - /// The time when the dependency was called. - /// The time taken by the external dependency to handle the call. - /// True if the dependency call was handled successfully. - /// - /// Learn more - /// + /// [Obsolete("Please use a different overload of TrackDependency")] public void TrackDependency(string dependencyName, string data, DateTimeOffset startTime, TimeSpan duration, bool success) { @@ -336,49 +228,19 @@ public void TrackDependency(string dependencyName, string data, DateTimeOffset s #pragma warning restore 618 } - /// - /// Send information about an external dependency (outgoing call) in the application. - /// - /// External dependency type. Very low cardinality value for logical grouping and interpretation of fields. Examples are SQL, Azure table, and HTTP. - /// Name of the command initiated with this dependency call. Low cardinality value. Examples are stored procedure name and URL path template. - /// Command initiated by this dependency call. Examples are SQL statement and HTTP URL's with all query parameters. - /// The time when the dependency was called. - /// The time taken by the external dependency to handle the call. - /// True if the dependency call was handled successfully. - /// - /// Learn more - /// + /// public void TrackDependency(string dependencyTypeName, string dependencyName, string data, DateTimeOffset startTime, TimeSpan duration, bool success) { this.TrackDependency(new DependencyTelemetry(dependencyTypeName, null, dependencyName, data, startTime, duration, null, success)); } - /// - /// Send information about an external dependency (outgoing call) in the application. - /// - /// External dependency type. Very low cardinality value for logical grouping and interpretation of fields. Examples are SQL, Azure table, and HTTP. - /// External dependency target. - /// Name of the command initiated with this dependency call. Low cardinality value. Examples are stored procedure name and URL path template. - /// Command initiated by this dependency call. Examples are SQL statement and HTTP URL's with all query parameters. - /// The time when the dependency was called. - /// The time taken by the external dependency to handle the call. - /// Result code of dependency call execution. - /// True if the dependency call was handled successfully. - /// - /// Learn more - /// + /// public void TrackDependency(string dependencyTypeName, string target, string dependencyName, string data, DateTimeOffset startTime, TimeSpan duration, string resultCode, bool success) { this.TrackDependency(new DependencyTelemetry(dependencyTypeName, target, dependencyName, data, startTime, duration, resultCode, success)); } - /// - /// Send information about external dependency call in the application. - /// Create a separate instance for each call to . - /// - /// - /// Learn more - /// + /// public void TrackDependency(DependencyTelemetry telemetry) { if (telemetry == null) @@ -389,20 +251,7 @@ public void TrackDependency(DependencyTelemetry telemetry) this.Track(telemetry); } - /// - /// Send information about availability of an application. - /// - /// Availability test name. - /// The time when the availability was captured. - /// The time taken for the availability test to run. - /// Name of the location the availability test was run from. - /// True if the availability test ran successfully. - /// Error message on availability test run failure. - /// Named string values you can use to classify and search for this availability telemetry. - /// Additional values associated with this availability telemetry. - /// - /// Learn more - /// + /// public void TrackAvailability(string name, DateTimeOffset timeStamp, TimeSpan duration, string runLocation, bool success, string message = null, IDictionary properties = null, IDictionary metrics = null) { var availabilityTelemetry = new AvailabilityTelemetry(name, timeStamp, duration, runLocation, success, message); @@ -420,13 +269,7 @@ public void TrackAvailability(string name, DateTimeOffset timeStamp, TimeSpan du this.TrackAvailability(availabilityTelemetry); } - /// - /// Send information about availability of an application. - /// Create a separate instance for each call to . - /// - /// - /// Learn more - /// + /// public void TrackAvailability(AvailabilityTelemetry telemetry) { if (telemetry == null) @@ -592,25 +435,13 @@ public void Initialize(ITelemetry telemetry) } } - /// - /// Send information about the page viewed in the application. - /// - /// Name of the page. - /// - /// Learn more - /// + /// public void TrackPageView(string name) { this.Track(new PageViewTelemetry(name)); } - /// - /// Send information about the page viewed in the application. - /// Create a separate instance for each call to . - /// - /// - /// Learn more - /// + /// public void TrackPageView(PageViewTelemetry telemetry) { if (telemetry == null) @@ -621,29 +452,13 @@ public void TrackPageView(PageViewTelemetry telemetry) this.Track(telemetry); } - /// - /// Send information about a request handled by the application. - /// - /// The request name. - /// The time when the page was requested. - /// The time taken by the application to handle the request. - /// The response status code. - /// True if the request was handled successfully by the application. - /// - /// Learn more - /// + /// public void TrackRequest(string name, DateTimeOffset startTime, TimeSpan duration, string responseCode, bool success) { this.Track(new RequestTelemetry(name, startTime, duration, responseCode, success)); } - /// - /// Send information about a request handled by the application. - /// Create a separate instance for each call to . - /// - /// - /// Learn more - /// + /// public void TrackRequest(RequestTelemetry request) { if (request == null) @@ -654,12 +469,7 @@ public void TrackRequest(RequestTelemetry request) this.Track(request); } - /// - /// Flushes the in-memory buffer and any metrics being pre-aggregated. - /// - /// - /// Learn more - /// + /// public void Flush() { CoreEventSource.Log.TelemetlyClientFlush(); @@ -680,17 +490,7 @@ public void Flush() } } - /// - /// Asynchronously Flushes the in-memory buffer and any metrics being pre-aggregated. - /// - /// - /// Learn more - /// - /// - /// Returns true when telemetry data is transferred out of process (application insights server or local storage) and are emitted before the flush invocation. - /// Returns false when transfer of telemetry data to server has failed with non-retriable http status. - /// FlushAsync on InMemoryChannel always returns true, as the channel offers minimal reliability guarantees and doesn't retry sending telemetry after a failure. - /// + /// /// TODO: Metrics flush to respect CancellationToken. public Task FlushAsync(CancellationToken cancellationToken) { @@ -716,25 +516,7 @@ public Task FlushAsync(CancellationToken cancellationToken) return cancellationToken.IsCancellationRequested ? TaskEx.FromCanceled(cancellationToken) : Task.FromResult(false); } - /// - /// Gets or creates a metric container that you can use to track, aggregate and send metric values.
- /// Optionally specify a metric configuration to control how the tracked values are aggregated. - ///
- /// The aggregated values will be sent to the TelemetryConfiguration - /// associated with this client.
- /// The aggregation scope of the fetchedMetric is TelemetryConfiguration; this - /// means that all values tracked for a given metric ID and dimensions will be aggregated together - /// across all clients that share the same TelemetryConfiguration.
- /// The ID (name) of the metric. - /// (The namespace specified in will be used. - /// To specify another namespace, use an overload that takes a MetricIdentifier parameter instead.) - /// A Metric with the specified ID and dimensions. If you call this method several times - /// with the same metric ID and dimensions for a given aggregation scope, you will receive the same - /// instance of Metric. - /// If you previously created a metric with the same namespace, ID, dimensions - /// and aggregation scope, but with a different configuration. When calling this method to get a previously - /// created metric, you can simply avoid specifying any configuration (or specify null) to imply the - /// configuration used earlier. + /// public Metric GetMetric( string metricId) { @@ -744,27 +526,7 @@ public Metric GetMetric( metricConfiguration: null); } - /// - /// Gets or creates a metric container that you can use to track, aggregate and send metric values.
- /// Optionally specify a metric configuration to control how the tracked values are aggregated. - ///
- /// The aggregated values will be sent to the TelemetryConfiguration - /// associated with this client.
- /// The aggregation scope of the fetchedMetric is TelemetryConfiguration; this - /// means that all values tracked for a given metric ID and dimensions will be aggregated together - /// across all clients that share the same TelemetryConfiguration.
- /// The ID (name) of the metric. - /// (The namespace specified in will be used. - /// To specify another namespace, use an overload that takes a MetricIdentifier parameter instead.) - /// Determines how tracked values will be aggregated.
- /// Use presets in or specify your own settings. - /// A Metric with the specified ID and dimensions. If you call this method several times - /// with the same metric ID and dimensions for a given aggregation scope, you will receive the same - /// instance of Metric. - /// If you previously created a metric with the same namespace, ID, dimensions - /// and aggregation scope, but with a different configuration. When calling this method to get a previously - /// created metric, you can simply avoid specifying any configuration (or specify null) to imply the - /// configuration used earlier. + /// public Metric GetMetric( string metricId, MetricConfiguration metricConfiguration) @@ -775,25 +537,7 @@ public Metric GetMetric( metricConfiguration: metricConfiguration); } - /// - /// Gets or creates a metric container that you can use to track, aggregate and send metric values.
- /// Optionally specify a metric configuration to control how the tracked values are aggregated. - ///
- /// The ID (name) of the metric. - /// (The namespace specified in will be used. - /// To specify another namespace, use an overload that takes a MetricIdentifier parameter instead.) - /// Determines how tracked values will be aggregated.
- /// Use presets in or specify your own settings. - /// A Metric with the specified ID and dimensions. If you call this method several times - /// with the same metric ID and dimensions for a given aggregation scope, you will receive the same - /// instance of Metric. - /// If you previously created a metric with the same namespace, ID, dimensions - /// and aggregation scope, but with a different configuration. When calling this method to get a previously - /// created metric, you can simply avoid specifying any configuration (or specify null) to imply the - /// configuration used earlier. - /// The scope across which the values for the metric are to be aggregated in memory. - /// See for more info. - /// A instance that you can use to automatically aggregate and then sent metric data value. + /// public Metric GetMetric( string metricId, MetricConfiguration metricConfiguration, @@ -805,24 +549,7 @@ public Metric GetMetric( metricConfiguration: metricConfiguration); } - /// - /// Gets or creates a metric container that you can use to track, aggregate and send metric values.
- /// Optionally specify a metric configuration to control how the tracked values are aggregated. - ///
- /// The aggregated values will be sent to the TelemetryConfiguration - /// associated with this client.
- /// The aggregation scope of the fetchedMetric is TelemetryConfiguration; this - /// means that all values tracked for a given metric ID and dimensions will be aggregated together - /// across all clients that share the same TelemetryConfiguration.
- /// The ID (name) of the metric. - /// (The namespace specified in will be used. - /// To specify another namespace, use an overload that takes a MetricIdentifier parameter instead.) - /// The name of the first dimension. - /// If you previously created a metric with the same namespace, ID, dimensions - /// and aggregation scope, but with a different configuration. When calling this method to get a previously - /// created metric, you can simply avoid specifying any configuration (or specify null) to imply the - /// configuration used earlier. - /// A instance that you can use to automatically aggregate and then sent metric data value. + /// public Metric GetMetric( string metricId, string dimension1Name) @@ -833,28 +560,7 @@ public Metric GetMetric( metricConfiguration: null); } - /// - /// Gets or creates a metric container that you can use to track, aggregate and send metric values.
- /// Optionally specify a metric configuration to control how the tracked values are aggregated. - ///
- /// The aggregated values will be sent to the TelemetryConfiguration - /// associated with this client.
- /// The aggregation scope of the fetchedMetric is TelemetryConfiguration; this - /// means that all values tracked for a given metric ID and dimensions will be aggregated together - /// across all clients that share the same TelemetryConfiguration.
- /// The ID (name) of the metric. - /// (The namespace specified in will be used. - /// To specify another namespace, use an overload that takes a MetricIdentifier parameter instead.) - /// The name of the first dimension. - /// Determines how tracked values will be aggregated.
- /// Use presets in or specify your own settings. - /// A Metric with the specified ID and dimensions. If you call this method several times - /// with the same metric ID and dimensions for a given aggregation scope, you will receive the same - /// instance of Metric. - /// If you previously created a metric with the same namespace, ID, dimensions - /// and aggregation scope, but with a different configuration. When calling this method to get a previously - /// created metric, you can simply avoid specifying any configuration (or specify null) to imply the - /// configuration used earlier. + /// public Metric GetMetric( string metricId, string dimension1Name, @@ -866,25 +572,7 @@ public Metric GetMetric( metricConfiguration: metricConfiguration); } - /// - /// Gets or creates a metric container that you can use to track, aggregate and send metric values.
- /// Optionally specify a metric configuration to control how the tracked values are aggregated. - ///
- /// The ID (name) of the metric. - /// (The namespace specified in will be used. - /// To specify another namespace, use an overload that takes a MetricIdentifier parameter instead.) - /// The name of the first dimension. - /// Determines how tracked values will be aggregated.
- /// Use presets in or specify your own settings. - /// A Metric with the specified ID and dimensions. If you call this method several times - /// with the same metric ID and dimensions for a given aggregation scope, you will receive the same - /// instance of Metric. - /// If you previously created a metric with the same namespace, ID, dimensions - /// and aggregation scope, but with a different configuration. When calling this method to get a previously - /// created metric, you can simply avoid specifying any configuration (or specify null) to imply the - /// configuration used earlier. - /// The scope across which the values for the metric are to be aggregated in memory. - /// See for more info. + /// public Metric GetMetric( string metricId, string dimension1Name, @@ -897,25 +585,7 @@ public Metric GetMetric( metricConfiguration: metricConfiguration); } - /// - /// Gets or creates a metric container that you can use to track, aggregate and send metric values.
- /// Optionally specify a metric configuration to control how the tracked values are aggregated. - ///
- /// The aggregated values will be sent to the TelemetryConfiguration - /// associated with this client.
- /// The aggregation scope of the fetchedMetric is TelemetryConfiguration; this - /// means that all values tracked for a given metric ID and dimensions will be aggregated together - /// across all clients that share the same TelemetryConfiguration.
- /// The ID (name) of the metric. - /// (The namespace specified in will be used. - /// To specify another namespace, use an overload that takes a MetricIdentifier parameter instead.) - /// The name of the first dimension. - /// The name of the second dimension. - /// If you previously created a metric with the same namespace, ID, dimensions - /// and aggregation scope, but with a different configuration. When calling this method to get a previously - /// created metric, you can simply avoid specifying any configuration (or specify null) to imply the - /// configuration used earlier. - /// A instance that you can use to automatically aggregate and then sent metric data value. + /// public Metric GetMetric( string metricId, string dimension1Name, @@ -927,29 +597,7 @@ public Metric GetMetric( metricConfiguration: null); } - /// - /// Gets or creates a metric container that you can use to track, aggregate and send metric values.
- /// Optionally specify a metric configuration to control how the tracked values are aggregated. - ///
- /// The aggregated values will be sent to the TelemetryConfiguration - /// associated with this client.
- /// The aggregation scope of the fetchedMetric is TelemetryConfiguration; this - /// means that all values tracked for a given metric ID and dimensions will be aggregated together - /// across all clients that share the same TelemetryConfiguration.
- /// The ID (name) of the metric. - /// (The namespace specified in will be used. - /// To specify another namespace, use an overload that takes a MetricIdentifier parameter instead.) - /// The name of the first dimension. - /// The name of the second dimension. - /// Determines how tracked values will be aggregated.
- /// Use presets in or specify your own settings. - /// A Metric with the specified ID and dimensions. If you call this method several times - /// with the same metric ID and dimensions for a given aggregation scope, you will receive the same - /// instance of Metric. - /// If you previously created a metric with the same namespace, ID, dimensions - /// and aggregation scope, but with a different configuration. When calling this method to get a previously - /// created metric, you can simply avoid specifying any configuration (or specify null) to imply the - /// configuration used earlier. + /// public Metric GetMetric( string metricId, string dimension1Name, @@ -962,26 +610,7 @@ public Metric GetMetric( metricConfiguration); } - /// - /// Gets or creates a metric container that you can use to track, aggregate and send metric values.
- /// Optionally specify a metric configuration to control how the tracked values are aggregated. - ///
- /// The ID (name) of the metric. - /// (The namespace specified in will be used. - /// To specify another namespace, use an overload that takes a MetricIdentifier parameter instead.) - /// The name of the first dimension. - /// The name of the second dimension. - /// Determines how tracked values will be aggregated.
- /// Use presets in or specify your own settings. - /// A Metric with the specified ID and dimensions. If you call this method several times - /// with the same metric ID and dimensions for a given aggregation scope, you will receive the same - /// instance of Metric. - /// If you previously created a metric with the same namespace, ID, dimensions - /// and aggregation scope, but with a different configuration. When calling this method to get a previously - /// created metric, you can simply avoid specifying any configuration (or specify null) to imply the - /// configuration used earlier. - /// The scope across which the values for the metric are to be aggregated in memory. - /// See for more info. + /// public Metric GetMetric( string metricId, string dimension1Name, @@ -995,26 +624,7 @@ public Metric GetMetric( metricConfiguration); } - /// - /// Gets or creates a metric container that you can use to track, aggregate and send metric values.
- /// Optionally specify a metric configuration to control how the tracked values are aggregated. - ///
- /// The aggregated values will be sent to the TelemetryConfiguration - /// associated with this client.
- /// The aggregation scope of the fetchedMetric is TelemetryConfiguration; this - /// means that all values tracked for a given metric ID and dimensions will be aggregated together - /// across all clients that share the same TelemetryConfiguration.
- /// The ID (name) of the metric. - /// (The namespace specified in will be used. - /// To specify another namespace, use an overload that takes a MetricIdentifier parameter instead.) - /// The name of the first dimension. - /// The name of the second dimension. - /// The name of the third dimension. - /// If you previously created a metric with the same namespace, ID, dimensions - /// and aggregation scope, but with a different configuration. When calling this method to get a previously - /// created metric, you can simply avoid specifying any configuration (or specify null) to imply the - /// configuration used earlier. - /// A instance that you can use to automatically aggregate and then sent metric data value. + /// public Metric GetMetric( string metricId, string dimension1Name, @@ -1027,30 +637,7 @@ public Metric GetMetric( metricConfiguration: null); } - /// - /// Gets or creates a metric container that you can use to track, aggregate and send metric values.
- /// Optionally specify a metric configuration to control how the tracked values are aggregated. - ///
- /// The aggregated values will be sent to the TelemetryConfiguration - /// associated with this client.
- /// The aggregation scope of the fetchedMetric is TelemetryConfiguration; this - /// means that all values tracked for a given metric ID and dimensions will be aggregated together - /// across all clients that share the same TelemetryConfiguration.
- /// The ID (name) of the metric. - /// (The namespace specified in will be used. - /// To specify another namespace, use an overload that takes a MetricIdentifier parameter instead.) - /// The name of the first dimension. - /// The name of the second dimension. - /// The name of the third dimension. - /// Determines how tracked values will be aggregated.
- /// Use presets in or specify your own settings. - /// A Metric with the specified ID and dimensions. If you call this method several times - /// with the same metric ID and dimensions for a given aggregation scope, you will receive the same - /// instance of Metric. - /// If you previously created a metric with the same namespace, ID, dimensions - /// and aggregation scope, but with a different configuration. When calling this method to get a previously - /// created metric, you can simply avoid specifying any configuration (or specify null) to imply the - /// configuration used earlier. + /// public Metric GetMetric( string metricId, string dimension1Name, @@ -1064,27 +651,7 @@ public Metric GetMetric( metricConfiguration); } - /// - /// Gets or creates a metric container that you can use to track, aggregate and send metric values.
- /// Optionally specify a metric configuration to control how the tracked values are aggregated. - ///
- /// The ID (name) of the metric. - /// (The namespace specified in will be used. - /// To specify another namespace, use an overload that takes a MetricIdentifier parameter instead.) - /// The name of the first dimension. - /// The name of the second dimension. - /// The name of the third dimension. - /// Determines how tracked values will be aggregated.
- /// Use presets in or specify your own settings. - /// A Metric with the specified ID and dimensions. If you call this method several times - /// with the same metric ID and dimensions for a given aggregation scope, you will receive the same - /// instance of Metric. - /// If you previously created a metric with the same namespace, ID, dimensions - /// and aggregation scope, but with a different configuration. When calling this method to get a previously - /// created metric, you can simply avoid specifying any configuration (or specify null) to imply the - /// configuration used earlier. - /// The scope across which the values for the metric are to be aggregated in memory. - /// See for more info. + /// public Metric GetMetric( string metricId, string dimension1Name, @@ -1099,27 +666,7 @@ public Metric GetMetric( metricConfiguration); } - /// - /// Gets or creates a metric container that you can use to track, aggregate and send metric values.
- /// Optionally specify a metric configuration to control how the tracked values are aggregated. - ///
- /// The aggregated values will be sent to the TelemetryConfiguration - /// associated with this client.
- /// The aggregation scope of the fetchedMetric is TelemetryConfiguration; this - /// means that all values tracked for a given metric ID and dimensions will be aggregated together - /// across all clients that share the same TelemetryConfiguration.
- /// The ID (name) of the metric. - /// (The namespace specified in will be used. - /// To specify another namespace, use an overload that takes a MetricIdentifier parameter instead.) - /// The name of the first dimension. - /// The name of the second dimension. - /// The name of the third dimension. - /// The name of the fourth dimension. - /// If you previously created a metric with the same namespace, ID, dimensions - /// and aggregation scope, but with a different configuration. When calling this method to get a previously - /// created metric, you can simply avoid specifying any configuration (or specify null) to imply the - /// configuration used earlier. - /// A instance that you can use to automatically aggregate and then sent metric data value. + /// public Metric GetMetric( string metricId, string dimension1Name, @@ -1133,31 +680,7 @@ public Metric GetMetric( metricConfiguration: null); } - /// - /// Gets or creates a metric container that you can use to track, aggregate and send metric values.
- /// Optionally specify a metric configuration to control how the tracked values are aggregated. - ///
- /// The aggregated values will be sent to the TelemetryConfiguration - /// associated with this client.
- /// The aggregation scope of the fetchedMetric is TelemetryConfiguration; this - /// means that all values tracked for a given metric ID and dimensions will be aggregated together - /// across all clients that share the same TelemetryConfiguration.
- /// The ID (name) of the metric. - /// (The namespace specified in will be used. - /// To specify another namespace, use an overload that takes a MetricIdentifier parameter instead.) - /// The name of the first dimension. - /// The name of the second dimension. - /// The name of the third dimension. - /// The name of the fourth dimension. - /// Determines how tracked values will be aggregated.
- /// Use presets in or specify your own settings. - /// A Metric with the specified ID and dimensions. If you call this method several times - /// with the same metric ID and dimensions for a given aggregation scope, you will receive the same - /// instance of Metric. - /// If you previously created a metric with the same namespace, ID, dimensions - /// and aggregation scope, but with a different configuration. When calling this method to get a previously - /// created metric, you can simply avoid specifying any configuration (or specify null) to imply the - /// configuration used earlier. + /// public Metric GetMetric( string metricId, string dimension1Name, @@ -1172,28 +695,7 @@ public Metric GetMetric( metricConfiguration); } - /// - /// Gets or creates a metric container that you can use to track, aggregate and send metric values.
- /// Optionally specify a metric configuration to control how the tracked values are aggregated. - ///
- /// The ID (name) of the metric. - /// (The namespace specified in will be used. - /// To specify another namespace, use an overload that takes a MetricIdentifier parameter instead.) - /// The name of the first dimension. - /// The name of the second dimension. - /// The name of the third dimension. - /// The name of the fourth dimension. - /// Determines how tracked values will be aggregated.
- /// Use presets in or specify your own settings. - /// A Metric with the specified ID and dimensions. If you call this method several times - /// with the same metric ID and dimensions for a given aggregation scope, you will receive the same - /// instance of Metric. - /// If you previously created a metric with the same namespace, ID, dimensions - /// and aggregation scope, but with a different configuration. When calling this method to get a previously - /// created metric, you can simply avoid specifying any configuration (or specify null) to imply the - /// configuration used earlier. - /// The scope across which the values for the metric are to be aggregated in memory. - /// See for more info. + /// public Metric GetMetric( string metricId, string dimension1Name, @@ -1209,21 +711,7 @@ public Metric GetMetric( metricConfiguration); } - /// - /// Gets or creates a metric container that you can use to track, aggregate and send metric values.
- /// Optionally specify a metric configuration to control how the tracked values are aggregated. - ///
- /// The aggregated values will be sent to the TelemetryConfiguration - /// associated with this client.
- /// The aggregation scope of the fetchedMetric is TelemetryConfiguration; this - /// means that all values tracked for a given metric ID and dimensions will be aggregated together - /// across all clients that share the same TelemetryConfiguration.
- /// A grouping containing the Namespace, the ID (name) and the dimension names of the metric. - /// If you previously created a metric with the same namespace, ID, dimensions - /// and aggregation scope, but with a different configuration. When calling this method to get a previously - /// created metric, you can simply avoid specifying any configuration (or specify null) to imply the - /// configuration used earlier. - /// A instance that you can use to automatically aggregate and then sent metric data value. + /// public Metric GetMetric( MetricIdentifier metricIdentifier) { @@ -1233,25 +721,7 @@ public Metric GetMetric( metricConfiguration: null); } - /// - /// Gets or creates a metric container that you can use to track, aggregate and send metric values.
- /// Optionally specify a metric configuration to control how the tracked values are aggregated. - ///
- /// The aggregated values will be sent to the TelemetryConfiguration - /// associated with this client.
- /// The aggregation scope of the fetchedMetric is TelemetryConfiguration; this - /// means that all values tracked for a given metric ID and dimensions will be aggregated together - /// across all clients that share the same TelemetryConfiguration.
- /// A grouping containing the Namespace, the ID (name) and the dimension names of the metric. - /// Determines how tracked values will be aggregated.
- /// Use presets in or specify your own settings. - /// A Metric with the specified ID and dimensions. If you call this method several times - /// with the same metric ID and dimensions for a given aggregation scope, you will receive the same - /// instance of Metric. - /// If you previously created a metric with the same namespace, ID, dimensions - /// and aggregation scope, but with a different configuration. When calling this method to get a previously - /// created metric, you can simply avoid specifying any configuration (or specify null) to imply the - /// configuration used earlier. + /// public Metric GetMetric( MetricIdentifier metricIdentifier, MetricConfiguration metricConfiguration) @@ -1262,22 +732,7 @@ public Metric GetMetric( metricConfiguration); } - /// - /// Gets or creates a metric container that you can use to track, aggregate and send metric values.
- /// Optionally specify a metric configuration to control how the tracked values are aggregated. - ///
- /// A grouping containing the Namespace, the ID (name) and the dimension names of the metric. - /// Determines how tracked values will be aggregated.
- /// Use presets in or specify your own settings. - /// A Metric with the specified ID and dimensions. If you call this method several times - /// with the same metric ID and dimensions for a given aggregation scope, you will receive the same - /// instance of Metric. - /// If you previously created a metric with the same namespace, ID, dimensions - /// and aggregation scope, but with a different configuration. When calling this method to get a previously - /// created metric, you can simply avoid specifying any configuration (or specify null) to imply the - /// configuration used earlier. - /// The scope across which the values for the metric are to be aggregated in memory. - /// See for more info. + /// public Metric GetMetric( MetricIdentifier metricIdentifier, MetricConfiguration metricConfiguration, diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e782641d7..07fd1d9865 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog ## VNext +- Add ITelemetryClient interface to TelemetryClient. Fixes ([#342](https://github.com/microsoft/ApplicationInsights-dotnet/issues/342)) ## Version 2.22.0 - no changes since beta. diff --git a/NETCORE/src/Shared/Extensions/ApplicationInsightsExtensions.cs b/NETCORE/src/Shared/Extensions/ApplicationInsightsExtensions.cs index 1c098c3a96..b3a920c95d 100644 --- a/NETCORE/src/Shared/Extensions/ApplicationInsightsExtensions.cs +++ b/NETCORE/src/Shared/Extensions/ApplicationInsightsExtensions.cs @@ -363,6 +363,7 @@ private static void AddTelemetryConfigAndClient(IServiceCollection services) services.AddSingleton(provider => provider.GetService>().Value); services.AddSingleton(); + services.AddSingleton(provider => provider.GetRequiredService()); } private static void AddAndConfigureDependencyTracking(IServiceCollection services)