Telemetry and Monitory with Applications Insights and Dynamics 365 F&O
Telemetry and Monitory with Applications Insights and Dynamics 365 F&O
With version 10.0.39 Applications Insights integrations is GA. Hence, here is a very simple example how to start using this great feature and start monitoring the performance of your application.
For more about D365FO and Application Insights integration:
For more about D365FO and Application Insights integration:
- Monitoring and telemetry using Application Insights - Finance & Operations | Dynamics 365 | Microsoft Learn
- Dynamics 365 Finance and Operations - Monitoring and Telemetry using Application Insights -TechTalk (youtube.com)
In this example we will monitor the execution time of a batch job. In particular, we will use a metric to analyze the execution over time.
// Create a class file and paste this code
class SlowBatchJobClass extends RunBaseBatch implements BatchRetryable { [SysEntryPointAttribute] public void run() { int maxWaitInSeconds = 20; // Maximum wait time in seconds SysApplicationInsightsTelemetryLogger logger = SysApplicationInsightsTelemetryLogger::instance(); // get logger instance // Record the start time utcdatetime startTime = DateTimeUtil::utcNow(); // Your logic here info("Executing batch job logic..."); // Simulate random wait time RandomGenerate randomGenerate; randomGenerate = RandomGenerate::construct(); int waitTime = randomGenerate.randomInt(1, maxWaitInSeconds); info(strFmt("Waiting for %1 seconds...", waitTime)); System.Threading.Thread::sleep(waitTime * 1000); // Convert seconds to milliseconds // Calculate the job execution time utcdatetime endTime = DateTimeUtil::utcNow(); int64 executionTime = DateTimeUtil::getDifference(endTime, startTime); // Log job execution time logger.trackMetric("SlowBatchJobClass_ExecutionTime", executionTime); info("Batch job completed successfully."); } public boolean isRetryable() { return true; // Indicates that the batch job is retryable } }
The metric is sent to Application Insights by calling the logMetric method from the
SysGlobalTelemetry class.
Note: No previous configuration/creation of the metric is necessary.
After a few executions of the Batch Job the metric automatically appears in Application Insights
Comments
Post a Comment