コード例 #1
0
        public IList <SaveSpansArgs> CreateTestClientSpans(HttpTestConfig config)
        {
            var result   = new List <SaveSpansArgs>();
            var now      = DateHelper.Instance.GetDateNow();
            var ticks    = now.Ticks;
            var traceId  = "trace_" + ticks;
            var tracerId = "ConcurrentTest-Tracer-" + now.ToString("yyyyMMddHHmmss");

            for (int i = 0; i < config.ConcurrentCount; i++)
            {
                var spanId         = "span_" + i.ToString("");
                var saveClientSpan = SaveClientSpan.Create(now, now.AddMilliseconds(10), tracerId, traceId, null, spanId, "FooOp");
                var saveSpansArgs  = new SaveSpansArgs();
                saveSpansArgs.Items.Add(saveClientSpan);
                result.Add(saveSpansArgs);
            }
            return(result);
        }
コード例 #2
0
        private async Task <TestResult> RunTestClientSpan(IWebApiTester webApiHelper, int failExpiredMs, SaveSpansArgs saveSpansArgs, HttpTestConfig config)
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();
            var jsonData = saveSpansArgs.ToJson(false);
            var saveOk   = await webApiHelper.TestHttpPost(config.GetSaveSpansApiUri(), jsonData, failExpiredMs).ConfigureAwait(false);

            stopwatch.Stop();
            var testResult = new TestResult();

            testResult.Success   = saveOk;
            testResult.ElapsedMs = stopwatch.ElapsedMilliseconds;
            var itemsCount     = saveSpansArgs.Items.Count;
            var saveClientSpan = saveSpansArgs.Items.First();

            testResult.Message = string.Format("{0}(1/{1}) => {2} , take {3:0.00} ms",
                                               saveClientSpan.SpanId,
                                               itemsCount,
                                               saveOk ? "Success" : "Fail",
                                               stopwatch.ElapsedMilliseconds);
            SimpleLog.Log(testResult.Message);
            return(testResult);
        }