Monitoring and telemetry in F&O

Applications Insights in an Azure service for monitoring of applications. Many Azure Services support it out of the box – you just connect, say, an Azure Function to Application Insights and it’ll automatically start collecting information about performance, failed requests and so on.

Using Application Insights API from D365FO is possible and several people in past showed custom solutions for that. But now there is also a solution from Microsoft included in F&O out of the box – it’s called Monitoring and telemetry.

You can find quite a few blog posts about the setup, such as this one, therefore I’m not going to duplicate it here.

But if you aren’t familiar with Application Insights / Azure Monitor, let me give you one example how it can be useful. Support personnel and developers are often interested in details of exceptions thrown in the application.

If enabled in F&O, Application Insights automatically collects information about such exceptions. You can see on overview of exceptions in a certain period:

you can query logs for particular exceptions and you can see a lot of details of an individual exception, including X++ call stack:

Notice also the actions available to you, such as the option to create a work item (in Azure DevOps or GitHub) or to see all available telemetry for the user session.

Note that you can use it in all types of environments. It’s most important in production, because you can’t debug there, but collecting extra data is useful in development and test environments too.

Custom messages

Some information, such as exceptions and form access, are collected by F&O automatically (if enabled).

But you also use code to log any information that it’s important for you, such as when something interesting happens, to provide trace message with extra context for debugging and to log custom metrics.

I didn’t particularly like the solution I saw in 10.0.31 and 32, because it didn’t support custom properties, but it has changed. The support was added somewhere between 10.0.32 and 10.0.35.

Let me give you an example. Here I’m adding a trace message from X++, but instead of adding just the message itself, I’m also adding two custom properties:

Map properties = new Map(Types::String, Types::String);
properties.add('Feature', 'My feature 1');
properties.add('MyCorrelationId', '123456');
SysGlobalTelemetry::logTraceWithCustomProperties('Custom message from X++', properties)

When looking into logs, I can see not just the textual message, but also my properties as structured data.

And what is even more important, I can easily use properties in filters and graphs. For example:

AppTraces | where Properties.Feature == 'My feature 1'

Leave a Reply

Your email address will not be published. Required fields are marked *