def operation_name_from_fun(fun: Any) -> str: obj = getattr(fun, '__self__', None) if obj is not None: objlabel = shortlabel(obj) funlabel = shortlabel(fun) if funlabel.startswith(objlabel): # remove obj name from function label funlabel = funlabel[len(objlabel):] return f'{objlabel}-{funlabel}' else: return f'{shortlabel(fun)}'
def operation_name_from_fun(fun: Any) -> str: """Generate opentracing name from function.""" obj = getattr(fun, "__self__", None) if obj is not None: objlabel = shortlabel(obj) funlabel = shortlabel(fun) if funlabel.startswith(objlabel): # remove obj name from function label funlabel = funlabel[len(objlabel) :] return f"{objlabel}-{funlabel}" else: return f"{shortlabel(fun)}"
def test_shortlabel(self, *, table): assert shortlabel(table)
def test_shortlabel(self, *, proxy): assert shortlabel(proxy) == 'Proxy'
def test_shortlabel(self, *, con): assert shortlabel(con)