def with_server_span(name):
 def with_server_span_decorator(fn):
  @functools.wraps(fn)
  def with_server_span_wrapper(*args, **kwargs):
   assert (not c.trace), 'called while already in a server span'
   try:
    with make_server_span(name):
     return fn(*args, **kwargs)
   finally:
    g.stats.flush()
  return with_server_span_wrapper
 return with_server_span_decorator

def with_server_span ( name ) : def with_server_span_decorator ( fn ) : @ functools . wraps ( fn ) def with_server_span_wrapper ( * args , ** kwargs ) : assert ( not c . trace ) , 'called while already in a server span' try : with make_server_span ( name ) : return fn ( * args , ** kwargs ) finally : g . stats . flush ( ) return with_server_span_wrapper return with_server_span_decorator
a decorator for functions that run outside request context .