Commit d531354e authored by Dmitry's avatar Dmitry Committed by Savorboard

Diagnostic retries (#382)

* added Retries number to WritePublishError diagnostic event

* added Retries number to WriteSubscriberInvokeError diagnostic event
parent b5e8716f
...@@ -203,6 +203,7 @@ namespace DotNetCore.CAP.Diagnostics ...@@ -203,6 +203,7 @@ namespace DotNetCore.CAP.Diagnostics
Exception ex, Exception ex,
DateTimeOffset startTime, DateTimeOffset startTime,
TimeSpan duration, TimeSpan duration,
int retries,
[CallerMemberName] string operation = "") [CallerMemberName] string operation = "")
{ {
if (@this.IsEnabled(CapErrorSubscriberInvoke)) if (@this.IsEnabled(CapErrorSubscriberInvoke))
...@@ -214,7 +215,7 @@ namespace DotNetCore.CAP.Diagnostics ...@@ -214,7 +215,7 @@ namespace DotNetCore.CAP.Diagnostics
@this.Write(CapErrorSubscriberInvoke, new SubscriberInvokeErrorEventData(operationId, operation, methodName, @this.Write(CapErrorSubscriberInvoke, new SubscriberInvokeErrorEventData(operationId, operation, methodName,
subscribeName, subscribeName,
subscribeGroup, parameterValues, ex, startTime, duration)); subscribeGroup, parameterValues, ex, startTime, duration, retries));
} }
} }
} }
......
...@@ -9,12 +9,14 @@ namespace DotNetCore.CAP.Diagnostics ...@@ -9,12 +9,14 @@ namespace DotNetCore.CAP.Diagnostics
{ {
public BrokerPublishErrorEventData(Guid operationId, string operation, string brokerAddress, public BrokerPublishErrorEventData(Guid operationId, string operation, string brokerAddress,
string brokerTopicName, string brokerTopicBody, Exception exception, DateTimeOffset startTime, string brokerTopicName, string brokerTopicBody, Exception exception, DateTimeOffset startTime,
TimeSpan duration) TimeSpan duration, int retries)
: base(operationId, operation, brokerAddress, brokerTopicName, brokerTopicBody, startTime, duration) : base(operationId, operation, brokerAddress, brokerTopicName, brokerTopicBody, startTime, duration)
{ {
Retries = retries;
Exception = exception; Exception = exception;
} }
public int Retries { get; }
public Exception Exception { get; } public Exception Exception { get; }
} }
} }
\ No newline at end of file
...@@ -9,12 +9,14 @@ namespace DotNetCore.CAP.Diagnostics ...@@ -9,12 +9,14 @@ namespace DotNetCore.CAP.Diagnostics
{ {
public SubscriberInvokeErrorEventData(Guid operationId, string operation, string methodName, public SubscriberInvokeErrorEventData(Guid operationId, string operation, string methodName,
string subscribeName, string subscribeGroup, string parameterValues, Exception exception, string subscribeName, string subscribeGroup, string parameterValues, Exception exception,
DateTimeOffset startTime, TimeSpan duration) : base(operationId, operation, methodName, subscribeName, DateTimeOffset startTime, TimeSpan duration, int retries) : base(operationId, operation, methodName,
subscribeGroup, parameterValues, startTime, duration) subscribeName, subscribeGroup, parameterValues, startTime, duration)
{ {
Retries = retries;
Exception = exception; Exception = exception;
} }
public int Retries { get; }
public Exception Exception { get; } public Exception Exception { get; }
} }
} }
\ No newline at end of file
...@@ -190,7 +190,8 @@ namespace DotNetCore.CAP ...@@ -190,7 +190,8 @@ namespace DotNetCore.CAP
message.Content, message.Content,
ex, ex,
startTime, startTime,
du); du,
message.Retries + 1);
s_diagnosticListener.WritePublishError(eventData); s_diagnosticListener.WritePublishError(eventData);
} }
......
...@@ -199,7 +199,8 @@ namespace DotNetCore.CAP ...@@ -199,7 +199,8 @@ namespace DotNetCore.CAP
} }
catch (Exception ex) catch (Exception ex)
{ {
s_diagnosticListener.WriteSubscriberInvokeError(operationId, consumerContext, ex, startTime, stopwatch.Elapsed); s_diagnosticListener.WriteSubscriberInvokeError(operationId, consumerContext, ex, startTime,
stopwatch.Elapsed, receivedMessage.Retries + 1);
throw new SubscriberExecutionFailedException(ex.Message, ex); throw new SubscriberExecutionFailedException(ex.Message, ex);
} }
......
...@@ -65,7 +65,7 @@ namespace DotNetCore.CAP.Test ...@@ -65,7 +65,7 @@ namespace DotNetCore.CAP.Test
var ex = new Exception("WritePublishErrorTest"); var ex = new Exception("WritePublishErrorTest");
DiagnosticsWapper(() => DiagnosticsWapper(() =>
{ {
var eventData = new BrokerPublishErrorEventData(operationId, "", "", "", "", ex, DateTimeOffset.UtcNow, default(TimeSpan)); var eventData = new BrokerPublishErrorEventData(operationId, "", "", "", "", ex, DateTimeOffset.UtcNow, default(TimeSpan), default(int));
s_diagnosticListener.WritePublishError(eventData); s_diagnosticListener.WritePublishError(eventData);
}, kvp => }, kvp =>
...@@ -192,7 +192,7 @@ namespace DotNetCore.CAP.Test ...@@ -192,7 +192,7 @@ namespace DotNetCore.CAP.Test
DiagnosticsWapper(() => DiagnosticsWapper(() =>
{ {
s_diagnosticListener.WriteSubscriberInvokeError(operationId, FackConsumerContext(), ex, s_diagnosticListener.WriteSubscriberInvokeError(operationId, FackConsumerContext(), ex,
DateTimeOffset.Now, TimeSpan.MaxValue); DateTimeOffset.Now, TimeSpan.MaxValue, default(int));
}, kvp => }, kvp =>
{ {
if (kvp.Key.Equals(CapDiagnosticListenerExtensions.CapErrorSubscriberInvoke)) if (kvp.Key.Equals(CapDiagnosticListenerExtensions.CapErrorSubscriberInvoke))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment