Skip to content
This repository was archived by the owner on Jul 30, 2024. It is now read-only.

Commit 833932e

Browse files
authored
Implement new telemetry (#678)
Today, we have to parse Application Insights logs to figure out how a message handler's duration. This makes it impossible to dashboard and monitor. This metric will let us detect messages that caused deadlettering by exceeding their expected duration. Depends on NuGet/ServerCommon#230 Part of NuGet/NuGetGallery#6624
1 parent 5ece44e commit 833932e

11 files changed

Lines changed: 130 additions & 14 deletions

File tree

src/NuGet.Jobs.Common/NuGet.Jobs.Common.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,13 @@
105105
<PrivateAssets>all</PrivateAssets>
106106
</PackageReference>
107107
<PackageReference Include="NuGet.Services.Configuration">
108-
<Version>2.38.0</Version>
108+
<Version>2.39.0</Version>
109109
</PackageReference>
110110
<PackageReference Include="NuGet.Services.Logging">
111-
<Version>2.38.0</Version>
111+
<Version>2.39.0</Version>
112112
</PackageReference>
113113
<PackageReference Include="NuGet.Services.Sql">
114-
<Version>2.38.0</Version>
114+
<Version>2.39.0</Version>
115115
</PackageReference>
116116
<PackageReference Include="System.Net.Http">
117117
<Version>4.3.3</Version>

src/NuGet.Services.Revalidate/NuGet.Services.Revalidate.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
<PrivateAssets>all</PrivateAssets>
124124
</PackageReference>
125125
<PackageReference Include="NuGet.Services.Status">
126-
<Version>2.38.0</Version>
126+
<Version>2.39.0</Version>
127127
</PackageReference>
128128
</ItemGroup>
129129
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

src/NuGet.Services.Validation.Orchestrator/Telemetry/TelemetryService.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ public class TelemetryService : ITelemetryService, ISubscriptionProcessorTelemet
3232
private const string DurationToHashPackageSeconds = OrchestratorPrefix + "DurationToHashPackageSeconds";
3333
private const string MessageDeliveryLag = OrchestratorPrefix + "MessageDeliveryLag";
3434
private const string MessageEnqueueLag = OrchestratorPrefix + "MessageEnqueueLag";
35+
private const string MessageHandlerDurationSeconds = OrchestratorPrefix + "MessageHandlerDurationSeconds";
36+
private const string MessageLockLost = OrchestratorPrefix + "MessageLockLost";
3537
private const string SymbolsMessageEnqueued = OrchestratorPrefix + "SymbolsMessageEnqueued";
3638

3739
private const string DurationToStartPackageSigningValidatorSeconds = PackageSigningPrefix + "DurationToStartSeconds";
@@ -51,6 +53,8 @@ public class TelemetryService : ITelemetryService, ISubscriptionProcessorTelemet
5153
private const string HashAlgorithm = "HashAlgorithm";
5254
private const string StreamType = "StreamType";
5355
private const string MessageType = "MessageType";
56+
private const string CallGuid = "CallGuid";
57+
private const string Handled = "Handled";
5458
private const string ValidationId = "ValidationId";
5559
private const string OperationDateTime = "OperationDateTime";
5660

@@ -251,6 +255,31 @@ public void TrackMessageDeliveryLag<TMessage>(TimeSpan deliveryLag)
251255
{ MessageType, typeof(TMessage).Name }
252256
});
253257

258+
public void TrackMessageHandlerDuration<TMessage>(TimeSpan duration, Guid callGuid, bool handled)
259+
{
260+
_telemetryClient.TrackMetric(
261+
MessageHandlerDurationSeconds,
262+
duration.TotalSeconds,
263+
new Dictionary<string, string>
264+
{
265+
{ MessageType, typeof(TMessage).Name },
266+
{ CallGuid, callGuid.ToString() },
267+
{ Handled, handled.ToString() }
268+
});
269+
}
270+
271+
public void TrackMessageLockLost<TMessage>(Guid callGuid)
272+
{
273+
_telemetryClient.TrackMetric(
274+
MessageLockLost,
275+
1,
276+
new Dictionary<string, string>
277+
{
278+
{ MessageType, typeof(TMessage).Name },
279+
{ CallGuid, callGuid.ToString() }
280+
});
281+
}
282+
254283
public void TrackEnqueueLag<TMessage>(TimeSpan enqueueLag)
255284
=> _telemetryClient.TrackMetric(
256285
MessageEnqueueLag,

src/PackageHash/PackageHash.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
<Version>1.1.2</Version>
8282
</PackageReference>
8383
<PackageReference Include="NuGet.Services.Cursor">
84-
<Version>2.38.0</Version>
84+
<Version>2.39.0</Version>
8585
</PackageReference>
8686
</ItemGroup>
8787
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

src/PackageLagMonitor/Monitoring.PackageLag.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
<Version>0.5.0-CI-20180510-012541</Version>
113113
</PackageReference>
114114
<PackageReference Include="NuGet.Services.AzureManagement">
115-
<Version>2.38.0</Version>
115+
<Version>2.39.0</Version>
116116
</PackageReference>
117117
<PackageReference Include="System.Net.Http">
118118
<Version>4.3.3</Version>

src/StatusAggregator/StatusAggregator.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,13 @@
157157
<Version>1.1.1</Version>
158158
</PackageReference>
159159
<PackageReference Include="NuGet.Services.Incidents">
160-
<Version>2.38.0</Version>
160+
<Version>2.39.0</Version>
161161
</PackageReference>
162162
<PackageReference Include="NuGet.Services.Status">
163-
<Version>2.38.0</Version>
163+
<Version>2.39.0</Version>
164164
</PackageReference>
165165
<PackageReference Include="NuGet.Services.Status.Table">
166-
<Version>2.38.0</Version>
166+
<Version>2.39.0</Version>
167167
</PackageReference>
168168
<PackageReference Include="WindowsAzure.Storage">
169169
<Version>9.2.0</Version>

src/Validation.Common.Job/Validation.Common.Job.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,16 @@
103103
<Version>5.0.0-preview1.5665</Version>
104104
</PackageReference>
105105
<PackageReference Include="NuGet.Services.ServiceBus">
106-
<Version>2.38.0</Version>
106+
<Version>2.39.0</Version>
107107
</PackageReference>
108108
<PackageReference Include="NuGet.Services.Storage">
109-
<Version>2.38.0</Version>
109+
<Version>2.39.0</Version>
110110
</PackageReference>
111111
<PackageReference Include="NuGet.Services.Validation">
112-
<Version>2.38.0</Version>
112+
<Version>2.39.0</Version>
113113
</PackageReference>
114114
<PackageReference Include="NuGet.Services.Validation.Issues">
115-
<Version>2.38.0</Version>
115+
<Version>2.39.0</Version>
116116
</PackageReference>
117117
<PackageReference Include="NuGetGallery.Core">
118118
<Version>4.4.5-master-2224741</Version>

src/Validation.PackageSigning.ProcessSignature/Telemetry/TelemetryService.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ public class TelemetryService : ITelemetryService, ISubscriptionProcessorTelemet
1616
private const string DurationToStripRepositorySignaturesSeconds = Prefix + "DurationToStripRepositorySignaturesSeconds";
1717
private const string MessageDeliveryLag = Prefix + "MessageDeliveryLag";
1818
private const string MessageEnqueueLag = Prefix + "MessageEnqueueLag";
19+
private const string MessageHandlerDurationSeconds = Prefix + "MessageHandlerDurationSeconds";
20+
private const string MessageLockLost = Prefix + "MessageLockLost";
1921

2022
private const string PackageId = "PackageId";
2123
private const string NormalizedVersion = "NormalizedVersion";
@@ -26,6 +28,8 @@ public class TelemetryService : ITelemetryService, ISubscriptionProcessorTelemet
2628
private const string OutputCounterSignatureCount = "OutputCounterSignatureCount";
2729
private const string Changed = "Changed";
2830
private const string MessageType = "MessageType";
31+
private const string CallGuid = "CallGuid";
32+
private const string Handled = "Handled";
2933

3034
private readonly ITelemetryClient _telemetryClient;
3135

@@ -100,5 +104,30 @@ public void TrackEnqueueLag<TMessage>(TimeSpan enqueueLag)
100104
{
101105
{ MessageType, typeof(TMessage).Name }
102106
});
107+
108+
public void TrackMessageHandlerDuration<TMessage>(TimeSpan duration, Guid callGuid, bool handled)
109+
{
110+
_telemetryClient.TrackMetric(
111+
MessageHandlerDurationSeconds,
112+
duration.TotalSeconds,
113+
new Dictionary<string, string>
114+
{
115+
{ MessageType, typeof(TMessage).Name },
116+
{ CallGuid, callGuid.ToString() },
117+
{ Handled, handled.ToString() }
118+
});
119+
}
120+
121+
public void TrackMessageLockLost<TMessage>(Guid callGuid)
122+
{
123+
_telemetryClient.TrackMetric(
124+
MessageLockLost,
125+
1,
126+
new Dictionary<string, string>
127+
{
128+
{ MessageType, typeof(TMessage).Name },
129+
{ CallGuid, callGuid.ToString() }
130+
});
131+
}
103132
}
104133
}

src/Validation.PackageSigning.ValidateCertificate/TelemetryService.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,17 @@ public class TelemetryService : ITelemetryService, ISubscriptionProcessorTelemet
1717
private const string UnableToValidateCertificate = Prefix + "UnableToValidateCertificate";
1818
private const string MessageDeliveryLag = Prefix + "MessageDeliveryLag";
1919
private const string MessageEnqueueLag = Prefix + "MessageEnqueueLag";
20+
private const string MessageHandlerDurationSeconds = Prefix + "MessageHandlerDurationSeconds";
21+
private const string MessageLockLost = Prefix + "MessageLockLost";
2022

2123
private const string PackageId = "PackageId";
2224
private const string PackageNormalizedVersion = "PackageNormalizedVersion";
2325
private const string PackageSignatureId = "PackageSignatureId";
2426
private const string CertificateId = "CertificateId";
2527
private const string CertificateThumbprint = "CertificateThumbprint";
2628
private const string MessageType = "MessageType";
29+
private const string CallGuid = "CallGuid";
30+
private const string Handled = "Handled";
2731

2832
private readonly TelemetryClient _telemetryClient;
2933

@@ -87,5 +91,30 @@ public void TrackEnqueueLag<TMessage>(TimeSpan enqueueLag)
8791
{
8892
{ MessageType, typeof(TMessage).Name }
8993
});
94+
95+
public void TrackMessageHandlerDuration<TMessage>(TimeSpan duration, Guid callGuid, bool handled)
96+
{
97+
_telemetryClient.TrackMetric(
98+
MessageHandlerDurationSeconds,
99+
duration.TotalSeconds,
100+
new Dictionary<string, string>
101+
{
102+
{ MessageType, typeof(TMessage).Name },
103+
{ CallGuid, callGuid.ToString() },
104+
{ Handled, handled.ToString() }
105+
});
106+
}
107+
108+
public void TrackMessageLockLost<TMessage>(Guid callGuid)
109+
{
110+
_telemetryClient.TrackMetric(
111+
MessageLockLost,
112+
1,
113+
new Dictionary<string, string>
114+
{
115+
{ MessageType, typeof(TMessage).Name },
116+
{ CallGuid, callGuid.ToString() }
117+
});
118+
}
90119
}
91120
}

src/Validation.ScanAndSign.Core/Validation.ScanAndSign.Core.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
<PrivateAssets>all</PrivateAssets>
6565
</PackageReference>
6666
<PackageReference Include="NuGet.Services.ServiceBus">
67-
<Version>2.38.0</Version>
67+
<Version>2.39.0</Version>
6868
</PackageReference>
6969
<PackageReference Include="MicroBuild.Core">
7070
<Version>0.3.0</Version>

0 commit comments

Comments
 (0)