-
Notifications
You must be signed in to change notification settings - Fork 469
Add AppInsights module to publish metrics #11365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces Application Insights metric exporting for .NET Meter API instruments in Azure Functions, enabling improved observability by allowing custom and built-in metrics to be exported to Application Insights for monitoring and diagnostics.
- Adds a custom
ApplicationInsightsMetricExporter
that listens to .NET Meter API instruments and exports their metrics to Application Insights - Implements configuration options and utility extensions for robust metric collection and graceful shutdown handling
- Integrates the metric exporter into the dependency injection setup with configuration for the core Functions meter
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
ScriptHostBuilderExtensions.cs | Adds DI registration for the metric exporter and configures it to listen to the Functions meter |
ApplicationInsightsMetricExporter.cs | Core exporter implementation that listens to Meter API instruments and exports to Application Insights |
ApplicationInsightsMetricExporterOptions.cs | Configuration options for specifying which meters to monitor and collection intervals |
TelemetryClientExtensions.cs | Extension methods for efficiently mapping Meter instruments to Application Insights metrics with dimension handling |
CancellationExtensions.cs | Utility methods for safe cancellation token handling during shutdown |
src/WebJobs.Script/Diagnostics/ApplicationInsightsMetricExporter.cs
Outdated
Show resolved
Hide resolved
src/WebJobs.Script/Diagnostics/ApplicationInsightsMetricExporter.cs
Outdated
Show resolved
Hide resolved
src/WebJobs.Script/Diagnostics/ApplicationInsightsMetricExporter.cs
Outdated
Show resolved
Hide resolved
src/WebJobs.Script/Diagnostics/ApplicationInsightsMetricExporter.cs
Outdated
Show resolved
Hide resolved
src/WebJobs.Script/Diagnostics/ApplicationInsightsMetricExporter.cs
Outdated
Show resolved
Hide resolved
6cdea89
to
d6c4fdc
Compare
Issue describing the changes in this PR
resolves #11364
Pull request checklist
IMPORTANT: Currently, changes must be backported to the
in-proc
branch to be included in Core Tools and non-Flex deployments.in-proc
branch is not requiredrelease_notes.md
Additional information
This PR adds an app insights telemetry module which exports Meter API instruments to app insights.
Co-pilot summary
This pull request introduces a new system for exporting .NET Meter API metrics to Application Insights, allowing for improved observability of metrics in Azure Functions. The main changes include implementing a custom metric exporter, configuration options, and integration into the application's dependency injection setup. Additionally, supporting extensions and utility methods were added to ensure smooth operation and graceful shutdown.
Metrics Exporter Integration:
ApplicationInsightsMetricExporter
, a customITelemetryModule
that listens to .NET Meter API instruments and exports their metrics to Application Insights. It handles various numeric types and supports asynchronous collection and graceful shutdown.ApplicationInsightsMetricExporterOptions
for configuring which meters to listen to and the collection interval, with support for future extensibility.ScriptHostBuilderExtensions
, registering the exporter and configuring it to listen to the core Functions meter.Telemetry and Utility Enhancements:
TelemetryClientExtensions
to efficiently map Meter instruments and their tags to Application Insights metrics, handling up to 10 dimensions and avoiding unnecessary allocations.CancellationExtensions
to safely cancelCancellationTokenSource
instances, handling disposed exceptions gracefully, which is used for robust exporter shutdown.Dependency and Usability Updates:
ScriptHostBuilderExtensions
to support the new metrics exporter integration. [1] [2] [3]These changes collectively enable first-class support for exporting custom and built-in .NET metrics to Application Insights, improving monitoring and diagnostics for Azure Functions.