@agoric/cosmos 0.34.2-dev-a7fc433.0 → 0.34.2-dev-09ccd43.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/git-revision.txt CHANGED
@@ -1 +1 @@
1
- a7fc433
1
+ 09ccd43
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/cosmos",
3
- "version": "0.34.2-dev-a7fc433.0+a7fc433",
3
+ "version": "0.34.2-dev-09ccd43.0+09ccd43",
4
4
  "description": "Connect JS to the Cosmos blockchain SDK",
5
5
  "parsers": {
6
6
  "js": "mjs"
@@ -38,5 +38,5 @@
38
38
  "typeCoverage": {
39
39
  "atLeast": 0
40
40
  },
41
- "gitHead": "a7fc433ecf3a9a44aebd4ca247c5622351761487"
41
+ "gitHead": "09ccd43baa1008caf35c52d900ffc934f8b8419e"
42
42
  }
@@ -119,18 +119,24 @@ func NewKeeper(storeKey storetypes.StoreKey) Keeper {
119
119
  }
120
120
  }
121
121
 
122
+ // size_increase and size_decrease metrics represent total writes and deletes *issued*
123
+ // respectively, which may differ from the total number of bytes committed/freed
124
+ // to/from the store due to the store's internal implementation.
122
125
  var MetricKeyStoreSizeIncrease = []string{"store", "size_increase"}
123
- var MetricKeyStoreSizeDecrese = []string{"store", "size_decrease"}
126
+ var MetricKeyStoreSizeDecrease = []string{"store", "size_decrease"}
124
127
  const MetricLabelStoreKey = "storeKey"
125
128
 
126
- func ReportStoreSizeMetrics(k Keeper, sizeDelta float32) {
129
+ // reportStoreSizeMetrics exports store size increase/decrease metrics
130
+ // when Cosmos telemetry is enabled.
131
+ func (k Keeper) reportStoreSizeMetrics(increase int, decrease int) {
127
132
  metricsLabel := []metrics.Label{
128
133
  telemetry.NewLabel(MetricLabelStoreKey, k.storeKey.Name()),
129
134
  }
130
- if sizeDelta >= 0 {
131
- telemetry.IncrCounterWithLabels(MetricKeyStoreSizeIncrease, sizeDelta, metricsLabel)
132
- } else {
133
- telemetry.IncrCounterWithLabels(MetricKeyStoreSizeDecrese, -sizeDelta, metricsLabel)
135
+ if increase > 0 {
136
+ telemetry.IncrCounterWithLabels(MetricKeyStoreSizeIncrease, float32(increase), metricsLabel)
137
+ }
138
+ if decrease > 0 {
139
+ telemetry.IncrCounterWithLabels(MetricKeyStoreSizeDecrease, float32(decrease), metricsLabel)
134
140
  }
135
141
  }
136
142
 
@@ -233,8 +239,7 @@ func (k Keeper) RemoveEntriesWithPrefix(ctx sdk.Context, pathPrefix string) {
233
239
 
234
240
  for _, key := range keys {
235
241
  rawValue := store.Get(key)
236
- sizeDelta := float32(-len(key) - len(rawValue))
237
- ReportStoreSizeMetrics(k, sizeDelta)
242
+ k.reportStoreSizeMetrics(0, len(key) + len(rawValue))
238
243
  store.Delete(key)
239
244
  }
240
245
 
@@ -391,20 +396,17 @@ func (k Keeper) SetStorage(ctx sdk.Context, entry agoric.KVEntry) {
391
396
  if !entry.HasValue() {
392
397
  if !k.HasChildren(ctx, path) {
393
398
  // We have no children, can delete.
394
- sizeDelta := float32(-len(encodedKey) - len(oldRawValue))
395
- ReportStoreSizeMetrics(k, sizeDelta)
399
+ k.reportStoreSizeMetrics(0, len(encodedKey) + len(oldRawValue))
396
400
  store.Delete(encodedKey)
397
401
  } else {
398
402
  // We have children, mark as an empty placeholder without deleting.
399
- sizeDelta := float32(len(types.EncodedNoDataValue) - len(oldRawValue))
400
- ReportStoreSizeMetrics(k, sizeDelta)
403
+ k.reportStoreSizeMetrics(len(types.EncodedNoDataValue), len(oldRawValue))
401
404
  store.Set(encodedKey, types.EncodedNoDataValue)
402
405
  }
403
406
  } else {
404
407
  // Update the value.
405
408
  newRawValue := bytes.Join([][]byte{types.EncodedDataPrefix, []byte(entry.StringValue())}, []byte{})
406
- sizeDelta := float32(len(newRawValue) - len(oldRawValue))
407
- ReportStoreSizeMetrics(k, sizeDelta)
409
+ k.reportStoreSizeMetrics(len(newRawValue), len(oldRawValue))
408
410
  store.Set(encodedKey, newRawValue)
409
411
  }
410
412
 
@@ -419,8 +421,7 @@ func (k Keeper) SetStorage(ctx sdk.Context, entry agoric.KVEntry) {
419
421
  break
420
422
  }
421
423
  encodedAncestor := types.PathToEncodedKey(ancestor)
422
- sizeDelta := float32(-len(encodedAncestor) - len(types.EncodedNoDataValue))
423
- ReportStoreSizeMetrics(k, sizeDelta)
424
+ k.reportStoreSizeMetrics(0, len(encodedAncestor) + len(types.EncodedNoDataValue))
424
425
  store.Delete(encodedAncestor)
425
426
  }
426
427
  } else {
@@ -432,8 +433,7 @@ func (k Keeper) SetStorage(ctx sdk.Context, entry agoric.KVEntry) {
432
433
  break
433
434
  }
434
435
  encodedAncestor := types.PathToEncodedKey(ancestor)
435
- sizeDelta := float32(len(encodedAncestor) + len(types.EncodedNoDataValue))
436
- ReportStoreSizeMetrics(k, sizeDelta)
436
+ k.reportStoreSizeMetrics(len(encodedAncestor) + len(types.EncodedNoDataValue), 0)
437
437
  store.Set(encodedAncestor, types.EncodedNoDataValue)
438
438
  }
439
439
  }