Skip to content

Commit

Permalink
add metering
Browse files Browse the repository at this point in the history
  • Loading branch information
alecps committed Aug 3, 2023
1 parent 6b3decd commit 3ef838d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ErrorMessage, KeyVersionInfo } from '@celo/phone-number-privacy-common'
import Logger from 'bunyan'
import { performance } from 'perf_hooks'

export interface ServicePartialSignature {
url: string
Expand Down Expand Up @@ -38,7 +39,17 @@ export abstract class CryptoClient {
`${ErrorMessage.NOT_ENOUGH_PARTIAL_SIGNATURES} ${this.allSignaturesLength}/${threshold}`
)
}
return this._combineBlindedSignatureShares(blindedMessage, logger)

const start = `Start combineBlindedSignatureShares`
const end = `End combineBlindedSignatureShares`
performance.mark(start)

const combinedSignature = this._combineBlindedSignatureShares(blindedMessage, logger)

performance.mark(end)
performance.measure('combineBlindedSignatureShares', start, end)

return combinedSignature
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { computeBlindedSignature } from '../../../common/bls/bls-cryptography-cl
import { REQUESTS_TABLE } from '../../../common/database/models/request'
import { getRequestExists } from '../../../common/database/wrappers/request'
import { DefaultKeyName, Key, KeyProvider } from '../../../common/key-management/key-provider-base'
import { Counters } from '../../../common/metrics'
import { Counters, Histograms, meter } from '../../../common/metrics'
import { SignerConfig } from '../../../config'
import { PnpQuotaService } from '../../services/quota'
import { PnpSession } from '../../session'
Expand Down Expand Up @@ -113,10 +113,14 @@ export class PnpSignAction implements Action<SignMessageRequest> {
}

try {
const signature = await this.sign(
session.request.body.blindedQueryPhoneNumber,
key,
session
const signature = await meter(
this.sign,
[session.request.body.blindedQueryPhoneNumber, key, session],
(err: any) => {
throw err
},
Histograms.getBlindedSigInstrumentation,
['sign']
)
this.io.sendSuccess(200, session.response, key, signature, quotaStatus, session.errors)
return
Expand Down

0 comments on commit 3ef838d

Please sign in to comment.