public void SomeWorkNeedTrace() { //will use "FooService-GetUserInfo" span var tracer = TracerContext.GetCurrent(); tracer.ActiveSpan.Log("another log from FooService's SomeWork"); Task.Delay(100).Wait(); }
public string GetUserInfo(string username) { var tracer = TracerContext.GetCurrent(); using (var scope = tracer.BuildSpan("FooApi-GetUserInfo").StartActive(true)) { var result = _fooService.GetUserInfo(username); //按需使用 scope.Span.Log("a log from FooApi"); scope.Span.SetTag("username", username); return(result); } }
public string GetUserInfo(string username) { var tracer = TracerContext.GetCurrent(); using (var scope = tracer.BuildSpan("FooData-GetUserInfo").StartActive(true)) { //按需使用 scope.Span.Log("a log from FooData"); scope.Span.SetTag("username", username); Task.Delay(20).Wait(); var result = $"some info of {username}"; return(result); } }