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

feat(prism-agent): metrics for issuance flow #669

Merged
merged 8 commits into from
Sep 5, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ object MessagingService {
else
didCommService.packEncrypted(msg = finalMessage, to = finalMessage.to.head) // TODO Head

_ <- ZIO.log(s"Sending to Message to '$serviceEndpoint'")
_ <- ZIO.log(s"Sending a Message to '$serviceEndpoint'")
resp <- HttpClient
.postDIDComm(url = serviceEndpoint, data = encryptedMessage.string)
.catchAll { case ex => ZIO.fail(SendMessageError(ex, Some(encryptedMessage.string))) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import io.iohk.atala.pollux.core.model.schema.CredentialSchema
import io.iohk.atala.pollux.core.repository.CredentialRepository
import io.iohk.atala.pollux.vc.jwt.*
import io.iohk.atala.prism.crypto.{MerkleInclusionProof, MerkleTreeKt, Sha256}
import io.iohk.atala.shared.utils.aspects.CustomMetricsAspect
import zio.*
import zio.prelude.ZValidation

Expand Down Expand Up @@ -138,7 +139,8 @@ private class CredentialServiceImpl(
case 1 => ZIO.succeed(())
case n => ZIO.fail(UnexpectedException(s"Invalid row count result: $n"))
}
.mapError(RepositoryError.apply)
.mapError(RepositoryError.apply) @@ CustomMetricsAspect
.startRecordingTime(s"${record.id}_issuer_offer_pending_to_sent_ms_gauge")
} yield record
}

Expand Down Expand Up @@ -214,7 +216,9 @@ private class CredentialServiceImpl(
record <- getRecordWithState(recordId, ProtocolState.OfferReceived)
count <- credentialRepository
.updateWithSubjectId(recordId, subjectId, ProtocolState.RequestPending)
.mapError(RepositoryError.apply)
.mapError(RepositoryError.apply) @@ CustomMetricsAspect.startRecordingTime(
s"${record.id}_issuance_flow_holder_req_pending_to_generated"
)
_ <- count match
case 1 => ZIO.succeed(())
case n => ZIO.fail(RecordIdNotFound(recordId))
Expand Down Expand Up @@ -261,7 +265,10 @@ private class CredentialServiceImpl(
request = createDidCommRequestCredential(offer, signedPresentation)
count <- credentialRepository
.updateWithRequestCredential(recordId, request, ProtocolState.RequestGenerated)
.mapError(RepositoryError.apply)
.mapError(RepositoryError.apply) @@ CustomMetricsAspect.endRecordingTime(
s"${record.id}_issuance_flow_holder_req_pending_to_generated",
"issuance_flow_holder_req_pending_to_generated_ms_gauge"
) @@ CustomMetricsAspect.startRecordingTime(s"${record.id}_issuance_flow_holder_req_generated_to_sent")
_ <- count match
case 1 => ZIO.succeed(())
case n => ZIO.fail(RecordIdNotFound(recordId))
Expand Down Expand Up @@ -308,7 +315,9 @@ private class CredentialServiceImpl(
issue = createDidCommIssueCredential(request)
count <- credentialRepository
.updateWithIssueCredential(recordId, issue, ProtocolState.CredentialPending)
.mapError(RepositoryError.apply)
.mapError(RepositoryError.apply) @@ CustomMetricsAspect.startRecordingTime(
s"${record.id}_issuance_flow_issuer_credential_pending_to_generated"
)
_ <- count match
case 1 => ZIO.succeed(())
case n => ZIO.fail(RecordIdNotFound(recordId))
Expand Down Expand Up @@ -356,6 +365,9 @@ private class CredentialServiceImpl(
recordId,
IssueCredentialRecord.ProtocolState.RequestGenerated,
IssueCredentialRecord.ProtocolState.RequestSent
) @@ CustomMetricsAspect.endRecordingTime(
s"${recordId}_issuance_flow_holder_req_generated_to_sent",
"issuance_flow_holder_req_generated_to_sent_ms_gauge"
)

override def markCredentialGenerated(
Expand All @@ -370,7 +382,10 @@ private class CredentialServiceImpl(
issueCredential,
IssueCredentialRecord.ProtocolState.CredentialGenerated
)
.mapError(RepositoryError.apply)
.mapError(RepositoryError.apply) @@ CustomMetricsAspect.endRecordingTime(
s"${record.id}_issuance_flow_issuer_credential_pending_to_generated",
"issuance_flow_issuer_credential_pending_to_generated_ms_gauge"
) @@ CustomMetricsAspect.startRecordingTime(s"${record.id}_issuance_flow_issuer_credential_generated_to_sent")
_ <- count match
case 1 => ZIO.succeed(())
case n => ZIO.fail(RecordIdNotFound(recordId))
Expand All @@ -390,6 +405,9 @@ private class CredentialServiceImpl(
recordId,
IssueCredentialRecord.ProtocolState.CredentialGenerated,
IssueCredentialRecord.ProtocolState.CredentialSent
) @@ CustomMetricsAspect.endRecordingTime(
s"${recordId}_issuance_flow_issuer_credential_generated_to_sent",
"issuance_flow_issuer_credential_generated_to_sent_ms_gauge"
)

override def markCredentialPublicationPending(
Expand Down
Loading
Loading