-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
participant-state-metrics: Add wrappers for v2. (#10404)
CHANGELOG_BEGIN CHANGELOG_END
- Loading branch information
1 parent
c3a3d60
commit b9518ce
Showing
4 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...etrics/src/main/scala/com/daml/ledger/participant/state/v2/metrics/TimedReadService.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package com.daml.ledger.participant.state.v2.metrics | ||
|
||
import akka.NotUsed | ||
import akka.stream.scaladsl.Source | ||
import com.daml.ledger.api.health.HealthStatus | ||
import com.daml.ledger.configuration.LedgerInitialConditions | ||
import com.daml.ledger.offset.Offset | ||
import com.daml.ledger.participant.state.v2.{ReadService, Update} | ||
import com.daml.metrics.{Metrics, Timed} | ||
|
||
final class TimedReadService(delegate: ReadService, metrics: Metrics) extends ReadService { | ||
|
||
override def ledgerInitialConditions(): Source[LedgerInitialConditions, NotUsed] = | ||
Timed.source( | ||
metrics.daml.services.read.getLedgerInitialConditions, | ||
delegate.ledgerInitialConditions(), | ||
) | ||
|
||
override def stateUpdates(beginAfter: Option[Offset]): Source[(Offset, Update), NotUsed] = | ||
Timed.source(metrics.daml.services.read.stateUpdates, delegate.stateUpdates(beginAfter)) | ||
|
||
override def currentHealth(): HealthStatus = | ||
delegate.currentHealth() | ||
} |
95 changes: 95 additions & 0 deletions
95
...trics/src/main/scala/com/daml/ledger/participant/state/v2/metrics/TimedWriteService.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
// Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package com.daml.ledger.participant.state.v2.metrics | ||
|
||
import java.util.concurrent.CompletionStage | ||
|
||
import com.daml.daml_lf_dev.DamlLf | ||
import com.daml.ledger.api.health.HealthStatus | ||
import com.daml.ledger.configuration.Configuration | ||
import com.daml.ledger.offset.Offset | ||
import com.daml.ledger.participant.state.v2.{ | ||
PruningResult, | ||
SubmissionResult, | ||
SubmitterInfo, | ||
TransactionMeta, | ||
WriteService, | ||
} | ||
import com.daml.lf.data.{Ref, Time} | ||
import com.daml.lf.transaction.SubmittedTransaction | ||
import com.daml.metrics.{Metrics, Timed} | ||
import com.daml.telemetry.TelemetryContext | ||
import com.google.rpc.status.Status | ||
|
||
final class TimedWriteService(delegate: WriteService, metrics: Metrics) extends WriteService { | ||
|
||
override def submitTransaction( | ||
submitterInfo: SubmitterInfo, | ||
transactionMeta: TransactionMeta, | ||
transaction: SubmittedTransaction, | ||
estimatedInterpretationCost: Long, | ||
)(implicit telemetryContext: TelemetryContext): CompletionStage[SubmissionResult] = | ||
Timed.timedAndTrackedCompletionStage( | ||
metrics.daml.services.write.submitTransaction, | ||
metrics.daml.services.write.submitTransactionRunning, | ||
delegate.submitTransaction( | ||
submitterInfo, | ||
transactionMeta, | ||
transaction, | ||
estimatedInterpretationCost, | ||
), | ||
) | ||
|
||
override def uploadPackages( | ||
submissionId: Ref.SubmissionId, | ||
archives: List[DamlLf.Archive], | ||
sourceDescription: Option[String], | ||
)(implicit telemetryContext: TelemetryContext): CompletionStage[SubmissionResult] = | ||
Timed.completionStage( | ||
metrics.daml.services.write.uploadPackages, | ||
delegate.uploadPackages(submissionId, archives, sourceDescription), | ||
) | ||
|
||
override def allocateParty( | ||
hint: Option[Ref.Party], | ||
displayName: Option[String], | ||
submissionId: Ref.SubmissionId, | ||
)(implicit telemetryContext: TelemetryContext): CompletionStage[SubmissionResult] = | ||
Timed.completionStage( | ||
metrics.daml.services.write.allocateParty, | ||
delegate.allocateParty(hint, displayName, submissionId), | ||
) | ||
|
||
override def submitConfiguration( | ||
maxRecordTime: Time.Timestamp, | ||
submissionId: Ref.SubmissionId, | ||
config: Configuration, | ||
)(implicit telemetryContext: TelemetryContext): CompletionStage[SubmissionResult] = | ||
Timed.completionStage( | ||
metrics.daml.services.write.submitConfiguration, | ||
delegate.submitConfiguration(maxRecordTime, submissionId, config), | ||
) | ||
|
||
override def prune( | ||
pruneUpToInclusive: Offset, | ||
submissionId: Ref.SubmissionId, | ||
): CompletionStage[PruningResult] = | ||
Timed.completionStage( | ||
metrics.daml.services.write.prune, | ||
delegate.prune(pruneUpToInclusive, submissionId), | ||
) | ||
|
||
override def currentHealth(): HealthStatus = | ||
delegate.currentHealth() | ||
|
||
override def rejectSubmission( | ||
submitterInfo: SubmitterInfo, | ||
submissionTime: Time.Timestamp, | ||
reason: Status, | ||
)(implicit telemetryContext: TelemetryContext): CompletionStage[SubmissionResult] = | ||
Timed.completionStage( | ||
metrics.daml.services.write.rejectSubmission, | ||
delegate.rejectSubmission(submitterInfo, submissionTime, reason), | ||
) | ||
} |