Add custom telemetry signals

Add custom telemetry signals

In continuation to my previous posts - Part 1, Part 2 , Part 3, this article covers about the custom telemetry signals .

The out of box telemetry signals captures the insights from the standard process.

It is also possible to extend signals to provide more insights to custom processes using the below class:

SysApplicationInsightsTelemetryLogger:

The class is present in the model 'Monitoring and Telemetry' .

Telemetry logger

The class uses the references to AppInsights telemetry client which provides access to the operations to track an event , trace , exception or metric.

Class declaration

The class uses the static constructor pattern to ensure a singleton instance per user session.

initialising the instance

The encapsulated Azure Application Insights telemetry client is further cached to ensure that only one telemetry client is created per Application Object Server (AOS) instance.

Constructor

Telemetry data contract types

Data contract types

Refer to the below documents for each contract

EventTelemetry class PageViewTelemetry class ExceptionTelemetry class TraceTelemetry class

Event Telemetry

To log a custom event to Azure Application Insights, you can create an instance of the SysApplicationInsightsEventTelemetry class and pass in the necessary payload.

Then use the trackEvent method on the SysApplicationInsightsTelemetryLogger class to emit the event.

Given below the method in the Logger class

Event method
Standard call to event log

A custom event telemetry when a record is created in SysUserLog table is given below.

Page views Telemetry

The logger logs every form that is opened in the application.

trackPageView

Given below the reference of the logger in standard class

Log page views to AppInsights capturing form completion

Exceptions Telemetry:

Track exceptions in Application insights using trackException method.

TrackException in Logger class

Reference in the standard where all errors that are presented in the Infolog are automatically emitted to Azure Application Insights.

Using trackException

Traces Telemetry:

Track exceptions using trackTrace method.

trackTrace in logger class

The above code snippet refers extending the trackTrace for custom traces.

Metrics Telemetry:

For metrics, no specific data contract is needed. Instead, you can interact directly with the class by using the method.

The logger first gets the existing metric instance from Azure Application Insights and updates the value.

trackMetric

By using , you can add properties that should be used as dimensions. Values can then be sliced based on those dimensions.

trackMetricWithDimensions

More reference about metrics is here

Other References:

https://learn.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/monitoring-telemetry/monitoring-developer-add-custom-signals#telemetry-logger

https://learn.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/monitoring-telemetry/monitoring-developer-add-custom-signals#telemetry-data-contract-types

In the next post , we will understand about the telemetry costs.

To view or add a comment, sign in

Others also viewed

Explore topics