Przeglądaj źródła

Diagnostic retries (#382)

* added Retries number to WritePublishError diagnostic event

* added Retries number to WriteSubscriberInvokeError diagnostic event
master
Dmitry 5 lat temu
committed by Savorboard
rodzic
commit
d531354e4b
6 zmienionych plików z 15 dodań i 8 usunięć
  1. +2
    -1
      src/DotNetCore.CAP/Diagnostics/DiagnosticListenerExtensions.cs
  2. +3
    -1
      src/DotNetCore.CAP/Diagnostics/EventData.Broker.PublishError.cs
  3. +4
    -2
      src/DotNetCore.CAP/Diagnostics/EventData.SubscriberInvokeError.cs
  4. +2
    -1
      src/DotNetCore.CAP/IPublishMessageSender.Base.cs
  5. +2
    -1
      src/DotNetCore.CAP/ISubscribeExecutor.Default.cs
  6. +2
    -2
      test/DotNetCore.CAP.Test/DiagnosticsTest.cs

+ 2
- 1
src/DotNetCore.CAP/Diagnostics/DiagnosticListenerExtensions.cs Wyświetl plik

@@ -203,6 +203,7 @@ namespace DotNetCore.CAP.Diagnostics
Exception ex,
DateTimeOffset startTime,
TimeSpan duration,
int retries,
[CallerMemberName] string operation = "")
{
if (@this.IsEnabled(CapErrorSubscriberInvoke))
@@ -214,7 +215,7 @@ namespace DotNetCore.CAP.Diagnostics

@this.Write(CapErrorSubscriberInvoke, new SubscriberInvokeErrorEventData(operationId, operation, methodName,
subscribeName,
subscribeGroup, parameterValues, ex, startTime, duration));
subscribeGroup, parameterValues, ex, startTime, duration, retries));
}
}
}

+ 3
- 1
src/DotNetCore.CAP/Diagnostics/EventData.Broker.PublishError.cs Wyświetl plik

@@ -9,12 +9,14 @@ namespace DotNetCore.CAP.Diagnostics
{
public BrokerPublishErrorEventData(Guid operationId, string operation, string brokerAddress,
string brokerTopicName, string brokerTopicBody, Exception exception, DateTimeOffset startTime,
TimeSpan duration)
TimeSpan duration, int retries)
: base(operationId, operation, brokerAddress, brokerTopicName, brokerTopicBody, startTime, duration)
{
Retries = retries;
Exception = exception;
}

public int Retries { get; }
public Exception Exception { get; }
}
}

+ 4
- 2
src/DotNetCore.CAP/Diagnostics/EventData.SubscriberInvokeError.cs Wyświetl plik

@@ -9,12 +9,14 @@ namespace DotNetCore.CAP.Diagnostics
{
public SubscriberInvokeErrorEventData(Guid operationId, string operation, string methodName,
string subscribeName, string subscribeGroup, string parameterValues, Exception exception,
DateTimeOffset startTime, TimeSpan duration) : base(operationId, operation, methodName, subscribeName,
subscribeGroup, parameterValues, startTime, duration)
DateTimeOffset startTime, TimeSpan duration, int retries) : base(operationId, operation, methodName,
subscribeName, subscribeGroup, parameterValues, startTime, duration)
{
Retries = retries;
Exception = exception;
}

public int Retries { get; }
public Exception Exception { get; }
}
}

+ 2
- 1
src/DotNetCore.CAP/IPublishMessageSender.Base.cs Wyświetl plik

@@ -190,7 +190,8 @@ namespace DotNetCore.CAP
message.Content,
ex,
startTime,
du);
du,
message.Retries + 1);

s_diagnosticListener.WritePublishError(eventData);
}


+ 2
- 1
src/DotNetCore.CAP/ISubscribeExecutor.Default.cs Wyświetl plik

@@ -199,7 +199,8 @@ namespace DotNetCore.CAP
}
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);
}


+ 2
- 2
test/DotNetCore.CAP.Test/DiagnosticsTest.cs Wyświetl plik

@@ -65,7 +65,7 @@ namespace DotNetCore.CAP.Test
var ex = new Exception("WritePublishErrorTest");
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);

}, kvp =>
@@ -192,7 +192,7 @@ namespace DotNetCore.CAP.Test
DiagnosticsWapper(() =>
{
s_diagnosticListener.WriteSubscriberInvokeError(operationId, FackConsumerContext(), ex,
DateTimeOffset.Now, TimeSpan.MaxValue);
DateTimeOffset.Now, TimeSpan.MaxValue, default(int));
}, kvp =>
{
if (kvp.Key.Equals(CapDiagnosticListenerExtensions.CapErrorSubscriberInvoke))


Ładowanie…
Anuluj
Zapisz