Class ApplicationInsightsFeatureUsageTrackingSession
- Namespace
- Splat.ApplicationInsights
- Assembly
- Splat.ApplicationInsights.dll
Provides a feature usage tracking session that records feature usage events and exceptions to Azure Application Insights using a specified telemetry client.
public sealed class ApplicationInsightsFeatureUsageTrackingSession : IFeatureUsageTrackingSession<Guid>, IFeatureUsageTrackingSession, IDisposable
- Inheritance
-
ApplicationInsightsFeatureUsageTrackingSession
- Implements
- Extension Methods
Remarks
This class is typically used to track the start and end of feature usage, as well as any exceptions that occur during the session. Feature usage events are sent to Application Insights when the session is created and disposed. Sub-features can be tracked by creating nested sessions. This class is not thread-safe; each instance should be used on a single thread.
Constructors
ApplicationInsightsFeatureUsageTrackingSession(string, TelemetryClient)
Initializes a new instance of the ApplicationInsightsFeatureUsageTrackingSession class.
public ApplicationInsightsFeatureUsageTrackingSession(string featureName, TelemetryClient telemetryClient)
Parameters
featureNamestringThe name of the feature.
telemetryClientTelemetryClientThe Application Insights telemetry client instance to use.
Properties
FeatureName
Gets the name of the Feature being tracked.
public string FeatureName { get; }
Property Value
FeatureReference
Gets the current Feature Usage Unique Reference.
public Guid FeatureReference { get; }
Property Value
ParentReference
Gets the unique reference for the Parent Tracking Session, if any.
public Guid ParentReference { get; }
Property Value
Methods
Dispose()
public void Dispose()
OnException(Exception)
Notify the APM toolset an exception has occurred in the current tracking session.
public void OnException(Exception exception)
Parameters
exceptionExceptionThe exception that occurred.
SubFeature(string)
Creates a new sub-feature tracking session with the specified description.
public IFeatureUsageTrackingSession SubFeature(string description)
Parameters
descriptionstringA string that describes the sub-feature to be tracked. Cannot be null or empty.
Returns
- IFeatureUsageTrackingSession
An IFeatureUsageTrackingSession instance for tracking usage of the specified sub-feature.
Remarks
Use sub-feature tracking sessions to record usage metrics for distinct operations or components within a larger feature. Each sub-feature session is independent and should be disposed when tracking is complete.