Skip to content

Commit fe76296

Browse files
authored
Update logging around GetWorkItem (#1760)
* Update logging around GetWorkItem * Added exception for no ID
1 parent 6a99c83 commit fe76296

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/MigrationTools.Clients.AzureDevops.ObjectModel/_Enginev1/Clients/TfsWorkItemMigrationClient.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using MigrationTools._EngineV1.DataContracts;
1010
using MigrationTools.DataContracts;
1111
using Serilog;
12+
using static Microsoft.TeamFoundation.Client.CommandLine.Options;
1213

1314
namespace MigrationTools._EngineV1.Clients
1415
{
@@ -150,28 +151,36 @@ public override WorkItemData GetWorkItem(string id)
150151

151152
public override WorkItemData GetWorkItem(int id)
152153
{
154+
if (id == 0)
155+
{
156+
throw new ArgumentOutOfRangeException("id", id, "id cant be empty.");
157+
}
153158
var startTime = DateTime.UtcNow;
154159
var timer = System.Diagnostics.Stopwatch.StartNew();
155160
WorkItem y;
156161
try
157162
{
163+
Log.Debug("TfsWorkItemMigrationClient::GetWorkItem({id})", id);
158164
y = Store.GetWorkItem(id);
159165
timer.Stop();
160166
Telemetry.TrackDependency(new DependencyTelemetry("TfsObjectModel", MigrationClient.Config.AsTeamProjectConfig().Collection.ToString(), "GetWorkItem", null, startTime, timer.Elapsed, "200", true));
161167
}
162168
catch (Exception ex)
163169
{
164-
timer.Stop();
165-
Telemetry.TrackDependency(new DependencyTelemetry("TfsObjectModel", MigrationClient.Config.AsTeamProjectConfig().Collection.ToString(), "GetWorkItem", null, startTime, timer.Elapsed, "500", false));
166170
Telemetry.TrackException(ex,
167171
new Dictionary<string, string> {
168172
{ "CollectionUrl", MigrationClient.Config.AsTeamProjectConfig().Collection.ToString() }
169173
},
170174
new Dictionary<string, double> {
171175
{ "Time",timer.ElapsedMilliseconds }
172176
});
173-
Log.Error(ex, "Unable to configure store");
177+
Log.Error(ex, "Unable to GetWorkItem with id[{id}]", id);
174178
throw;
179+
} finally
180+
{
181+
timer.Stop();
182+
Telemetry.TrackDependency(new DependencyTelemetry("TfsObjectModel", MigrationClient.Config.AsTeamProjectConfig().Collection.ToString(), "GetWorkItem", null, startTime, timer.Elapsed, "500", false));
183+
175184
}
176185
return y?.AsWorkItemData();
177186
}
@@ -273,6 +282,7 @@ private WorkItemStore GetWorkItemStore()
273282
WorkItemStore store;
274283
try
275284
{
285+
Log.Debug("TfsWorkItemMigrationClient::GetWorkItemStore({InternalCollection}, {bypassRules})", _config.AsTeamProjectConfig().Collection, _bypassRules);
276286
store = new WorkItemStore((TfsTeamProjectCollection)MigrationClient.InternalCollection, _bypassRules);
277287
timer.Stop();
278288
Telemetry.TrackDependency(new DependencyTelemetry("TfsObjectModel", MigrationClient.Config.AsTeamProjectConfig().Collection.ToString(), "GetWorkItemStore", null, startTime, timer.Elapsed, "200", true));

0 commit comments

Comments
 (0)