public async Task InvokeAsync(HttpContext context)
        {
            TraceIdentifiersContext feature = TraceIdentifiersContext.Startup
                                              .CloneForThread();

            string local = this.Options.LocalValueFactory(context);

            this.TryToWriteLocal(context, local);

            feature = feature.CreateChildWithLocal(this.Options.LocalIsShared(context), local);
            context.Features.Set(feature);

            ICollection <string> all = this.TryToReadRemote(context).ToArray();

            if (all.Any())
            {
                feature.CreateChildWithRemote(all);
            }

            try
            {
                using (feature)
                {
                    await _next(context);
                }
            }
            finally
            {
                this.TryToWriteLocal(context, local);
            }
        }
        public async Task InvokeAsync(HttpContext context)
        {
            this.TryToWriteLocal(context);
            ICollection <string> all = this.TryToReadRemoteShared(context).ToArray();

            TraceIdentifiersContext feature = TraceIdentifiersContext.StartupEmpty
                                              .CloneForThread();

            feature.Remote = this.TryToReadRemoteSingle(context);

            feature = feature.CreateChildWithLocal(this.Options.ShareLocal, context.TraceIdentifier);

            using (feature)
            {
                if (all.Any())
                {
                    using (var withRemote = feature.CreateChildWithRemote(all))
                    {
                        context.Features.Set(withRemote);
                        await _next(context);
                    }
                }
                else
                {
                    context.Features.Set(feature);
                    await _next(context);
                }
            }

            this.TryToWriteLocal(context);
        }