Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Critical time calculated using DeliverAt header - Release 3.1 #291

Merged
merged 1 commit into from
Mar 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<ItemGroup>
<PackageReference Include="GitHubActionsTestLogger" Version="1.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
<PackageReference Include="NServiceBus" Version="7.2.3" />
<PackageReference Include="NServiceBus" Version="7.7.0" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.16.1" />
<PackageReference Include="Particular.Approvals" Version="0.2.0" />
Expand Down
12 changes: 12 additions & 0 deletions src/NServiceBus.Metrics/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ public static bool TryGetTimeSent(this ReceivePipelineCompleted completed, out D
return false;
}

public static bool TryGetDeliverAt(this ReceivePipelineCompleted completed, out DateTime deliverAt)
{
var headers = completed.ProcessedMessage.Headers;
if (headers.TryGetValue(Headers.DeliverAt, out var deliverAtString))
{
deliverAt = DateTimeExtensions.ToUtcDateTime(deliverAtString);
return true;
}
deliverAt = DateTime.MinValue;
return false;
}

public static bool TryGetMessageType(this ReceivePipelineCompleted completed, out string processedMessageType)
{
return completed.ProcessedMessage.Headers.TryGetMessageType(out processedMessageType);
Expand Down
4 changes: 2 additions & 2 deletions src/NServiceBus.Metrics/NServiceBus.Metrics.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NServiceBus" Version="[7.0.0, 8.0.0)" />
<PackageReference Include="NServiceBus" Version="[7.7.0, 8.0.0)" />
<PackageReference Include="Particular.Packaging" Version="1.2.1" PrivateAssets="All" />
</ItemGroup>

</Project>
</Project>
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using NServiceBus;
using NServiceBus.Features;
using NServiceBus.Metrics;
Expand All @@ -16,9 +17,9 @@ protected override void WireUp(DurationProbe probe)
{
context.Pipeline.OnReceivePipelineCompleted(e =>
{
if (e.TryGetTimeSent(out var timeSent))
if (e.TryGetDeliverAt(out var startTime) || e.TryGetTimeSent(out startTime))
{
var endToEndTime = e.CompletedAt - timeSent;
var endToEndTime = e.CompletedAt - startTime;
e.TryGetMessageType(out var messageType);

var @event = new DurationEvent(endToEndTime, messageType);
Expand All @@ -30,4 +31,4 @@ protected override void WireUp(DurationProbe probe)
}

readonly FeatureConfigurationContext context;
}
}
2 changes: 2 additions & 0 deletions src/NServiceBus.Metrics/ProbeBuilders/RetriesProbeBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ public RetriesProbeBuilder(FeatureConfigurationContext context)
protected override void WireUp(SignalProbe probe)
{
var errors = notifications.Errors;
#pragma warning disable CS0618 // Type or member is obsolete
errors.MessageHasFailedAnImmediateRetryAttempt += (sender, message) => Signal(message.Headers, probe);
errors.MessageHasBeenSentToDelayedRetries += (sender, message) => Signal(message.Headers, probe);
#pragma warning restore CS0618 // Type or member is obsolete
Comment on lines +19 to +22
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just guessing, is that stuff obsolete in 7.7 becuase it's getting cancellation tokens in V8? (which we obviously can't update it to yet in this version)

}

static void Signal(Dictionary<string, string> messageHeaders, SignalProbe probe)
Expand Down