Beispiel #1
0
        public IList <ClientSpan> CreateSaveClientSpans(CallTraceApiArgs args)
        {
            var saveSpans = new List <ClientSpan>();

            var dateHelper = DateHelper.Instance;
            var tracerId   = "DemoTracer-" + DateHelper.Instance.GetNowAsFormat("yyyyMMddHHmm");

            var theTime = dateHelper.GetDateNow();

            for (int i = 0; i < args.Count; i++)
            {
                //Task.Delay(TimeSpan.FromMilliseconds(args.IntervalMs)).Wait();
                var now     = theTime.AddMilliseconds(args.IntervalMs * i);
                var traceId = "Trace_" + now.Ticks;

                var apiSpan1 = CreateSaveClientSpans(tracerId, traceId, null, "SPAN_001", "FooApi");
                var apiSpan2 = CreateSaveClientSpans(tracerId, traceId, "SPAN_001", "SPAN_002", "FooService");
                var apiSpan3 = CreateSaveClientSpans(tracerId, traceId, "SPAN_002", "SPAN_003", "FooRepos", true);

                MockDuration(apiSpan1, now, 0, 500);
                MockDuration(apiSpan2, now, 50, 100);
                MockDuration(apiSpan3, now, 100, 200);

                saveSpans.Add(apiSpan1);
                saveSpans.Add(apiSpan2);
                saveSpans.Add(apiSpan3);
            }

            return(saveSpans);
        }
Beispiel #2
0
        public async Task CallTraceApi(CallTraceApiArgs args)
        {
            var saveSpans     = CreateSaveClientSpans(args);
            var saveSpansArgs = SaveSpansArgs.Create(saveSpans.ToArray());

            var apiProxy = ApiProxyContext.Current;
            await apiProxy.SaveSpans(saveSpansArgs);
        }