Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(433)

Side by Side Diff: server/internal/logdog/collector/coordinator/cache.go

Issue 2123853002: Added unit annotation supports onto tsmon in go. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: Specify the unit of logdog/collector/subscription/processing_time_ms with types.Milliseconds Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « server/internal/logdog/collector/collector.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The LUCI Authors. All rights reserved. 1 // Copyright 2016 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package coordinator 5 package coordinator
6 6
7 import ( 7 import (
8 "sync" 8 "sync"
9 "time" 9 "time"
10 10
11 "github.com/luci/luci-go/common/clock" 11 "github.com/luci/luci-go/common/clock"
12 "github.com/luci/luci-go/common/config" 12 "github.com/luci/luci-go/common/config"
13 "github.com/luci/luci-go/common/errors" 13 "github.com/luci/luci-go/common/errors"
14 "github.com/luci/luci-go/common/logdog/types" 14 "github.com/luci/luci-go/common/logdog/types"
15 log "github.com/luci/luci-go/common/logging" 15 log "github.com/luci/luci-go/common/logging"
16 "github.com/luci/luci-go/common/lru" 16 "github.com/luci/luci-go/common/lru"
17 "github.com/luci/luci-go/common/promise" 17 "github.com/luci/luci-go/common/promise"
18 "github.com/luci/luci-go/common/tsmon/field" 18 "github.com/luci/luci-go/common/tsmon/field"
19 "github.com/luci/luci-go/common/tsmon/metric" 19 "github.com/luci/luci-go/common/tsmon/metric"
20 tsmon_types "github.com/luci/luci-go/common/tsmon/types"
20 "golang.org/x/net/context" 21 "golang.org/x/net/context"
21 ) 22 )
22 23
23 const ( 24 const (
24 // DefaultSize is the default (maximum) size of the LRU cache. 25 // DefaultSize is the default (maximum) size of the LRU cache.
25 DefaultSize = 1024 * 1024 26 DefaultSize = 1024 * 1024
26 27
27 // DefaultExpiration is the default expiration value. 28 // DefaultExpiration is the default expiration value.
28 DefaultExpiration = 10 * time.Minute 29 DefaultExpiration = 10 * time.Minute
29 ) 30 )
30 31
31 var ( 32 var (
32 tsCache = metric.NewCounter("logdog/collector/coordinator/cache", 33 tsCache = metric.NewCounter("logdog/collector/coordinator/cache",
33 "Metrics for cache uses, tracking hits and misses.", 34 "Metrics for cache uses, tracking hits and misses.",
35 tsmon_types.MetricMetadata{},
34 field.Bool("hit")) 36 field.Bool("hit"))
35 ) 37 )
36 38
37 // cache is a Coordinator interface implementation for the Collector service 39 // cache is a Coordinator interface implementation for the Collector service
38 // that caches remote results locally. 40 // that caches remote results locally.
39 type cache struct { 41 type cache struct {
40 Coordinator 42 Coordinator
41 43
42 // Size is the number of stream states to hold in the cache. 44 // Size is the number of stream states to hold in the cache.
43 size int 45 size int
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 ce.terminalIndex = tidx 296 ce.terminalIndex = tidx
295 } 297 }
296 }) 298 })
297 } 299 }
298 300
299 func (ce *cacheEntry) withLock(f func()) { 301 func (ce *cacheEntry) withLock(f func()) {
300 ce.Lock() 302 ce.Lock()
301 defer ce.Unlock() 303 defer ce.Unlock()
302 f() 304 f()
303 } 305 }
OLDNEW
« no previous file with comments | « server/internal/logdog/collector/collector.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698