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

Emit critical time metric #7058

Closed
wants to merge 19 commits into from
Closed

Conversation

saratry
Copy link
Contributor

@saratry saratry commented Jun 6, 2024

This PR introduces a new OpenTelemetry-native metric for measuring the message's critical time.

POA:

@mauroservienti mauroservienti force-pushed the otel/handling-metrics branch from d1df89e to 829b70e Compare June 20, 2024 09:28
@mauroservienti mauroservienti changed the title Register critical time metric. Emit critical time metric Jun 20, 2024
@mauroservienti mauroservienti marked this pull request as ready for review June 20, 2024 15:28
@mauroservienti
Copy link
Member

Reverting to draft to signal the dependency on #7077 and preventing accidental merge

@mauroservienti mauroservienti marked this pull request as draft June 21, 2024 05:27
@mauroservienti mauroservienti added this to the 9.1.0 milestone Jun 21, 2024
@mauroservienti mauroservienti force-pushed the otel/handling-metrics branch from 1b9dc91 to 53eb461 Compare June 25, 2024 09:05
@mauroservienti
Copy link
Member

@lailabougria @SzymonPobiega, this is ready for a review

Copy link
Contributor

@lailabougria lailabougria left a comment

Choose a reason for hiding this comment

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

again only nits

@@ -19,4 +19,7 @@ class Meters

internal static readonly Histogram<double> MessageHandlerTime =
NServiceBusMeter.CreateHistogram<double>(Metrics.MessageHandlerTime, "s", "The time in seconds for the execution of the business code.");

internal static readonly Histogram<double> CriticalTime =
NServiceBusMeter.CreateHistogram<double>(Metrics.CriticalTime, "s", "The time in seconds between when the message was sent until processed by the endpoint.");
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
NServiceBusMeter.CreateHistogram<double>(Metrics.CriticalTime, "s", "The time in seconds between when the message was sent until processed by the endpoint.");
NServiceBusMeter.CreateHistogram<double>(Metrics.CriticalTime, "s", "The time in seconds from when the message was sent to when it was processed.");

Copy link
Member

@mauroservienti mauroservienti Jun 25, 2024

Choose a reason for hiding this comment

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

I'm fine either way. The documentation states the following:

The time between when a message is sent and when it is fully processed.

Shall we align the text here with docs?

Suggested change
NServiceBusMeter.CreateHistogram<double>(Metrics.CriticalTime, "s", "The time in seconds between when the message was sent until processed by the endpoint.");
NServiceBusMeter.CreateHistogram<double>(Metrics.CriticalTime, "s", "The time in seconds between when a message is sent and when it is fully processed.");

Comment on lines +73 to +76
incomingPipelineMetricTags.ApplyTags(ref tags, [
MeterTags.QueueName,
MeterTags.EndpointDiscriminator,
MeterTags.MessageType]);
Copy link
Member

@mauroservienti mauroservienti Jun 25, 2024

Choose a reason for hiding this comment

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

@lailabougria @SzymonPobiega, is it useful to add here the MeterTags.MessageHandlerTypes? It'll be published to both critical and processing time, reporting all the handlers involved.

Suggested change
incomingPipelineMetricTags.ApplyTags(ref tags, [
MeterTags.QueueName,
MeterTags.EndpointDiscriminator,
MeterTags.MessageType]);
incomingPipelineMetricTags.ApplyTags(ref tags, [
MeterTags.QueueName,
MeterTags.EndpointDiscriminator,
MeterTags.MessageType,
MeterTags.MessageHandlerTypes]);

Comment on lines +50 to +55
[Test]
public async Task Should_not_record_critical_time_on_failure()
{
using TestingMetricListener metricsListener = await WhenMessagesHandled(() => new MyExceptionalMessage());
metricsListener.AssertMetric(CriticalTimeMetricName, 0);
}
Copy link
Member

Choose a reason for hiding this comment

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

@lailabougria, what do you think about this test? If that's what you meant, I'll add a similar one to the processing time metric PR

@SzymonPobiega
Copy link
Member

#7095

@SzymonPobiega SzymonPobiega removed this from the 9.1.0 milestone Jul 18, 2024
@saratry saratry deleted the otel/critical-time branch July 19, 2024 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants