@agoric/cosmos 0.34.2-dev-f83e5a9.0 → 0.34.2-dev-3825031.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
- f83e5a9
1
+ 3825031
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/cosmos",
3
- "version": "0.34.2-dev-f83e5a9.0+f83e5a9",
3
+ "version": "0.34.2-dev-3825031.0+3825031",
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": "f83e5a92dd636fb3d36beb671d37f1fcd61fa48c"
41
+ "gitHead": "38250315cedf68dc801b75bee867818a3846fae7"
42
42
  }
@@ -119,13 +119,19 @@ func NewKeeper(storeKey storetypes.StoreKey) Keeper {
119
119
  }
120
120
  }
121
121
 
122
- var MetricKeysSizeDelta = []string{"store", "size_delta"}
122
+ var MetricKeyStoreSizeIncrease = []string{"store", "size_increase"}
123
+ var MetricKeyStoreSizeDecrese = []string{"store", "size_decrease"}
123
124
  const MetricLabelStoreKey = "storeKey"
124
125
 
125
- func NewMetricsLabels(k Keeper) []metrics.Label {
126
- return []metrics.Label{
126
+ func ReportStoreSizeMetrics(k Keeper, sizeDelta float32) {
127
+ metricsLabel := []metrics.Label{
127
128
  telemetry.NewLabel(MetricLabelStoreKey, k.storeKey.Name()),
128
129
  }
130
+ if sizeDelta >= 0 {
131
+ telemetry.IncrCounterWithLabels(MetricKeyStoreSizeIncrease, sizeDelta, metricsLabel)
132
+ } else {
133
+ telemetry.IncrCounterWithLabels(MetricKeyStoreSizeDecrese, -sizeDelta, metricsLabel)
134
+ }
129
135
  }
130
136
 
131
137
  // ExportStorage fetches all storage
@@ -228,7 +234,7 @@ func (k Keeper) RemoveEntriesWithPrefix(ctx sdk.Context, pathPrefix string) {
228
234
  for _, key := range keys {
229
235
  rawValue := store.Get(key)
230
236
  sizeDelta := float32(-len(key) - len(rawValue))
231
- telemetry.IncrCounterWithLabels(MetricKeysSizeDelta, sizeDelta, NewMetricsLabels(k))
237
+ ReportStoreSizeMetrics(k, sizeDelta)
232
238
  store.Delete(key)
233
239
  }
234
240
 
@@ -386,19 +392,19 @@ func (k Keeper) SetStorage(ctx sdk.Context, entry agoric.KVEntry) {
386
392
  if !k.HasChildren(ctx, path) {
387
393
  // We have no children, can delete.
388
394
  sizeDelta := float32(-len(encodedKey) - len(oldRawValue))
389
- telemetry.IncrCounterWithLabels(MetricKeysSizeDelta, sizeDelta, NewMetricsLabels(k))
395
+ ReportStoreSizeMetrics(k, sizeDelta)
390
396
  store.Delete(encodedKey)
391
397
  } else {
392
398
  // We have children, mark as an empty placeholder without deleting.
393
399
  sizeDelta := float32(len(types.EncodedNoDataValue) - len(oldRawValue))
394
- telemetry.IncrCounterWithLabels(MetricKeysSizeDelta, sizeDelta, NewMetricsLabels(k))
400
+ ReportStoreSizeMetrics(k, sizeDelta)
395
401
  store.Set(encodedKey, types.EncodedNoDataValue)
396
402
  }
397
403
  } else {
398
404
  // Update the value.
399
405
  newRawValue := bytes.Join([][]byte{types.EncodedDataPrefix, []byte(entry.StringValue())}, []byte{})
400
406
  sizeDelta := float32(len(newRawValue) - len(oldRawValue))
401
- telemetry.IncrCounterWithLabels(MetricKeysSizeDelta, sizeDelta, NewMetricsLabels(k))
407
+ ReportStoreSizeMetrics(k, sizeDelta)
402
408
  store.Set(encodedKey, newRawValue)
403
409
  }
404
410
 
@@ -414,7 +420,7 @@ func (k Keeper) SetStorage(ctx sdk.Context, entry agoric.KVEntry) {
414
420
  }
415
421
  encodedAncestor := types.PathToEncodedKey(ancestor)
416
422
  sizeDelta := float32(-len(encodedAncestor) - len(types.EncodedNoDataValue))
417
- telemetry.IncrCounterWithLabels(MetricKeysSizeDelta, sizeDelta, NewMetricsLabels(k))
423
+ ReportStoreSizeMetrics(k, sizeDelta)
418
424
  store.Delete(encodedAncestor)
419
425
  }
420
426
  } else {
@@ -427,7 +433,7 @@ func (k Keeper) SetStorage(ctx sdk.Context, entry agoric.KVEntry) {
427
433
  }
428
434
  encodedAncestor := types.PathToEncodedKey(ancestor)
429
435
  sizeDelta := float32(len(encodedAncestor) + len(types.EncodedNoDataValue))
430
- telemetry.IncrCounterWithLabels(MetricKeysSizeDelta, sizeDelta, NewMetricsLabels(k))
436
+ ReportStoreSizeMetrics(k, sizeDelta)
431
437
  store.Set(encodedAncestor, types.EncodedNoDataValue)
432
438
  }
433
439
  }