@@ -18,7 +18,7 @@ namespace Microsoft.Azure.WebJobs.Script.Diagnostics
18
18
/// <summary>
19
19
/// A meter listener which exports metrics to Application Insights.
20
20
/// </summary>
21
- public sealed class ApplicationInsightsMetricExporter : ITelemetryModule , IAsyncDisposable
21
+ public sealed partial class ApplicationInsightsMetricExporter : ITelemetryModule , IAsyncDisposable
22
22
{
23
23
private readonly MeterListener _listener ;
24
24
private readonly ApplicationInsightsMetricExporterOptions _options ;
@@ -42,6 +42,7 @@ public ApplicationInsightsMetricExporter(IOptions<ApplicationInsightsMetricExpor
42
42
{
43
43
if ( _options . ShouldListenTo ( instrument ) )
44
44
{
45
+ Events . Log . SubscribedToInstrument ( instrument ) ;
45
46
listener . EnableMeasurementEvents ( instrument , this ) ;
46
47
}
47
48
} ,
@@ -65,6 +66,8 @@ public void Initialize(TelemetryConfiguration configuration)
65
66
{
66
67
ArgumentNullException . ThrowIfNull ( configuration ) ;
67
68
ObjectDisposedException . ThrowIf ( _shutdown . IsCancellationRequested , this ) ;
69
+
70
+ Events . Log . MeterListeningStarted ( ) ;
68
71
_client = new TelemetryClient ( configuration ) ;
69
72
_listener . Start ( ) ;
70
73
_exportTask = CollectAsync ( _shutdown . Token ) ;
@@ -73,6 +76,7 @@ public void Initialize(TelemetryConfiguration configuration)
73
76
/// <inheritdoc />
74
77
public async ValueTask DisposeAsync ( )
75
78
{
79
+ Events . Log . MeterListeningStopped ( ) ;
76
80
_listener . Dispose ( ) ;
77
81
78
82
await _shutdown . CancelNoThrowAsync ( ) ;
@@ -114,12 +118,14 @@ private async Task CollectAsync(CancellationToken cancellation)
114
118
{
115
119
try
116
120
{
121
+ Events . Log . BeginCollectObservables ( ) ;
117
122
_listener . RecordObservableInstruments ( ) ;
123
+ Events . Log . EndCollectObservables ( ) ;
118
124
await Task . Delay ( _options . CollectInterval , cancellation ) ;
119
125
}
120
126
catch ( Exception ex ) when ( ! ex . IsFatal ( ) )
121
127
{
122
- // swallow exceptions
128
+ Events . Log . FailedToCollectInstruments ( ex ) ;
123
129
}
124
130
}
125
131
}
0 commit comments