Add BlobMetrics (#7622)

* Add BlobMetrics

Signed-off-by: 7suyash7 <suyashnyn1@gmail.com>

* refactor

Signed-off-by: 7suyash7 <suyashnyn1@gmail.com>

* remove unused blob_storage

Signed-off-by: 7suyash7 <suyashnyn1@gmail.com>

* add .size() to BlobCache

Signed-off-by: 7suyash7 <suyashnyn1@gmail.com>

* Add to Changelog

Signed-off-by: 7suyash7 <suyashnyn1@gmail.com>

---------

Signed-off-by: 7suyash7 <suyashnyn1@gmail.com>
Co-authored-by: Fabio Di Fabio <fabio.difabio@consensys.net>
pull/7644/head
Suyash Nayan 2 months ago committed by GitHub
parent 96e9873dd9
commit beaee59212
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 4
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/BlobCache.java
  3. 14
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPool.java
  4. 17
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPoolMetrics.java

@ -9,6 +9,7 @@
### Additions and Improvements ### Additions and Improvements
- Remove privacy test classes support [#7569](https://github.com/hyperledger/besu/pull/7569) - Remove privacy test classes support [#7569](https://github.com/hyperledger/besu/pull/7569)
- Add Blob Transaction Metrics [#7622](https://github.com/hyperledger/besu/pull/7622)
### Bug fixes ### Bug fixes
- Fix mounted data path directory permissions for besu user [#7575](https://github.com/hyperledger/besu/pull/7575) - Fix mounted data path directory permissions for besu user [#7575](https://github.com/hyperledger/besu/pull/7575)

@ -91,4 +91,8 @@ public class BlobCache {
public BlobsWithCommitments.BlobQuad get(final VersionedHash vh) { public BlobsWithCommitments.BlobQuad get(final VersionedHash vh) {
return cache.getIfPresent(vh); return cache.getIfPresent(vh);
} }
public long size() {
return cache.estimatedSize();
}
} }

@ -129,6 +129,7 @@ public class TransactionPool implements BlockAddedObserver {
this.blockAddedEventOrderedProcessor = this.blockAddedEventOrderedProcessor =
ethContext.getScheduler().createOrderedProcessor(this::processBlockAddedEvent); ethContext.getScheduler().createOrderedProcessor(this::processBlockAddedEvent);
this.cacheForBlobsOfTransactionsAddedToABlock = blobCache; this.cacheForBlobsOfTransactionsAddedToABlock = blobCache;
initializeBlobMetrics();
initLogForReplay(); initLogForReplay();
subscribePendingTransactions(this::mapBlobsOnTransactionAdded); subscribePendingTransactions(this::mapBlobsOnTransactionAdded);
subscribeDroppedTransactions(this::unmapBlobsOnTransactionDropped); subscribeDroppedTransactions(this::unmapBlobsOnTransactionDropped);
@ -686,6 +687,19 @@ public class TransactionPool implements BlockAddedObserver {
return isPoolEnabled.get(); return isPoolEnabled.get();
} }
public int getBlobCacheSize() {
return (int) cacheForBlobsOfTransactionsAddedToABlock.size();
}
public int getBlobMapSize() {
return mapOfBlobsInTransactionPool.size();
}
private void initializeBlobMetrics() {
metrics.createBlobCacheSizeMetric(this::getBlobCacheSize);
metrics.createBlobMapSizeMetric(this::getBlobMapSize);
}
class PendingTransactionsListenersProxy { class PendingTransactionsListenersProxy {
private final Subscribers<PendingTransactionAddedListener> onAddedListeners = private final Subscribers<PendingTransactionAddedListener> onAddedListeners =
Subscribers.create(); Subscribers.create();

@ -28,6 +28,7 @@ import org.hyperledger.besu.plugin.services.metrics.LabelledMetric;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.function.DoubleSupplier; import java.util.function.DoubleSupplier;
import java.util.function.IntSupplier;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -285,4 +286,20 @@ public class TransactionPoolMetrics {
private String priority(final boolean hasPriority) { private String priority(final boolean hasPriority) {
return hasPriority ? "yes" : "no"; return hasPriority ? "yes" : "no";
} }
public void createBlobCacheSizeMetric(final IntSupplier sizeSupplier) {
metricsSystem.createIntegerGauge(
BesuMetricCategory.TRANSACTION_POOL,
"blob_cache_size",
"Current size of the blob cache",
sizeSupplier);
}
public void createBlobMapSizeMetric(final IntSupplier sizeSupplier) {
metricsSystem.createIntegerGauge(
BesuMetricCategory.TRANSACTION_POOL,
"blob_map_size",
"Current size of the blob map",
sizeSupplier);
}
} }

Loading…
Cancel
Save