@@ -2,6 +2,7 @@ package proxy
22
33import (
44 "context"
5+ "time"
56
67 "resenje.org/singleflight"
78
@@ -43,18 +44,30 @@ func (p *singleflightProxy) ReadWriteTx(ctx context.Context, f datastore.TxUserF
4344func (p * singleflightProxy ) OptimizedRevision (ctx context.Context ) (datastore.Revision , error ) {
4445 // NOTE: Optimized revisions are singleflighted by the underlying datastore via the
4546 // CachedOptimizedRevisions struct.
47+ ctx , span := tracer .Start (ctx , "singleflightProxy.OptimizedRevision" )
48+ defer span .End ()
4649 return p .delegate .OptimizedRevision (ctx )
4750}
4851
4952func (p * singleflightProxy ) CheckRevision (ctx context.Context , revision datastore.Revision ) error {
53+ ctx , cancel := context .WithTimeout (ctx , 5 * time .Second )
54+ defer cancel ()
55+
5056 _ , _ , err := p .checkRevGroup .Do (ctx , revision .String (), func (ctx context.Context ) (string , error ) {
57+ ctx , span := tracer .Start (ctx , "singleflightProxy.CheckRevision(sf)" )
58+ defer span .End ()
5159 return "" , p .delegate .CheckRevision (ctx , revision )
5260 })
5361 return err
5462}
5563
5664func (p * singleflightProxy ) HeadRevision (ctx context.Context ) (datastore.Revision , error ) {
65+ ctx , cancel := context .WithTimeout (ctx , 5 * time .Second )
66+ defer cancel ()
67+
5768 rev , _ , err := p .headRevGroup .Do (ctx , "" , func (ctx context.Context ) (datastore.Revision , error ) {
69+ ctx , span := tracer .Start (ctx , "singleflightProxy.HeadRevision(sf)" )
70+ defer span .End ()
5871 return p .delegate .HeadRevision (ctx )
5972 })
6073 return rev , err
@@ -69,6 +82,9 @@ func (p *singleflightProxy) Watch(ctx context.Context, afterRevision datastore.R
6982}
7083
7184func (p * singleflightProxy ) Statistics (ctx context.Context ) (datastore.Stats , error ) {
85+ ctx , cancel := context .WithTimeout (ctx , 5 * time .Second )
86+ defer cancel ()
87+
7288 stats , _ , err := p .statsGroup .Do (ctx , "" , func (ctx context.Context ) (datastore.Stats , error ) {
7389 return p .delegate .Statistics (ctx )
7490 })
0 commit comments