Unverified Commit 0d880506 authored by Steven Allen's avatar Steven Allen Committed by GitHub

Merge pull request #15 from ipfs/feat/implement-du

implement the PersistentDatastore interface
parents 160b391d 82ff6795
1.3.1: QmbJgZGRtkFeSdCxBCPaMKWRDYbqMxHyFfvjQGcWzpqsDe
1.3.2: QmXez8SABR95KKKgU9XFtTTQ79QRn2nWS9o5pa1EcHsLs5
os:
- linux
- osx
- linux
sudo: false
language: go
go:
- 1.8
- 1.9.x
install: true
install:
- make deps
script:
- make deps
- gx-go rewrite
- go get github.com/mattn/goveralls
- goveralls -service=travis-ci
- bash <(curl -s https://raw.githubusercontent.com/ipfs/ci-helpers/master/travis-ci/run-standard-tests.sh)
cache:
directories:
- $GOPATH/src/gx
notifications:
email: false
env: GOTFLAGS="-race -cpu=5"
test: deps
go test -race -v ./...
export IPFS_API ?= v04x.ipfs.io
gx:
......@@ -10,5 +7,3 @@ gx:
deps: gx
gx --verbose install --global
gx-go rewrite
go get -t ./...
......@@ -68,6 +68,11 @@ func New(prefix string, ds datastore.Datastore) *measure {
gcErr: metrics.New(prefix+".gc.errors_total", "Number of errored Datastore.CollectGarbage calls").Counter(),
gcLatency: metrics.New(prefix+".gc.latency_seconds",
"Latency distribution of Datastore.CollectGarbage calls").Histogram(datastoreLatencyBuckets),
duNum: metrics.New(prefix+".du_total", "Total number of Datastore.DiskUsage calls").Counter(),
duErr: metrics.New(prefix+".du.errors_total", "Number of errored Datastore.DiskUsage calls").Counter(),
duLatency: metrics.New(prefix+".du.latency_seconds",
"Latency distribution of Datastore.DiskUsage calls").Histogram(datastoreLatencyBuckets),
}
return m
}
......@@ -108,6 +113,10 @@ type measure struct {
gcNum metrics.Counter
gcErr metrics.Counter
gcLatency metrics.Histogram
duNum metrics.Counter
duErr metrics.Counter
duLatency metrics.Histogram
}
func recordLatency(h metrics.Histogram, start time.Time) {
......@@ -211,6 +220,16 @@ func (m *measure) CollectGarbage() error {
return nil
}
func (m *measure) DiskUsage() (uint64, error) {
defer recordLatency(m.duLatency, time.Now())
m.duNum.Inc()
size, err := datastore.DiskUsage(m.backend)
if err != nil {
m.duErr.Inc()
}
return size, err
}
type measuredBatch struct {
puts int
deletes int
......
......@@ -15,9 +15,9 @@
},
{
"author": "jbenet",
"hash": "QmXRKBQA4wXP7xWbFiZsR1GP4HV6wMDQ1aWFxZZ4uBcPX9",
"hash": "QmeiCcJfDW1GJnWUArudsv5rQsihpi4oyddPhdqo3CfX6i",
"name": "go-datastore",
"version": "2.4.0"
"version": "2.4.1"
}
],
"gxVersion": "0.8.0",
......@@ -25,6 +25,6 @@
"license": "",
"name": "go-ds-measure",
"releaseCmd": "git commit -a -m \"gx publish $VERSION\"",
"version": "1.3.1"
"version": "1.3.2"
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment