Skip to content

Commit

Permalink
Fix test error from addition of WorkItemMetrics
Browse files Browse the repository at this point in the history
  • Loading branch information
MrHinsh committed Sep 5, 2024
1 parent a13a3b5 commit 3023335
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 8 deletions.
12 changes: 6 additions & 6 deletions docs/Reference/Generated/MigrationTools.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion src/MigrationTools.Shadows/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.Extensions.DependencyInjection;
using System.Diagnostics.Metrics;
using Microsoft.Extensions.DependencyInjection;
using MigrationTools.Clients;
using MigrationTools.Clients.Shadows;
using MigrationTools.Services;
Expand Down Expand Up @@ -32,6 +33,11 @@ public static void AddMigrationToolServicesForUnitTests(this IServiceCollection
context.AddSingleton<ITelemetryLogger, TelemetryLoggerFake>();
context.AddSingleton<IMigrationToolVersion, FakeMigrationToolVersion>();
context.AddSingleton<IWorkItemQueryBuilderFactory, WorkItemQueryBuilderFactoryFake>();


// Meters
context.AddSingleton<IMeterFactory, MeterFactoryFake>();
context.AddSingleton<WorkItemMetrics>();
}
}
}
22 changes: 22 additions & 0 deletions src/MigrationTools.Shadows/Services/MeterFactoryFake.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.Metrics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MigrationTools.Services.Shadows
{
public class MeterFactoryFake : IMeterFactory
{
public Meter Create(MeterOptions options)
{
return new Meter(options);
}

public void Dispose()
{
// do nothing
}
}
}
2 changes: 1 addition & 1 deletion src/MigrationTools/Services/WorkItemMetrics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class WorkItemMetrics

public Histogram<double> RevisionsPerWorkItem { get; private set; }

public WorkItemMetrics(IMeterFactory meterFactory, IConfiguration configuration)
public WorkItemMetrics(IMeterFactory meterFactory)
{
WorkItemMeter = meterFactory.Create(meterName);
WorkItemsProcessedCount = WorkItemMeter.CreateCounter<long>("work_items_processed_total");
Expand Down

0 comments on commit 3023335

Please sign in to comment.