From ea85952f12a73285a2f8f50e690d2dc9b1477c1a Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Wed, 4 Dec 2024 09:35:29 +0100 Subject: [PATCH] @Timed for memberships, coopShares and coopAssets --- .../HsOfficeCoopAssetsTransactionController.java | 4 ++++ .../HsOfficeCoopAssetsTransactionRepository.java | 7 ++++++- .../HsOfficeCoopSharesTransactionController.java | 6 ++++++ .../HsOfficeCoopSharesTransactionRepository.java | 7 ++++++- .../office/membership/HsOfficeMembershipController.java | 6 ++++++ .../office/membership/HsOfficeMembershipRepository.java | 8 ++++++++ 6 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionController.java index 8288d7c1..b3b35ddb 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionController.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.hs.office.coopassets; +import io.micrometer.core.annotation.Timed; import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.errors.MultiValidationException; import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficeCoopAssetsApi; @@ -55,6 +56,7 @@ public class HsOfficeCoopAssetsTransactionController implements HsOfficeCoopAsse @Override @Transactional(readOnly = true) + @Timed("app.coopAssets.api.getListOfCoopAssets") public ResponseEntity> getListOfCoopAssets( final String currentSubject, final String assumedRoles, @@ -77,6 +79,7 @@ public class HsOfficeCoopAssetsTransactionController implements HsOfficeCoopAsse @Override @Transactional + @Timed("app.coopAssets.api.postNewCoopAssetTransaction") public ResponseEntity postNewCoopAssetTransaction( final String currentSubject, final String assumedRoles, @@ -102,6 +105,7 @@ public class HsOfficeCoopAssetsTransactionController implements HsOfficeCoopAsse @Override @Transactional(readOnly = true) + @Timed("app.coopAssets.api.getSingleCoopAssetTransactionByUuid") public ResponseEntity getSingleCoopAssetTransactionByUuid( final String currentSubject, final String assumedRoles, final UUID assetTransactionUuid) { diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionRepository.java index c606f476..26c2d09b 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/coopassets/HsOfficeCoopAssetsTransactionRepository.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.hs.office.coopassets; +import io.micrometer.core.annotation.Timed; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.Repository; @@ -10,6 +11,7 @@ import java.util.UUID; public interface HsOfficeCoopAssetsTransactionRepository extends Repository { + @Timed("app.coopAssets.repo.findByUuid") Optional findByUuid(UUID id); @Query(""" @@ -18,11 +20,14 @@ public interface HsOfficeCoopAssetsTransactionRepository extends Repository= :fromValueDate)) AND ( CAST(:toValueDate AS java.time.LocalDate)IS NULL OR (at.valueDate <= :toValueDate)) ORDER BY at.membership.memberNumberSuffix, at.valueDate - """) + """) + @Timed("app.coopAssets.repo.findCoopAssetsTransactionByOptionalMembershipUuidAndDateRange") List findCoopAssetsTransactionByOptionalMembershipUuidAndDateRange( UUID membershipUuid, LocalDate fromValueDate, LocalDate toValueDate); + @Timed("app.coopAssets.repo.save") HsOfficeCoopAssetsTransactionEntity save(final HsOfficeCoopAssetsTransactionEntity entity); + @Timed("app.coopAssets.repo.count") long count(); } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionController.java index ebd47800..12540e66 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionController.java @@ -1,6 +1,8 @@ package net.hostsharing.hsadminng.hs.office.coopshares; import jakarta.persistence.EntityNotFoundException; + +import io.micrometer.core.annotation.Timed; import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficeCoopSharesApi; import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeCoopSharesTransactionInsertResource; @@ -38,6 +40,8 @@ public class HsOfficeCoopSharesTransactionController implements HsOfficeCoopShar @Override @Transactional(readOnly = true) + + @Timed("app.coopShares.api.getListOfCoopShares") public ResponseEntity> getListOfCoopShares( final String currentSubject, final String assumedRoles, @@ -57,6 +61,7 @@ public class HsOfficeCoopSharesTransactionController implements HsOfficeCoopShar @Override @Transactional + @Timed("app.coopShares.repo.postNewCoopSharesTransaction") public ResponseEntity postNewCoopSharesTransaction( final String currentSubject, final String assumedRoles, @@ -80,6 +85,7 @@ public class HsOfficeCoopSharesTransactionController implements HsOfficeCoopShar @Override @Transactional(readOnly = true) + @Timed("app.coopShares.repo.getSingleCoopShareTransactionByUuid") public ResponseEntity getSingleCoopShareTransactionByUuid( final String currentSubject, final String assumedRoles, final UUID shareTransactionUuid) { diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionRepository.java index 5c3e0af6..d8322870 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/coopshares/HsOfficeCoopSharesTransactionRepository.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.hs.office.coopshares; +import io.micrometer.core.annotation.Timed; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.Repository; @@ -10,6 +11,7 @@ import java.util.UUID; public interface HsOfficeCoopSharesTransactionRepository extends Repository { + @Timed("app.coopShares.repo.findByUuid") Optional findByUuid(UUID id); @Query(""" @@ -18,11 +20,14 @@ public interface HsOfficeCoopSharesTransactionRepository extends Repository= :fromValueDate)) AND ( CAST(:toValueDate AS java.time.LocalDate)IS NULL OR (st.valueDate <= :toValueDate)) ORDER BY st.membership.memberNumberSuffix, st.valueDate - """) + """) + @Timed("app.coopShares.repo.findCoopSharesTransactionByOptionalMembershipUuidAndDateRange") List findCoopSharesTransactionByOptionalMembershipUuidAndDateRange( UUID membershipUuid, LocalDate fromValueDate, LocalDate toValueDate); + @Timed("app.coopShares.repo.save") HsOfficeCoopSharesTransactionEntity save(final HsOfficeCoopSharesTransactionEntity entity); + @Timed("app.coopShares.repo.count") long count(); } diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipController.java b/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipController.java index f41bd5c2..d2ee381b 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipController.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipController.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.hs.office.membership; +import io.micrometer.core.annotation.Timed; import net.hostsharing.hsadminng.context.Context; import net.hostsharing.hsadminng.hs.office.generated.api.v1.api.HsOfficeMembershipsApi; import net.hostsharing.hsadminng.hs.office.generated.api.v1.model.HsOfficeMembershipInsertResource; @@ -33,6 +34,7 @@ public class HsOfficeMembershipController implements HsOfficeMembershipsApi { @Override @Transactional(readOnly = true) + @Timed("app.membership.api.getListOfMemberships") public ResponseEntity> getListOfMemberships( final String currentSubject, final String assumedRoles, @@ -53,6 +55,7 @@ public class HsOfficeMembershipController implements HsOfficeMembershipsApi { @Override @Transactional + @Timed("app.membership.api.postNewMembership") public ResponseEntity postNewMembership( final String currentSubject, final String assumedRoles, @@ -76,6 +79,7 @@ public class HsOfficeMembershipController implements HsOfficeMembershipsApi { @Override @Transactional(readOnly = true) + @Timed("app.membership.api.getSingleMembershipByUuid") public ResponseEntity getSingleMembershipByUuid( final String currentSubject, final String assumedRoles, @@ -93,6 +97,7 @@ public class HsOfficeMembershipController implements HsOfficeMembershipsApi { @Override @Transactional + @Timed("app.membership.api.deleteMembershipByUuid") public ResponseEntity deleteMembershipByUuid( final String currentSubject, final String assumedRoles, @@ -109,6 +114,7 @@ public class HsOfficeMembershipController implements HsOfficeMembershipsApi { @Override @Transactional + @Timed("app.membership.api.patchMembership") public ResponseEntity patchMembership( final String currentSubject, final String assumedRoles, diff --git a/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipRepository.java b/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipRepository.java index d7f36d07..e0fb0e1e 100644 --- a/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipRepository.java +++ b/src/main/java/net/hostsharing/hsadminng/hs/office/membership/HsOfficeMembershipRepository.java @@ -1,5 +1,6 @@ package net.hostsharing.hsadminng.hs.office.membership; +import io.micrometer.core.annotation.Timed; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.Repository; @@ -10,10 +11,13 @@ import java.util.UUID; public interface HsOfficeMembershipRepository extends Repository { + @Timed("app.membership.repo.findByUuid") Optional findByUuid(UUID id); + @Timed("app.membership.repo.save") HsOfficeMembershipEntity save(final HsOfficeMembershipEntity entity); + @Timed("app.membership.repo.findAll") List findAll(); @Query(""" @@ -22,6 +26,7 @@ public interface HsOfficeMembershipRepository extends Repository findMembershipsByOptionalPartnerUuid(UUID partnerUuid); @Query(""" @@ -30,6 +35,7 @@ public interface HsOfficeMembershipRepository extends Repository