DKX.Tracer by david_kudera

<PackageReference Include="DKX.Tracer" Version="0.1.0" />

 RootSpan

using DKX.Tracer.Exporters; using Microsoft.AspNetCore.Http; using System; using System.Diagnostics; using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; namespace DKX.Tracer { [System.Runtime.CompilerServices.NullableContext(2)] [System.Runtime.CompilerServices.Nullable(0)] public class RootSpan : Span, IRootSpan, ISpan, IDisposable, IAsyncDisposable { [System.Runtime.CompilerServices.Nullable(1)] private readonly IExporter _exporter; public HttpRequest HttpRequest { get; set; } public HttpResponse HttpResponse { get; set; } public Exception Exception { get; set; } [System.Runtime.CompilerServices.NullableContext(1)] public RootSpan(IExporter exporter, IDateTimeProvider dateTimeProvider, string name) : base(dateTimeProvider, name, null) { _exporter = exporter; } [AsyncStateMachine(typeof(<DisposeAsync>d__14))] [DebuggerStepThrough] public ValueTask DisposeAsync() { <DisposeAsync>d__14 stateMachine = new <DisposeAsync>d__14(); stateMachine.<>4__this = this; stateMachine.<>t__builder = AsyncValueTaskMethodBuilder.Create(); stateMachine.<>1__state = -1; stateMachine.<>t__builder.Start(ref stateMachine); return stateMachine.<>t__builder.Task; } [System.Runtime.CompilerServices.NullableContext(1)] public IRootSpan AttachHttpRequest(HttpRequest request) { if (base.Closed) throw new Exception("Can not attach http request to closed span " + base.Name); HttpRequest = request; return this; } [System.Runtime.CompilerServices.NullableContext(1)] public IRootSpan AttachHttpResponse(HttpResponse response) { if (base.Closed) throw new Exception("Can not attach http response to closed span " + base.Name); HttpResponse = response; return this; } [System.Runtime.CompilerServices.NullableContext(1)] public IRootSpan AttachException(Exception exception) { if (base.Closed) throw new Exception("Can not attach exception to closed span " + base.Name); Exception = exception; return this; } [System.Runtime.CompilerServices.NullableContext(1)] public Task Save(CancellationToken cancellationToken = default(CancellationToken)) { return _exporter.Save(this, cancellationToken); } } }