topic hubPlatform, DevOps & Performanceofficial - Microsoftreviewed - checked by Opus

Instrumenting with telemetry

Instrumenting Business Central AL code with telemetry. It covers setting up extension telemetry, emitting custom events to Application Insights or the Event Log, using feature telemetry, and the platform events already logged for extensions. It answers how-to and which-method questions.

Path: Development > Programming in the AL language > Instrumenting with telemetry · tier official · system platform · narrative reviewed (checked by Opus)

Overview

Telemetry lets you collect data about usage, errors, performance and lifecycle events from your Business Central application. The pages here cover the full path: the general concepts of adding telemetry signals, the setup needed for extensions, and the AL methods used to emit events.

Start with “Adding Telemetry to Your Business Central Application” for the overall picture, then “Set Up Extension Telemetry in Business Central” to connect an extension to Azure Application Insights through app.json. After that, choose how to log. Feature telemetry (the FeatureTelemetry codeunit) covers usage, errors and uptake. Custom events use Session.LogMessage for Application Insights, or SendTraceTag for the Event Log.

“Data logged to app/extension telemetry” lists the events the platform already emits, such as page interactions, REST API calls, report rendering, error dialogs and resource consumption. Check it before writing custom events. A subtopic holds two reference documentation pages.

Key points

  • Extension telemetry is set up by adding the applicationInsightsConnectionString property (or applicationInsightsKey) in app.json; the setup page mentions runtime 7.2.
  • Session.LogMessage creates custom telemetry events for Application Insights, with dictionary and dimension overloads, TelemetryScope, DataClassification and CustomDimensions parameters.
  • SendTraceTag sends custom trace events to the Business Central Server Event Log, with severity levels, categories and data classification; viewable in Event Viewer.
  • Feature telemetry uses the FeatureTelemetry codeunit with LogUsage, LogError and LogUptake to track feature health and adoption.
  • Uptake states are Discovered, Set up, Used and Undiscovered; a Telemetry Logger interface and custom dimensions allow filtering and comparing features.
  • The platform already logs events for extensions: page interactions, REST API calls, report rendering, error dialogs and resource consumption.
  • The Application Insights custom events page references version 29; the Event Log page references 2020 release wave 2.

Subtopics

More Learn pages

  • Adding Telemetry to Your Business Central Application: Instrument Business Central applications with telemetry to analyze usage, troubleshoot problems, and collect events in Application Insights or Windows logs.
  • Creating Custom Telemetry Events for Azure Application Insights: Add custom telemetry events to Business Central extensions with Session.LogMessage, choose their scope, and define dimensions for Application Insights.
  • Creating Custom Telemetry Events for the Event Log: Create custom telemetry events with SendTraceTag in Business Central on-premises, view them in Windows event logs, and control logging severity.
  • Extension Telemetry Data in Business Central: Learn which Business Central events can reach an extension’s Application Insights resource and how to identify signals that support extension telemetry.
  • Feature telemetry: Learn about the telemetry that you can emit from features in Business Central.
    • Feature Telemetry module simplifies app health monitoring and tracks feature uptake using three event types: LogUsage for successful feature use, LogError for explicit errors, and LogUptake for…
    • Prerequisite: Must implement Telemetry Logger interface in an extension codeunit and register it via OnRegisterTelemetryLogger event subscriber, one per app publisher.
    • LogUptake tracks four uptake states: Undiscovered, Discovered (page opens), Set up (user configures), and Used (user attempts feature). Calling with Undiscovered resets uptake state.
    • Limit: LogUptake may make database transactions and requires PerformWriteTransactionsInASeparateSession set to true when called from try function.
    • Custom dimensions include extension info, user role, environment type, client type, and for errors: stack trace and error text describing the issue.
    • If no telemetry logger registered for publisher, server logs event AL0000G7K to environment telemetry indicating app sending data without registered logger.
    • In the observatory: Codeunit 8703 “Feature Telemetry”, Codeunit 8708 “Telemetry Loggers”
  • Set Up Extension Telemetry in Business Central: Configure a Business Central extension to send telemetry to Azure Application Insights, monitor deployed apps, and add feature or custom telemetry events.

Key facts from Microsoft Learn (CC BY 4.0), in our own words (D106); open the page for the full text.

Videos, posts and code changes

Linked by a Haiku matcher with a grounding quote from the item’s summary (link/topics.ts); machine-generated.

Source: Microsoft Learn (CC BY 4.0). Descriptions are Learn’s own.

What Learn documents here 8 Learn pages