Microsoft Certified: Azure Developer Associate (AZ-204)Monitor, troubleshoot, and optimize Azure solutionsEasy

A development team is building a serverless application using Azure Functions and needs to monitor custom business events and metrics within their function executions. They want to track specific user actions, internal processing steps, and calculated values to gain deeper insights into application behavior. Which Application Insights SDK method should they use to send these custom events and metrics?

  1. ATrackEvent and TrackMetric
  2. BTrackRequest
  3. CTrackDependency
  4. DTrackTrace
Show answer & explanation

Correct answer: A. TrackEvent and TrackMetric

The `TrackEvent` method is used to record discrete business events, while `TrackMetric` is used for sending numerical values that can be aggregated and analyzed over time. Both are ideal for custom business events and metrics, respectively.

Why the other options are wrong

  • B. `TrackRequest` automatically captures information about HTTP requests and responses, not custom business logic.
  • C. `TrackDependency` is used to monitor calls to external services or databases, not internal business events or custom metrics.
  • D. `TrackTrace` is used for logging diagnostic messages, not for distinct business events or measurable metrics.

Application Insights Custom Telemetry

Sending custom events, metrics, traces, and dependencies to Application Insights from your application code to gain deeper insights beyond standard auto-collected telemetry.

  • Uses SDK methods like TrackEvent, TrackMetric, TrackTrace.
  • Enables monitoring of specific business logic.
  • Helps in root cause analysis of application-specific issues.

Memory trick: Track everything: Events for actions, Metrics for numbers!

More Monitor, troubleshoot, and optimize Azure solutions questions