Skip to content

Telemetry Class

Definition

Top level static class that provides easy access to telemetry operations.

C#
[Obsolete("Telemetry is deprecated. See the upgrade guide at https://sqtechdocs.azurewebsites.net/docs/tooltelemetry/index.html")]
public static class Telemetry

Inheritance object

Properties

Session

Gets the session data.

C#
public static SessionData Session { get; }

ConfigurationLocked

Gets a value indicating whether the configuration is currently locked.

C#
public static bool ConfigurationLocked { get; }

TrackEvent

Gets a Tracker used for tracking custom Events in ApplicationInsights.

C#
public static dynamic TrackEvent { get; }

TrackException

Gets a Tracker used for tracking Exceptions in ApplicationInsights.

C#
public static dynamic TrackException { get; }

TrackMetric

Gets a Tracker used for tracking Metrics in ApplicationInsights.

C#
public static dynamic TrackMetric { get; }

TrackCritical

Gets a Tracker used for tracking critical traces in ApplicationInsights.

C#
public static dynamic TrackCritical { get; }

TrackError

Gets a Tracker used for tracking error traces in ApplicationInsights.

C#
public static dynamic TrackError { get; }

TrackInfo

Gets a Tracker used for tracking information traces in ApplicationInsights.

C#
public static dynamic TrackInfo { get; }

TrackVerbose

Gets a Tracker used for tracking verbose traces in ApplicationInsights.

C#
public static dynamic TrackVerbose { get; }

TrackWarn

Gets a Tracker used for tracking warning traces in ApplicationInsights.

C#
public static dynamic TrackWarn { get; }

Methods

Flush()

Flushes data to Application Insights.

C#
public static void Flush()

Configure(string?, CollectionMode?, TimeSpan?, Severity?, bool?, Dictionary<string, RequiredParameterInfo>?, Dictionary<string, RequiredParameterInfo>?, Dictionary<string, RequiredParameterInfo>?, Dictionary<string, string>?, Dictionary<string, string>?, Dictionary<string, string>?, Dictionary<string, string>?, Dictionary<string, string>?, bool?)

Configures Telemetry for use. Telemetry can be used without configuration.

C#
public static void Configure(string? connectionString = null, CollectionMode? dataCollectionMode = null, TimeSpan? metricAggregationPeriod = null, Severity? minimumSeverityLevel = null, bool? developerMode = null, Dictionary<string, RequiredParameterInfo>? requiredExceptionParameters = null, Dictionary<string, RequiredParameterInfo>? requiredTraceParameters = null, Dictionary<string, RequiredParameterInfo>? requiredEventParameters = null, Dictionary<string, string>? globalCustomProperties = null, Dictionary<string, string>? exceptionCustomProperties = null, Dictionary<string, string>? traceCustomProperties = null, Dictionary<string, string>? eventCustomProperties = null, Dictionary<string, string>? personallyIdentifiableCustomProperties = null, bool? configurationLocked = null)

Parameters

connectionString string
The instrumentation key to be used across all tracking that is associated with the Application Insights target.

dataCollectionMode CollectionMode?
An Enum Flag specifying what types of additional data should be collected.

metricAggregationPeriod TimeSpan?
Specifies the length of time over which metrics should be aggregated before being sent to Application Insights.

minimumSeverityLevel Severity?
Specifies the minimum severity level to log for all Traces. Any Trace below this severity level will not be sent to Application Insights.

developerMode bool?
Specifies whether or not Application Insights should be run in Developer mode. Developer mode causes telemetry to be processed more rapidly.

requiredExceptionParameters Dictionary<string, RequiredParameterInfo>
A Dictionary of required parameter names that must be passed to all TrackException calls, where the key is the parameter name.

requiredTraceParameters Dictionary<string, RequiredParameterInfo>
A Dictionary of required parameter names that must be passed to all TrackTrace calls, where the key is the parameter name.

requiredEventParameters Dictionary<string, RequiredParameterInfo>
A Dictionary of required parameter names that must be passed to all TrackEvent calls, where the key is the parameter name.

globalCustomProperties Dictionary<string, string>
A Dictionary of properties that are to be added to all Telemetry events.

exceptionCustomProperties Dictionary<string, string>
A Dictionary of properties that are to be added to all Exception Telemetry events.

traceCustomProperties Dictionary<string, string>
A Dictionary of properties that are to be added to all Trace Telemetry events.

eventCustomProperties Dictionary<string, string>
A Dictionary of properties that are to be added to all Event Telemetry events.

personallyIdentifiableCustomProperties Dictionary<string, string>
A Dictionary of properties that are to be added to all Telemetry events, but will not be added if the dataCollectionMode is not set to log Personally Identifiable Information.

configurationLocked bool?
Specifies whether the configuration should be locked after these changes. Locked configurations cannot be changed for the rest of execution.

ResetConfiguration()

Sets all configuration parameters to their default value

C#
public static void ResetConfiguration()

OverrideSessionId(Guid?)

Allows for manually overriding certain session data information; however, be aware that doing so will flag that data as modified in the telemetry.

C#
public static void OverrideSessionId(Guid? sessionId = null)

Parameters

sessionId Guid?
A unique Guid associated with the current session.

OverrideSessionData(Guid?, string?, bool?)

Allows for manually overriding certain session data information; however, be aware that doing so will flag that data as modified in the telemetry.

C#
[Obsolete("OS version and IsDebugBuild as session data are deprecated and cannot be overridden.")]
public static void OverrideSessionData(Guid? sessionId = null, string? osversion = null, bool? isDebugBuild = null)

Parameters

sessionId Guid?
A unique Guid associated with the current session.

osversion string
The version of OS the user is running during this session.

isDebugBuild bool?
Specifies whether this session was run under a Debug build.

GetDefaultContext()

Returns a DefaultTelemetryContext which implements ITelemetryContext with all required parameters set to their default values

C#
public static DefaultTelemetryContext GetDefaultContext()

Returns

DefaultTelemetryContext
A DefaultTelemetryContext object.

RegisterGlobalProperty(string, string)

Registers a global property which will be added to all telemetry events if collection of Global Data is enabled.

C#
public static void RegisterGlobalProperty(string name, string value)

Parameters

name string
The name of the property.

value string
The value of the property.

UnregisterGlobalProperty(string)

Attempts to unregister a global property.

C#
public static void UnregisterGlobalProperty(string name)

Parameters

name string
The name of the property to unregister.

RegisterPersonallyIdentifiableProperty(string, string)

Registers a property which will be added to all telemetry events if collection of PII Data is enabled.

C#
public static void RegisterPersonallyIdentifiableProperty(string name, string value)

Parameters

name string
The name of the property.

value string
The value of the property.

UnregisterPersonallyIdentifiableProperty(string)

Attempts to unregister a PII property.

C#
public static void UnregisterPersonallyIdentifiableProperty(string name)

Parameters

name string
The name of the property to unregister.

RegisterTrackerProperty(TrackerType, string, string)

Registers a property which will be added to all telemetry events of the specified tracker types, and only if collection of Custom Data is enabled.

C#
public static void RegisterTrackerProperty(TrackerType trackerType, string name, string value)

Parameters

trackerType TrackerType
The tracker types for which to register this property.

name string
The name of the property.

value string
The value of the property.

UnregisterTrackerProperty(TrackerType, string)

Attempts to unregister a property for each of the specified tracker types.

C#
public static void UnregisterTrackerProperty(TrackerType trackerType, string name)

Parameters

trackerType TrackerType
The tracker types for which to unregister this property.

name string
The name of the property to unregister.

RegisterRequiredTrackerParameter(TrackerType, string, RequiredParameterInfo)

Registers a required parameter for each of the specified tracker types.

C#
public static void RegisterRequiredTrackerParameter(TrackerType trackerType, string name, RequiredParameterInfo parameterInfo)

Parameters

trackerType TrackerType
The tracker types for which to register the required parameter.

name string
The name of the required parameter.

parameterInfo RequiredParameterInfo
Additional information about the required parameter.

RegisterRequiredTrackerParameter(TrackerType, string, object, string)

Register a required parameter for each of the specified tracker types.

C#
public static void RegisterRequiredTrackerParameter(TrackerType trackerType, string name, object defaultValue, string errorMessage)

Parameters

trackerType TrackerType
The tracker types for which to register the required parameter.

name string
The name of the required parameter.

defaultValue object
The default value of the required parameter.

errorMessage string
An error message to display if the required parameter is not provided to a telemetry call.

UnregisterRequiredTrackerParameter(TrackerType, string)

Attempts to unregister a required parameter for each of the specified tracker types.

C#
public static void UnregisterRequiredTrackerParameter(TrackerType trackerType, string name)

Parameters

trackerType TrackerType
The tracker types for which to unregister the required parameter.

name string
The name of the required parameter to unregister.