diff options
| author | Julie Qiu <julie@golang.org> | 2020-08-07 09:30:50 -0400 |
|---|---|---|
| committer | Julie Qiu <julie@golang.org> | 2021-06-12 01:54:21 +0000 |
| commit | 6f80375784c7ef415fc44ca3084bd5ed3834bbd7 (patch) | |
| tree | 6194f679ed8640ab7acd267d39617a868328aadd /internal/postgres | |
| parent | 2717a634e1e7d4bc46e5784db873fd701f92d5e1 (diff) | |
| download | go-x-pkgsite-6f80375784c7ef415fc44ca3084bd5ed3834bbd7.tar.xz | |
internal/dcensus: add Latency
There are several places where we need to compute the latency
measurement for recording an opencensus measurement.
A dcensus.Latency function is added so that
we can ensure latency is being calculated in the same way for all
measurements.
Change-Id: Ic138f29106f88c9c468084816d8856e47bbd7cc2
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/247359
Trust: Julie Qiu <julie@golang.org>
Run-TryBot: Julie Qiu <julie@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Diffstat (limited to 'internal/postgres')
| -rw-r--r-- | internal/postgres/search.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/internal/postgres/search.go b/internal/postgres/search.go index d5016884..ce8aebb0 100644 --- a/internal/postgres/search.go +++ b/internal/postgres/search.go @@ -22,6 +22,7 @@ import ( "golang.org/x/mod/semver" "golang.org/x/pkgsite/internal" "golang.org/x/pkgsite/internal/database" + "golang.org/x/pkgsite/internal/dcensus" "golang.org/x/pkgsite/internal/derrors" "golang.org/x/pkgsite/internal/experiment" "golang.org/x/pkgsite/internal/log" @@ -231,10 +232,9 @@ func (db *DB) hedgedSearch(ctx context.Context, q string, limit, offset, maxResu // skew the latency distribution. // Note that this latency measurement might differ meaningfully from the // resp.Latency, if time was spent waiting for the result count estimate. - latency := float64(time.Since(searchStart)) / float64(time.Millisecond) stats.RecordWithTags(ctx, []tag.Mutator{tag.Upsert(keySearchSource, resp.source)}, - searchLatency.M(latency)) + dcensus.MDur(searchLatency, time.Since(searchStart))) // To avoid fighting with the query planner, our searches only hit the // search_documents table and we enrich after getting the results. In the // future, we may want to fully denormalize and put all search data in the |
