From b1e563517ac4926eb0b6b7874d263d18c8d6bd0f Mon Sep 17 00:00:00 2001 From: Sebastian Date: Fri, 17 Dec 2021 13:13:45 +0100 Subject: [PATCH] More telemetry. --- .../Orleans/LoggingFilter.cs | 31 +++++++++++-------- .../States/Persistence.cs | 20 +++++++++--- 2 files changed, 34 insertions(+), 17 deletions(-) diff --git a/backend/src/Squidex.Infrastructure/Orleans/LoggingFilter.cs b/backend/src/Squidex.Infrastructure/Orleans/LoggingFilter.cs index 6c9152027..ccde0b8d4 100644 --- a/backend/src/Squidex.Infrastructure/Orleans/LoggingFilter.cs +++ b/backend/src/Squidex.Infrastructure/Orleans/LoggingFilter.cs @@ -22,23 +22,28 @@ namespace Squidex.Infrastructure.Orleans public async Task Invoke(IIncomingGrainCallContext context) { - try - { - await context.Invoke(); - } - catch (DomainException ex) + var name = $"Grain/{context.Grain?.GetType().Name}/{context.ImplementationMethod?.Name}"; + + using (Telemetry.Activities.StartActivity(name)) { - if (ex.InnerException != null) + try { - Log(context, ex.InnerException); + await context.Invoke(); } + catch (DomainException ex) + { + if (ex.InnerException != null) + { + Log(context, ex.InnerException); + } - throw; - } - catch (Exception ex) - { - Log(context, ex); - throw; + throw; + } + catch (Exception ex) + { + Log(context, ex); + throw; + } } } diff --git a/backend/src/Squidex.Infrastructure/States/Persistence.cs b/backend/src/Squidex.Infrastructure/States/Persistence.cs index 0a3f1b628..1fa38f116 100644 --- a/backend/src/Squidex.Infrastructure/States/Persistence.cs +++ b/backend/src/Squidex.Infrastructure/States/Persistence.cs @@ -69,12 +69,18 @@ namespace Squidex.Infrastructure.States { if (UseSnapshots) { - await snapshotStore.RemoveAsync(ownerKey); + using (Telemetry.Activities.StartActivity("Persistence/ReadState")) + { + await snapshotStore.RemoveAsync(ownerKey); + } } if (UseEventSourcing) { - await eventStore.DeleteStreamAsync(streamName.Value); + using (Telemetry.Activities.StartActivity("Persistence/ReadEvents")) + { + await eventStore.DeleteStreamAsync(streamName.Value); + } } } @@ -171,7 +177,10 @@ namespace Squidex.Infrastructure.States return; } - await snapshotStore.WriteAsync(ownerKey, state, oldVersion, newVersion); + using (Telemetry.Activities.StartActivity("Persistence/WriteState")) + { + await snapshotStore.WriteAsync(ownerKey, state, oldVersion, newVersion); + } versionSnapshot = newVersion; @@ -194,7 +203,10 @@ namespace Squidex.Infrastructure.States try { - await eventStore.AppendAsync(eventCommitId, streamName.Value, oldVersion, eventData); + using (Telemetry.Activities.StartActivity("Persistence/WriteEvents")) + { + await eventStore.AppendAsync(eventCommitId, streamName.Value, oldVersion, eventData); + } } catch (WrongEventVersionException ex) {