NewStore creates a Store to build service graphs. The store caches edges, each representing a request between two services. Once an edge is complete its metrics can be collected. Edges that have not found their pair are deleted after ttl time.
(ttl time.Duration, maxItems int, onComplete, onExpire Callback, droppedSpanSideOverflowCounter prometheus.Counter)
| 40 | // request between two services. Once an edge is complete its metrics can be collected. Edges that |
| 41 | // have not found their pair are deleted after ttl time. |
| 42 | func NewStore(ttl time.Duration, maxItems int, onComplete, onExpire Callback, droppedSpanSideOverflowCounter prometheus.Counter) Store { |
| 43 | s := &store{ |
| 44 | l: list.New(), |
| 45 | m: make(map[string]*list.Element), |
| 46 | d: make(map[droppedSpanSideKey]int64), |
| 47 | |
| 48 | onComplete: onComplete, |
| 49 | onExpire: onExpire, |
| 50 | |
| 51 | ttl: ttl, |
| 52 | maxItems: maxItems, |
| 53 | |
| 54 | droppedSpanSideOverflowCounter: droppedSpanSideOverflowCounter, |
| 55 | } |
| 56 | |
| 57 | return s |
| 58 | } |
| 59 | |
| 60 | func (s *store) len() int { |
| 61 | s.mtx.Lock() |
no outgoing calls