DynamicTracker Class
Definition
An abstract class which provides basic tracking functionality for other trackers to build upon.
[Obsolete("Telemetry is deprecated. See the upgrade guide at https://sqtechdocs.azurewebsites.net/docs/tooltelemetry/index.html")]public abstract class DynamicTracker : DynamicObject, IDynamicMetaObjectProviderInheritance object → DynamicObject
Implements IDynamicMetaObjectProvider
Constructors
DynamicTracker(TelemetryClient, ConfigurationData, SessionData)
Initializes a new instance of the DynamicTracker class.
protected DynamicTracker(TelemetryClient telemetryClient, ConfigurationData configuration, SessionData session)Parameters
telemetryClient TelemetryClient
The underlying Telemetry Client that handles all telemetry events to Application Insights.
configuration ConfigurationData
A structure that contains all configuration settings for telemetry.
session SessionData
A structure that contains session specific information.
Properties
AppInsightsMetrics
Gets a dictionary containing Key-Value pairs to be logged into Application Insights as associated Metrics.
protected Dictionary<string, double> AppInsightsMetrics { get; }AppInsightsProperties
Gets a dictionary containing Key-Value pairs to be logged into Application Insights as associated Properties.
protected Dictionary<string, string> AppInsightsProperties { get; }Configuration
Gets or sets the current configuration settings for telemetry.
protected ConfigurationData Configuration { get; set; }Session
Gets or sets a unique ID associated with this session.
protected SessionData Session { get; set; }TelemetryClient
Gets or sets the underlying Telemetry Client that handles all telemetry events to Application Insights.
protected TelemetryClient TelemetryClient { get; set; }TelemetryName
Gets or sets the name to be associated with this log within Application Insights. This value is set during calls to TryInvokeMember based on the binder.Name value.
protected string TelemetryName { get; set; }Methods
TryInvokeMember(InvokeMemberBinder, object?[]?, out object?)
Provides the implementation for operations that invoke a member. Classes derived from the DynamicObject class can override this method to specify dynamic behavior for operations such as calling a method.
public override bool TryInvokeMember(InvokeMemberBinder binder, object?[]? args, out object? result)Parameters
binder InvokeMemberBinder
Provides information about the dynamic operation. The binder.Name property provides the name of the member on which the dynamic operation is performed. For example, for the statement sampleObject.SampleMethod(100), where sampleObject is an instance of the class derived from the DynamicObject class, binder.Name returns “SampleMethod”. The binder.IgnoreCase property specifies whether the member name is case-sensitive.
args object[]
The arguments that are passed to the object member during the invoke operation. For example, for the statement sampleObject.SampleMethod(100), where sampleObject is derived from the DynamicObject class, args[0] is equal to 100.
result object
The result of the member invocation.
Returns
bool
true if the operation is successful; otherwise, false. If this method returns false, the run-time binder of the language determines the behavior. (In most cases, a language-specific run-time exception is thrown.)
VerifyRequiredParameters(IList, IReadOnlyDictionary<string, RequiredParameterInfo>)
Verifies that all of the required parameter names specified in requiredParameters exist in the list of given properties. If any don’t, an InvalidTelemetryCall exception will be thrown.
protected static void VerifyRequiredParameters(IList<TelemetryProperty> properties, IReadOnlyDictionary<string, RequiredParameterInfo> requiredParameters)Parameters
properties IList<TelemetryProperty>
List of properties to check against.
requiredParameters IReadOnlyDictionary<string, RequiredParameterInfo>
Dictionary of required parameter names with an associated error message.
AdditionalDataValidation(IList)
This method is run once at the start of a TryInvokeMethod call and may be implemented by any classes extending DynamicTracker to perform implementation specific data validation of the parameters passed in.
protected virtual void AdditionalDataValidation(IList<TelemetryProperty> properties)Parameters
properties IList<TelemetryProperty>
An ordered list of named properties from TryInvokeMethod.
CollectCustomData()
This method is run once during automatic data collection if collection of custom data is enabled.
protected abstract void CollectCustomData()Track()
This method is run once at the end of a TryInvokeMethod call and should be implemented by any classes extending DynamicTracker to perform implementation specific tracking.
protected abstract bool Track()Returns
bool
true if tracking was successful, false otherwise.
AddData(string, object?)
Adds arbitrary objects as additional data to be tracked by Application Insights.
protected void AddData(string name, object? value)Parameters
name string
Key value uniquely associated with the object.
value object
The object to be added to tracked data.