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

chore: log incoming message execution time #1414

Merged
merged 2 commits into from
Dec 10, 2024
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
5 changes: 5 additions & 0 deletions source/B2BApi/IncomingMessages/IncomingMessageReceiver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System.Diagnostics;
using System.Net;
using System.Text;
using Energinet.DataHub.EDI.AuditLog.AuditLogger;
Expand Down Expand Up @@ -55,6 +56,7 @@ public async Task<HttpResponseData> RunAsync(
CancellationToken hostCancellationToken)
{
ArgumentNullException.ThrowIfNull(request);
var stopwatch = Stopwatch.StartNew();
var cancellationToken = request.GetCancellationToken(hostCancellationToken);

if (!await _featureFlagManager.ReceiveMeteredDataForMeasurementPointsAsync().ConfigureAwait(false))
Expand Down Expand Up @@ -113,6 +115,9 @@ public async Task<HttpResponseData> RunAsync(
var httpResponseData = await CreateResponseAsync(request, httpStatusCode, documentFormat, responseMessage)
.ConfigureAwait(false);

stopwatch.Stop();
_logger.LogInformation($"IncomingMessage Execution time: {stopwatch.ElapsedMilliseconds} ms");
MadsDue marked this conversation as resolved.
Show resolved Hide resolved

return httpResponseData;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System.Diagnostics;
using Energinet.DataHub.EDI.ArchivedMessages.Interfaces;
using Energinet.DataHub.EDI.ArchivedMessages.Interfaces.Models;
using Energinet.DataHub.EDI.BuildingBlocks.Domain.Authentication;
Expand Down Expand Up @@ -78,12 +79,18 @@ public async Task<ResponseMessage> ReceiveIncomingMarketMessageAsync(
{
ArgumentNullException.ThrowIfNull(documentType);
ArgumentNullException.ThrowIfNull(incomingMarketMessageStream);
var stopwatch = Stopwatch.StartNew();

var incomingMarketMessageParserResult = await ParseIncomingMessageAsync(
incomingMarketMessageStream,
incomingDocumentFormat,
documentType,
cancellationToken)
.ConfigureAwait(false);

stopwatch.Stop();
_logger.LogInformation($"IncomingMessage Parsing execution time: {stopwatch.ElapsedMilliseconds} ms");

if (incomingMarketMessageParserResult.Errors.Count != 0
|| incomingMarketMessageParserResult.IncomingMessage == null)
{
Expand All @@ -99,21 +106,30 @@ public async Task<ResponseMessage> ReceiveIncomingMarketMessageAsync(

if (ShouldArchive(documentType))
{
stopwatch.Restart();
await ArchiveIncomingMessageAsync(
incomingMarketMessageStream,
incomingMarketMessageParserResult.IncomingMessage,
documentType,
cancellationToken)
.ConfigureAwait(false);
stopwatch.Stop();
_logger.LogInformation($"IncomingMessage Archiving execution time: {stopwatch.ElapsedMilliseconds} ms");
}

stopwatch.Restart();
await _delegateIncomingMessage
.DelegateAsync(incomingMarketMessageParserResult.IncomingMessage, documentType, cancellationToken)
.ConfigureAwait(false);
stopwatch.Stop();
_logger.LogInformation($"IncomingMessage Delegation execution time: {stopwatch.ElapsedMilliseconds} ms");

stopwatch.Restart();
var validationResult = await _validateIncomingMessage
.ValidateAsync(incomingMarketMessageParserResult.IncomingMessage, incomingDocumentFormat, cancellationToken)
.ConfigureAwait(false);
stopwatch.Stop();
_logger.LogInformation($"IncomingMessage Validation execution time: {stopwatch.ElapsedMilliseconds} ms");

if (!validationResult.Success)
{
Expand All @@ -124,11 +140,14 @@ await _delegateIncomingMessage
return _responseFactory.From(validationResult, responseDocumentFormat);
}

stopwatch.Restart();
var result = await _incomingMessageReceiver
.ReceiveAsync(
incomingMarketMessageParserResult.IncomingMessage,
cancellationToken)
.ConfigureAwait(false);
stopwatch.Stop();
_logger.LogInformation($"IncomingMessage Receiving execution time: {stopwatch.ElapsedMilliseconds} ms");

if (result.Success)
{
Expand Down
Loading