Skip to content

Commit

Permalink
[3892] Log editing context save duration on debug
Browse files Browse the repository at this point in the history
Bug: #3892
Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
  • Loading branch information
pcdavid committed Aug 28, 2024
1 parent db03783 commit 2d40f79
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import org.eclipse.sirius.web.domain.boundedcontexts.project.Project;
import org.eclipse.sirius.web.domain.boundedcontexts.semanticdata.Document;
import org.eclipse.sirius.web.domain.boundedcontexts.semanticdata.services.api.ISemanticDataUpdateService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.jdbc.core.mapping.AggregateReference;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
Expand All @@ -46,6 +48,8 @@ public class EditingContextPersistenceService implements IEditingContextPersiste

private static final String TIMER_NAME = "siriusweb_editingcontext_save";

private final Logger logger = LoggerFactory.getLogger(EditingContextPersistenceService.class);

private final ISemanticDataUpdateService semanticDataUpdateService;

private final IResourceToDocumentService resourceToDocumentService;
Expand All @@ -64,7 +68,7 @@ public EditingContextPersistenceService(ISemanticDataUpdateService semanticDataU
@Override
@Transactional
public void persist(IEditingContext editingContext) {
long start = System.currentTimeMillis();
long start = System.nanoTime();

if (editingContext instanceof IEMFEditingContext emfEditingContext) {
new UUIDParser().parse(editingContext.getId())
Expand All @@ -90,7 +94,8 @@ public void persist(IEditingContext editingContext) {
});
}

long end = System.currentTimeMillis();
this.timer.record(end - start, TimeUnit.MILLISECONDS);
long durationNs = System.nanoTime() - start;
this.timer.record(durationNs, TimeUnit.NANOSECONDS);
this.logger.debug("Editing context {} saved in {} ms", editingContext.getId(), TimeUnit.NANOSECONDS.toMillis(durationNs));
}
}

0 comments on commit 2d40f79

Please sign in to comment.