Ejemplo n.º 1
0
        public ISpanContext Extract <TCarrier>(IFormat <TCarrier> format, TCarrier carrier)
        {
            VerifySupportedFormat(format);
            ITextMap implCarrier = GetRealCarrier(carrier);
            Trace    trace       = null;

            if (!_traceExtractor.TryExtract(implCarrier, (c, key) => c.Where(x => x.Key == key).Select(x => x.Value).FirstOrDefault(), out trace))
            {
                return(null);
            }
            return(new OtSpanContext(trace));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 通过<paramref name="dic"/>构建本地跟踪通过<see cref="ServerTrace"/>,<see cref="LocalTrace"/>使用
 /// </summary>
 /// <param name="dic">字典对象</param>
 public void Create(IDictionary <string, string> dic = null)
 {
     if (dic == null)
     {
         Unity.Get();
     }
     else
     {
         tracing.Trace trace;
         if (!_extractor.TryExtract(dic, (c, key) =>
         {
             string value;
             c.TryGetValue(key, out value);
             return(value);
         }, out trace))
         {
             Unity.Get();
         }
         else
         {
             Unity.Set(trace);
         }
     }
 }