Skip to content

Commit 92cf9d1

Browse files
authored
Add NServiceBus 10 version of the Metrics snippets (#7749)
1 parent e3f3291 commit 92cf9d1

File tree

4 files changed

+56
-0
lines changed

4 files changed

+56
-0
lines changed

Snippets/Metrics/Metrics.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Metrics_4", "Metrics_4\Metr
88
EndProject
99
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Metrics_5", "Metrics_5\Metrics_5.csproj", "{F8F32616-85F4-48F9-871F-46246FF37479}"
1010
EndProject
11+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Metrics_6", "Metrics_6\Metrics_6.csproj", "{150068EF-8B97-4804-A8F7-1C001D1F4013}"
12+
EndProject
1113
Global
1214
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1315
Debug|Any CPU = Debug|Any CPU
@@ -26,6 +28,10 @@ Global
2628
{F8F32616-85F4-48F9-871F-46246FF37479}.Debug|Any CPU.Build.0 = Debug|Any CPU
2729
{F8F32616-85F4-48F9-871F-46246FF37479}.Release|Any CPU.ActiveCfg = Release|Any CPU
2830
{F8F32616-85F4-48F9-871F-46246FF37479}.Release|Any CPU.Build.0 = Release|Any CPU
31+
{150068EF-8B97-4804-A8F7-1C001D1F4013}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
32+
{150068EF-8B97-4804-A8F7-1C001D1F4013}.Debug|Any CPU.Build.0 = Debug|Any CPU
33+
{150068EF-8B97-4804-A8F7-1C001D1F4013}.Release|Any CPU.ActiveCfg = Release|Any CPU
34+
{150068EF-8B97-4804-A8F7-1C001D1F4013}.Release|Any CPU.Build.0 = Release|Any CPU
2935
EndGlobalSection
3036
GlobalSection(SolutionProperties) = preSolution
3137
HideSolutionNode = FALSE
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using NServiceBus;
2+
using NServiceBus.Logging;
3+
4+
public class Configuration
5+
{
6+
public void ConfigureEndpoint(EndpointConfiguration endpointConfiguration)
7+
{
8+
#region Metrics-Enable
9+
10+
var metrics = endpointConfiguration.EnableMetrics();
11+
12+
#endregion
13+
14+
#region Metrics-Observers
15+
16+
var durationsLog = LogManager.GetLogger("Durations");
17+
var signalsLog = LogManager.GetLogger("Signals");
18+
19+
metrics.RegisterObservers(
20+
register: context =>
21+
{
22+
foreach (var duration in context.Durations)
23+
{
24+
duration.Register(
25+
observer: (ref DurationEvent @event) =>
26+
{
27+
durationsLog.DebugFormat("{0} = {1}", duration.Name, @event.Duration);
28+
});
29+
}
30+
foreach (var signal in context.Signals)
31+
{
32+
signal.Register(
33+
observer: (ref SignalEvent @event) =>
34+
{
35+
signalsLog.DebugFormat("{0} = {1}", signal.Name, @event.MessageType);
36+
});
37+
}
38+
});
39+
40+
#endregion
41+
}
42+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFramework>net10.0</TargetFramework>
4+
</PropertyGroup>
5+
<ItemGroup>
6+
<PackageReference Include="NServiceBus.Metrics" Version="6.0.0-alpha.2" />
7+
</ItemGroup>
8+
</Project>

Snippets/Metrics/Metrics_6/prerelease.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)