Skip to content

Commit

Permalink
[JSON-API] Add metrics for ledger command submission timing (#10076)
Browse files Browse the repository at this point in the history
changelog_begin

- [JSON-API] Timing metrics which measure how long the processing of a command submission request takes on the ledger are now available

changelog_end
  • Loading branch information
realvictorprm authored Jun 22, 2021
1 parent 7eb2ce7 commit 1f5aa44
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,10 @@ class Endpoints(
_ <- EitherT.pure(parseAndDecodeTimerCtx.close())

ac <- eitherT(
handleFutureEitherFailure(commandService.create(jwt, jwtPayload, cmd))
Timed.future(
metrics.daml.HttpJsonApi.commandSubmissionLedgerTimer,
handleFutureEitherFailure(commandService.create(jwt, jwtPayload, cmd)),
)
): ET[domain.ActiveContract[ApiValue]]
} yield ac
}
Expand All @@ -241,8 +244,11 @@ class Endpoints(
resolvedCmd = cmd.copy(argument = apiArg, reference = resolvedRef)

resp <- eitherT(
handleFutureEitherFailure(
commandService.exercise(jwt, jwtPayload, resolvedCmd)
Timed.future(
metrics.daml.HttpJsonApi.commandSubmissionLedgerTimer,
handleFutureEitherFailure(
commandService.exercise(jwt, jwtPayload, resolvedCmd)
),
)
): ET[domain.ExerciseResponse[ApiValue]]

Expand All @@ -261,8 +267,11 @@ class Endpoints(
_ <- EitherT.pure(parseAndDecodeTimerCtx.close())

resp <- eitherT(
handleFutureEitherFailure(
commandService.createAndExercise(jwt, jwtPayload, cmd)
Timed.future(
metrics.daml.HttpJsonApi.commandSubmissionLedgerTimer,
handleFutureEitherFailure(
commandService.createAndExercise(jwt, jwtPayload, cmd)
),
)
): ET[domain.ExerciseResponse[ApiValue]]
} yield resp
Expand Down
3 changes: 3 additions & 0 deletions ledger/metrics/src/main/scala/com/daml/metrics/Metrics.scala
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,9 @@ final class Metrics(val registry: MetricRegistry) {
val dbFindByContractKey: Timer = registry.timer(Prefix :+ "db_find_by_contract_key_timing")
// Meters how long a find by contract id database operation takes
val dbFindByContractId: Timer = registry.timer(Prefix :+ "db_find_by_contract_id_timing")
// Meters how long processing of the command submission request takes on the ledger
val commandSubmissionLedgerTimer: Timer =
registry.timer(Prefix :+ "command_submission_ledger_timing")
// Meters http requests throughput
val httpRequestThroughput: Meter = registry.meter(Prefix :+ "http_request_throughput")
// Meters how many websocket connections are currently active
Expand Down

0 comments on commit 1f5aa44

Please sign in to comment.